日常记录(18)solve…before约束
solve a before data约束的存在,随机变量a会先被赋予随机值,a为1或0的概率为1/2,接下来再为data随机变量赋随机值,其概率取决于a的值,最终保持组合的值实现均匀分布。
class transaction; rand bit a; rand bit[1:0] data; constraint c1{ a -> data==3'h3; //条件约束 solve a before data;} //在给出data随机值之前先给出a的随机值 endclass module gen_data; initial begin transaction tr=new() ; for(int i=0; i<10; i++ ) begin tr.randomize() ; $display("a= %0d, data= %0d",tr.a, tr.data) ; end end endmodule
https://blog.csdn.net/weixin_46022434/article/details/107757344
Le vent se lève! . . . il faut tenter de vivre!
Le vent se lève! . . . il faut tenter de vivre!