Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between 'wait' and '@' statement

Tags:

verilog

The following set of codes do the same thing.Is there any difference between them ?If not , why is wait (clk) not generally used?

always @(posedge clk)
begin

end


always wait(clk)
begin 

end
like image 499
user2128682 Avatar asked Oct 23 '25 19:10

user2128682


1 Answers

@(posedge clk) is edge sensitive , hence it is used to model synchronous circuits.While, wait(clk) is level sensitive.Since most circuits are designed to be synchronous @(posedge clk) is predominantly used

wait (expression)

The "expression" is evaluated, if false, then execution is suspended until the expression becomes true. If the expression is true when the statement is reached, then the wait has no effect, and execution proceeds to the controlled statement.

@(posedge clk) - is an edge event.
posedge:0,x,z->1    negedge:1,x,z->0

Edge events are useful for modelling clocked logic elements, like flip-flops. They are also useful for synchronizing activity in a model based on a common clock. Example, in the following always block,it enters the always block on the negative edge of clock.

always @(negedge clock)
    x = f(y);       
like image 77
chitranna Avatar answered Oct 26 '25 21:10

chitranna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!