I'm relatively new to SV. I'm building a testbench in which I want to monitor a signal and take some action if it value changes @ clock posedge.
I’m looking for a compact way to this (I.e. not using a register).
logic [31:0] var_signal
Inizialmente
begin
for(i=0; i<max_cles; i++) begin
@(posedge clk_i);
//check if var_signal changed and do something
end
end
I searched the web and found threads on assertions but it is not what I want to do here.
Any hints?
Best Answer
I know you don't want to use a register but it can be test-bench register. You have to make a copy at the clock edge and compare it against the old value:
There is a caveat: if the signal can also become 'z' or 'x' you should use:
Note that you are in an ideal simulation environment and there is no such moment as
@(posedge..
That moment is infinitely short.In a real digital design the signal has to be stable around the clock edge. The time before the clock edge is called the setup time and the time after is called the hold time.