Professional Documents
Culture Documents
Verilog-Part III
initial
begin
procedural_statements
end
Sharif University of Technology 3
Initial Statement
Runs first statement at time 0
Runs once
Until reaching last statement
Suitable for Testbench
Not Synthesizable
RHS is an expression:
Constant values
Nets and Registers
Operators
a = -23;
#10 b = a + d;
i1 = #9 a & b + {w1, w2};
#50 i2 = #10 i1 - (b + a);
Sharif University of Technology 8
Blocking Assignment Simulation
#delay1 lhs = #delay2 rhs;
initial initial
begin begin
a <= b; a = b;
b <= a; b = a;
end end
always <event_control>
begin
procedural_statements
end
Sharif University of Technology 17
Always Statement
Starts at time 0
Runs forever in a loop
When reaching last statement, begins with
the first statement
If event_control specified:
Waits until the event occurs, then starts
execution of first statement
always
begin
{c_out, s} <= a + b + c_in;
m <= n * p;
end
Sharif University of Technology 19
Event Control
@ ( list_of_events )
events:
nets, registers
posedge … -> transition to 1
negedge … -> transition to 0
Sharif University of Technology 20
Example
@ ( w)
@ ( posedge clk )
@ ( negedge a or b )
@ ( a or b[3] or c[3:1] )
@ ( posedge a or b[1] or negedge c[1] )