验证模块参数值

问题描述 投票:0回答:1

这是我用来提出问题的一个简单模块:

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.
    
system-verilog
1个回答
1
投票
请参阅 IEEE Std 1800-2017,第 20.11 节

细化系统任务

如果

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
    
© www.soinside.com 2019 - 2024. All rights reserved.