我对 Verilog 完全陌生,对于我在大学学习的课程,我必须很快了解它的很多内容。我正在摆弄我的 Altera DE2 板和 quartis2,并了解其细节。
我正在尝试制作一个通过开关打开和关闭的计数器。
到目前为止,计数器根据按键进行计数和重置。
这是我的错误:
Error (10119): Verilog HDL Loop Statement error at my_first_counter_enable.v(19):
loop with non-constant loop condition must terminate within 250 iterations
我知道我被要求提供一个循环变量,但即使这样做我也会收到错误。
module my_first_counter_enable(SW,CLOCK_50,LEDR,KEY);
input CLOCK_50;
input [17:0] SW;
input KEY;
output [17:0] LEDR;
reg [32:0] count;
wire reset_n;
wire enable;
assign reset_n = KEY;
assign enable = SW[0];
assign LEDR = count[27:24];
always@ (posedge CLOCK_50 or negedge reset_n) begin
while(enable) begin
if(!reset_n)
count = 0;
else
count = count + 1;
end
end
endmodule
我希望有人能指出我循环中的错误并允许我继续。
我认为你不想使用while
在那里循环。怎么样:
always@ (posedge CLOCK_50 or negedge reset_n) begin
if(!reset_n)
count <= 0;
else if (enable)
count <= count + 1;
end
我还添加了非阻塞作业<=
,更适合同步逻辑。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)