【问题标题】:SystemVerilog dist constraintSystemVerilog 分布约束
【发布时间】:2022-01-23 01:17:00
【问题描述】:

我在如何设置 dist 约束方面遗漏了一些东西。我试图在两个范围 [0:31] 和 [32:65535] 之间获得相等的权重。我设置了一个简单的测试:

class data;
  rand bit [15:0] field1;
  constraint c_f1 { field1 dist {[0:31] := 1, [32:65535] := 1};}
endclass

module testbench;
   
  initial begin
    data test_h;
    test_h = new();
    
    repeat(10) begin
        assert(test_h.randomize());
        $display("field1 = %h", test_h.field1);
    end
  end

endmodule

但是,我看到的大多数值 > 32。我在这里误解了什么?

【问题讨论】:

标签: constraints system-verilog


【解决方案1】:

使用:/ 运算符而不是:= 运算符。变化:

  constraint c_f1 { field1 dist {[0:31] := 1, [32:65535] := 1};}

到:

  constraint c_f1 { field1 dist {[0:31] :/ 1, [32:65535] :/ 1};}

请参阅 IEEE Std 1800-2017,第 18.5.4 节分发

:/ 操作符将指定的权重分配给项目,或者,如果 item 是一个范围,将范围作为一个整体。如果有n个值 range,每个值的权重为 range_weight / n 。

这给出了 0-31 之间的更多值:

field1 = 0012
field1 = 001f
field1 = 000f
field1 = a138
field1 = 0018
field1 = 001c
field1 = 9d48
field1 = 0009
field1 = 85bf
field1 = f930

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-12
    • 2022-11-02
    相关资源
    最近更新 更多