我正在尝试做一个简单的断言来检查两个值是否相等。当我为同一个变量分配两个不同的值时,有人可以解释一下行为吗
logic src_sig ;
logic dest_sig;
logic alt_sig;
assign a = src_sig;
assign a = alt_sig;
assign b = dest_sig;
我的断言顺序是:
sequence check_seq(X,Y);
(X == Y);
endsequence
我的初始块是:
initial begin
#100 @ (posedge clk) begin
src_sig <= 1;
dest_sig <=1;
alt_sig <= 0;
end
#10 @ (posedge clk) begin
src_sig <=1;
dest_sig <=0;
alt_sig <= 0;
end
#10 @ (posedge clk) begin
src_sig <= 0;
dest_sig <= 0;
alt_sig <= 1;
end
#10 @ (posedge clk) begin
src_sig <= 0;
dest_sig <= 1;
alt_sig <= 1;
end
#30 $finish;
end
我期望第二个分配将覆盖第一个分配,或者它将分配给两者src_sig
和alt_sig
。因此,它应该分别显示 2 次或 4 次违规。但我得到以下结果(3 次违规)。
"testbench.sv", 31: test.check_assert: started at 103ns failed at 103ns
Offending '(a == b)'
"testbench.sv", 31: test.check_assert: started at 113ns failed at 113ns
Offending '(a == b)'
"testbench.sv", 31: test.check_assert: started at 133ns failed at 133ns
Offending '(a == b)'
请解释这里发生了什么?
编辑:: 完整代码
module test_gcc();
logic clk=0;
logic src_sig,dest_sig,alt_sig;
assign a = src_sig;
assign a = alt_sig;
assign b = dest_sig;
initial begin
clk = 0;
forever #1 clk=~clk;
end
sequence check_seq(X,Y);
(X == Y);
endsequence
property check_connection(M,N);
@(posedge clk)
($rose(M)||$rose(N)||$fell(M)||$fell(N)) |-> check_seq(M,N);
endproperty
check_assert : assert property (check_connection(a,b));
initial begin
#100 @ (posedge clk) begin
src_sig <= 1;
dest_sig <=1;
alt_sig <= 0;
end
#10 @ (posedge clk) begin
src_sig <=1;
dest_sig <=0;
alt_sig <= 0;
end
#10 @ (posedge clk) begin
src_sig <= 0;
dest_sig <= 0;
alt_sig <= 1;
end
#10 @ (posedge clk) begin
src_sig <= 0;
dest_sig <= 1;
alt_sig <= 1;
end
#30 $finish;
end
endmodule