I'm confused about the exact meaning of the wait statement.

What happens in this case:

forever begin wait (vif.xn_valid == 1'b1); @(posedge vif.clk); end 

Is the wait statement blocking? Is the

@(posedge vif.clk) 

executed every time inside the loop, regardless of the evaluation of the wait expression?

And in this case:

forever begin wait(vif.cyc_tic == 1'b1) @(posedge vif.clk) #0 fact_log2_samp_t = vif.fact_log2_samp; end 

Is the code after the wait (#0 fact_log2_samp_t = vif.fact_log2_samp; ) executed only if the evaluation of the wait expression is true?

1 Answer

In this case

forever begin wait (vif.xn_valid == 1'b1); @(posedge vif.clk); end 

the loop blocks until the expression (vif.xn_valid == 1'b1) is true, then it blocks until there is a posedge on vif.clk.

A wait statement blocks until the condition is true. If the condition is already true then execution carries on immediately.

In this case:

forever begin wait(vif.cyc_tic == 1'b1) @(posedge vif.clk) #0 fact_log2_samp_t = vif.fact_log2_samp; end 

the loop blocks until the expression (vif.cyc_tic == 1'b1) is true, then it blocks until there is a posedge on vif.clk. It is the same as:

forever begin wait(vif.cyc_tic == 1'b1); @(posedge vif.clk); #0 fact_log2_samp_t = vif.fact_log2_samp; end 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.