Verilog循环条件
我对verilog是一个全新的人,我必须很快了解它,因为我正在大学里学习一门课程。所以我在玩我的altera DE2板和quartis2,学习细节 我想做一个计数器,它是通过开关打开和关闭的。 到目前为止,计数器计数和重置基于按键 这是我的错误:Verilog循环条件,verilog,Verilog,我对verilog是一个全新的人,我必须很快了解它,因为我正在大学里学习一门课程。所以我在玩我的altera DE2板和quartis2,学习细节 我想做一个计数器,它是通过开关打开和关闭的。 到目前为止,计数器计数和重置基于按键 这是我的错误: Error (10119): Verilog HDL Loop Statement error at my_first_counter_enable.v(19): loop with non-constant loop condition mus
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
我希望有人能指出我循环中的错误,并允许我继续
谢谢大家! 标题
错误(10119):Verilog HDL Loop语句错误:具有非常量循环条件的循环必须在迭代中终止
描述
当合成在Verilog HDL中的循环中迭代超过合成循环限制时,Quartus®II软件中可能会出现此错误。此限制防止合成可能运行到无限循环中。默认情况下,此循环限制设置为250次迭代
解决方法/修复方法
要解决此错误,可以使用Quartus II设置文件(.qsf)中的VERILOG_NON_CONSTANT_loop_limit选项设置循环限制。例如:
set_global_assignment-name VERILOG_NON_CONSTANT_LOOP_LIMIT 300我认为你不想在那里使用
循环。那么:
always@ (posedge CLOCK_50 or negedge reset_n) begin
if(!reset_n)
count <= 0;
else if (enable)
count <= count + 1;
end
始终@(posedge时钟50或negedge重置)开始
如果(!重置)
计数每当时钟有正边缘时,块就会触发。如果你有一个,而循环在硬件中并不意味着什么,它仍然需要一个时钟来驱动触发器
而回路可用于测试,以驱动刺激
integer x;
initial begin
x = 0;
while (x<1000) begin
data_in = 2**x ; //or stimulus read from file etc ...
x=x+1;
end
end
NB:就个人而言,我也会在每件事上加上begin-end,以避免以后再加上额外的行,并想知道为什么它们总是或永远不会被执行,特别是在对语言不熟悉的时候。它还具有使缩进看起来更好的附加好处
always@ (posedge CLOCK_50 or negedge reset_n) begin
if(!reset_n) begin
count <= 'b0;
end
else if (enable) begin
count <= count + 1;
end
end
始终@(posedge时钟50或negedge重置)开始
如果(!reset_n)开始
计数我也看到了,但是当我把它放到我的代码中时,我得到了一个关于这行代码的错误。因为它表明你需要把它放到设置文件中,而不是你的代码中。你的代码中没有错误,你只是超出了限制。因此,您需要增加限制,或者采取一种类似@toolic answer:-)的方法哦!好吧,我想我错过了,明白了。我将在我的设置文件中查看该设置
always@ (posedge CLOCK_50 or negedge reset_n) begin
if(!reset_n) begin
count <= 'b0;
end
else if (enable) begin
count <= count + 1;
end
end