本文提供了用Verilog设计4位寄存器的代码,且时钟周期可调,实现异步清零与同步置数,已通过Basys2开发板验证。
代码如下:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40module register #(parameter N=4) ( input wire load, input wire clr, input wire clk, input wire [N-1:0] d, output reg [N-1:0] q ); reg [25:0] m; reg n; initial m=26'b0; initial n=0; always@(posedge clk) //clk频率为50MHz begin if(m==25000000)//通过改变m的条件值可改变n的频率 n=!n; else m<=m+1; if(m==25000000)//通过改变m的条件值可改变n的频率 m<=0; else m<=m+1; end always@(posedge n or posedge clr) begin if(clr==1) q<=0; else if(load==1) q<=d; else q<=q; end endmodule
约束条件如下:
复制代码
1
2
3
4
5
6
7
8
9
10
11NET"d[0]"LOC=P11; NET"d[1]"LOC=L3; NET"d[2]"LOC=K3; NET"d[3]"LOC=B4; NET"clk"LOC=B8; NET"clr"LOC=N3; NET"load"LOC=E2; NET"q[0]"LOC=M5; NET"q[1]"LOC=M11; NET"q[2]"LOC=P7; NET"q[3]"LOC=P6;
欢迎大家指正,觉得有用就赞一个~
最后
以上就是大力凉面最近收集整理的关于Verilog4位寄存器程序(可调周期)的全部内容,更多相关Verilog4位寄存器程序(可调周期)内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复