这是我用来提出问题的一个简单模块:
module counter #(
parameter LIMIT = 15
)( input clk,
input rstn,
output reg[7:0] out);
always @ (posedge clk) begin
if (! rstn)
out <= 0;
else
if (out >= LIMIT)
out <= 0;
else
out <= out + 1;
end
endmodule
如果 LIMIT
超出 0 到 63 的范围,则编译/构建/模拟过程必须 all
失败。正确的方法是什么?我有 VHDL 背景,但写这个没用:
a_check_lfsr_size_others: assert (LIMIT >= 1 && LIMIT <= 64)
else
$fatal("LIMIT exceeded range of 1 to 64");
我收到此错误:
Reserved word "property" or "#0" missing after "assert". Simple immediate assertions are illegal outside the procedural code.
细化系统任务。
如果LIMIT
为 65,则会产生详细时间错误:
module counter #(
parameter LIMIT = 15
)( input clk,
input rstn,
output reg[7:0] out);
always @ (posedge clk) begin
if (! rstn)
out <= 0;
else
if (out >= LIMIT)
out <= 0;
else
out <= out + 1;
end
if ((LIMIT < 1) || (LIMIT > 64)) $fatal;
endmodule
module tb;
counter i0 ();
counter #(.LIMIT(33)) i1 ();
counter #(.LIMIT(65)) i2 ();
endmodule
输出示例:
Error-[FEST] $fatal elaboration system task
path: tb.i2