当前位置:网站首页>FPGA初次尝试
FPGA初次尝试
2022-06-09 02:43:00 【舒溶】
quartus II易错
编写verilog语言并编译

module名字要和文件名字一样,这个名字也要尽量和项目名字一样,这样不容易出错
modelsim仿真



再添加testbench,自己写仿真程序
modelSim 重复仿真

假设修改了testBench程序文件或者元器件程序,要重新编译一下

选择要重新编译的两个文件,从新编译
然后打开仿真文件

拉到最底下选work里面的testBench文件,然后确定
然后最左边instance那里,ctrl+w添加波形,然后

restart和run进行仿真。记得中间是总时间长度
仿真波形输出十进制

课设源代码
module xiyiji
#(
parameter set_cnt_min = 25'd10
)
(
input wire sys_clk,
input wire sys_work,
output wire [24:0] out_sec,
output wire [24:0] out_min,
output wire [0:0] is_finish
);
reg [24:0] cnt_sec=25'd20;
reg [24:0] state=25'd0;
reg [24:0] cnt_min=set_cnt_min;
always @(posedge sys_clk or negedge sys_work)
if(sys_work==1'b0)begin
//不工作的时候设置为初始值
cnt_sec<=25'd20;
state<=25'd0;
cnt_min<=set_cnt_min;
end
else if(cnt_min==25'd0)begin
cnt_min<=cnt_min;
cnt_sec<=25'd0;
state<=25'd0;
end
else if(cnt_sec==25'd0)begin
if(state==25'd3&&cnt_min==25'd1)begin
//结束了
state<=25'd0;
cnt_min<=25'd0;
cnt_sec<=25'd0;
end
else if(state==25'd3)begin
//一个轮回结束了
state<=25'd0;
cnt_min<=cnt_min-25'd1;
end
else begin
//一个中间状态跳转到另一个中间状态
state<=state+25'd1;
end
cnt_sec<=(state==25'd1||state==25'd3)?25'd19:25'd9;
end
else begin
cnt_sec<=cnt_sec-25'd1;
end
assign out_sec=cnt_sec;
assign out_min=cnt_min;
assign is_finis=(cnt_min==25'd0)?1'b1:1'b0;
endmodule
`timescale 10ns/1ns
module tb_led();
reg sys_clk;
reg sys_work;
wire [24:0] out_sec;
wire [24:0] out_min;
wire [0:0] is_finish;
initial
begin
sys_clk=1'b1;
sys_work<=1'b0;
#20
sys_work<=1'b1;
end
always #10 sys_clk=~sys_clk;
xiyiji
#(
.set_cnt_min(25'd8)
)
xiyijiInst(
.sys_clk(sys_clk),
.sys_work(sys_work),
.out_sec(out_sec),
.out_min(out_min),
.is_finish(is_finish)
);
endmodule
边栏推荐
- 说说你印象中比较深刻的 Bug
- Datetimeformatter date formatting and parsing
- Leetcode 974. And K divisible subarray prefix sum
- Export related knowledge
- The high-end is weak. Can Yanghe still keep the third place in the industry?
- LocalTime 、LocalDate 、LocalDateTime
- Jedis tool class, adapting to a single redis and redis cluster
- 接口测试系列——转转交易业务场景接口测试实践
- Leetcode 1155. N façons de rouler les dés
- Problems and solutions in using renrenfast
猜你喜欢

【HomeAssistant外网访问(cpolar)】

Using redis in business code to achieve caching effect

LocalTime 、LocalDate 、LocalDateTime

Ccf-csp 201803-5 quadratic summation 30 points

FFmpeg的软、硬解码方式梳理

Discussion on MLIR Technology
![[coding streaming] installation and use of SRS streaming media server](/img/8a/e3462db8425377d32ec2ef22c1ccf3.png)
[coding streaming] installation and use of SRS streaming media server
![[network protocol] | [01] network byte order big end and small end](/img/9f/c69293aa8983161f4733a84389a311.png)
[network protocol] | [01] network byte order big end and small end

toggleRowSelection()失效的2个重要影响因素

Go Technology Daily (June 7, 2022) - go programmer development efficiency artifact summary
随机推荐
TypeScript 基础类型 —— 类型断言
qt项目添加编译报错选项
Leetcode 1155. N façons de rouler les dés
Acwing 791 high precision addition
Two important influencing factors of togglerowselection() failure
Ccf-csp 201903-2 24:00
Jsnpp框架的全链式语法初探
Discussion on MLIR Technology
Go技術日報(2022-06-07)——go程序員開發效率神器匯總
Leetcode 974. And K divisible subarray prefix sum
Binding mode of QT overloaded signal slot function
Leetcode 1310. Subarray XOR query prefix and + XOR
toggleRowSelection()失效的2個重要影響因素
export相關知識
Problems and solutions in using renrenfast
Sorting out the soft and hard decoding methods of ffmpeg
Docker安装Redis
Basic principle of digital circuit adder (I)
LocalTime 、LocalDate 、LocalDateTime
New textbook for self taught examination-p292