bit clk , a , b ;
int e , f ;
always #5 clk = !clk ;
always @( posedge clk ) e <= e + 1 ; // Assignment in NBA Region
function int func (int i);
f = e; // Module scope variable assigned within the subroutine
$display("T:%2t Within func , i is %0d , f is %0d",$time,i,f );
return f;
endfunction
sequence s1 ;
int v , w ;
@(posedge clk)
( 1 , v = e , $display("T:%2t v == %0d",$time,v) ) ##1 ( b[->1] , w = func(v) , $display("T:%2t Sequence s1 Completes with v == %0d , w == %0d , f == %0d",$time,v,w,f ) ) ;
endsequence
property p1 ;
@(posedge clk) $rose(a) |=> s1;
endproperty
assert property(p1) $display("Assertion passed at T:%2t",$time) ;
initial begin
#24 ; a = 1 ;
#10 ; a = 0 ; // T: 34
#40 ; b = 1 ; // T: 74
#10 ; b = 0 ; // T: 84
#2 ; $finish();
end
Although ‘f’ is assigned 8 ( in observed region ), why do we observe it’s value as 0 via the $display which executes in reactive region i.e after the assignment to ‘f’ ?
bit clk , a , b ;
always #5 clk = !clk;
int val = 2;
always @(posedge clk) b <= b + 1; // Updated in NBA region
task automatic delay( int count );
$display("Task called at T:%0t with i/p arg == %0d",$time,count);
if( count > 0 ) begin
repeat(count) @(posedge clk);
$display("Task completes at T:%0t",$time);
end
// Immediate assertion
im: assert ( b == 2) $display("Immediate assertion passes"); // Question about this
else $display("Immediate assertion fails");
endtask
property p1;
@(posedge clk) $rose(a) |-> (1, delay(val));
endproperty
assert property(p1);
initial begin
#04 ; a = 1 ;
#25 ; $finish();
end
Although ‘delay’ executes in reactive region, due to repeat(count) @(posedge clk);
would it re-enter active region ( via loopback from reactive ) due to the event control ?
On unblocking the next procedural statement is the immediate assertion.
So would the immediate assertion execute in reactive region ( since ‘delay’ executes in reactive region ) OR would it execute in active region itself ( since event control executes in active region ) ?
Does this mean that the immediate assertion executes in reactive region ( same as the subroutine ) ?