当前位置:首页 >> 硬件技术 >> 【Verilog语法】比较不同计数器的运算方式,其中有一个数是延迟打一拍的效果,目的是使得两个计数器的结果相同。,魅族mx论坛

【Verilog语法】比较不同计数器的运算方式,其中有一个数是延迟打一拍的效果,目的是使得两个计数器的结果相同。,魅族mx论坛

cpugpu芯片开发光刻机 硬件技术 2
文件名:【Verilog语法】比较不同计数器的运算方式,其中有一个数是延迟打一拍的效果,目的是使得两个计数器的结果相同。,魅族mx论坛 【Verilog语法】比较不同计数器的运算方式,其中有一个数是延迟打一拍的效果,目的是使得两个计数器的结果相同。

比较不同计数器的运算方式,其中有一个数是延迟打一拍的效果,目的是使得两个计数器的结果相同。 1,第一种2,第二种3,第三种

第三种方案,完成实现。

1,第一种

(1)RTL

module c(input clk,input rst_n,// input a,// input b,output cnt1,output cnt2);reg [4:0] cnt1, cnt2;always@(posedge clk or negedge rst_n) beginif(!rst_n) begincnt1 <= 0;cnt2 <= 0;endelse if(cnt1 <= 16) begincnt1 <= cnt1 + 1;cnt2 <= cnt1; endelse begincnt1 <= 0;cnt2 <= 0;end endendmodule

(2)TB

module tb_c;reg clk;reg rst_n;wire [4:0] cnt1;wire [4:0] cnt2;always #10 clk = ~clk;initial beginclk = 1; rst_n =1;#20; rst_n = 0;#40; rst_n = 1; end c uu(.clk(clk),.rst_n(rst_n),.cnt1(cnt1),.cnt2(cnt2));endmodule

(3)仿真

2,第二种

(1)RTL

module c(input clk,input rst_n,// input a,// input b,output cnt1,output cnt2);reg [4:0] cnt1, cnt2;always@(posedge clk or negedge rst_n) beginif(!rst_n) begincnt1 <= 0;cnt2 <= 0;endelse if(cnt2 <= 16) begincnt1 <= cnt1 + 1;cnt2 <= cnt1; endelse begincnt1 <= 0;cnt2 <= 0;end endendmodule

(2)TB

module tb_c;reg clk;reg rst_n;wire [4:0] cnt1;wire [4:0] cnt2;always #10 clk = ~clk;initial beginclk = 1; rst_n =1;#20; rst_n = 0;#40; rst_n = 1; end c uu(.clk(clk),.rst_n(rst_n),.cnt1(cnt1),.cnt2(cnt2));endmodule

(3)仿真

3,第三种

(1)RTL

module c(input clk,input rst_n,// input a,// input b,output cnt1,output cnt2);reg [4:0] cnt1, cnt2;// 1always@(posedge clk or negedge rst_n) beginif(!rst_n) begincnt1 <= 0;endelse if(cnt1 < 16) begincnt1 <= cnt1 + 1; // 1endelse begincnt1 <= 0;end end// 2always@(posedge clk or negedge rst_n) beginif(!rst_n) begincnt2 <= 0;endelse if(cnt2 < 16) begincnt2 <= cnt1; // 0endelse begincnt2 <= 0;end endendmodule

(2)TB

module tb_c;reg clk;reg rst_n;wire [4:0] cnt1;wire [4:0] cnt2;always #10 clk = ~clk;initial beginclk = 1; rst_n =1;#20; rst_n = 0;#40; rst_n = 1; end c uu(.clk(clk),.rst_n(rst_n),.cnt1(cnt1),.cnt2(cnt2));endmodule

(3)仿真

协助本站SEO优化一下,谢谢!
关键词不能为空
同类推荐
«    2025年12月    »
1234567
891011121314
15161718192021
22232425262728
293031
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
搜索
最新留言
文章归档
网站收藏
友情链接