需要用 dist 解决之前吗?

Is solve before needed with dist?

IEEE Std 1800-2017 中的第 18.5.10 节有以下示例来说明为什么我们需要 solve before:

rand bit s;
rand bit [31:0] d;
constraint c { s -> d == 0; }

下面2个选项还需要solvebefore吗?

A.

rand bit s;
rand bit [31:0] d;
constraint c1 { d < 1000; }
constraint c2 { if ( s == 1 ) d == 0; }

B.

rand bit s;
rand bit [31:0] d;
constraint c1 { d < 1000;
                if ( s == 1 ) d == 0;
              }
constraint c2 { s dist { 0 :/ 95, 1 :/ 5 }; }               

天真地阅读以上所有内容会假设有 50%(选项 B 为 5%)的机会选择 s 作为 1,而 IEEE 标准说您需要一个 solve s before d 约束第一个获得50%机会的例子。

A 和 B 是否需要 solve before 才能获得 s 为 1 的预期 50%/5% 机会?

选项 A 会给你 0.0999% 的机会 s 在没有 solve s before d 结构的情况下为 1。 (s 在 1001 个解决方案中只有 1 个是 1'b1)。

选项 B 会给你 5% 的机会 s 是 1,无论是否有 solve s before d 结构。 dist 约束意味着在解决方案 space 中选择值的顺序,因此添加 solve before 构造将是多余的。