14.1. Behavioral Blocks (initial & always)
​
Verilog provides two fundamental procedural blocks for behavioral modeling: the initial block and the always block. These blocks contain procedural statements that execute sequentially.
​
14.1.1. The initial Block
​
Syntax and Characteristics
​
The initial block executes only once at the beginning of simulation at time t = 0.
Verilog
Key Properties
​
-
Executes exactly ONCE at time t = 0
​
-
Typically, NOT synthesizable (some exceptions for memory initialization)
​
-
Primarily used in testbenches
​
-
Can contain timing controls (#delay, @event, wait)
​
-
Multiple initial blocks execute concurrently
​
Common Applications
Verilog
14.1.2. The always Block
​
Syntax and Characteristics
​
The always block executes repeatedly throughout the simulation. It forms the core of RTL design and is synthesizable when written correctly.
Verilog
Sensitivity List
​
The sensitivity list determines when the always block executes. It can contain:
​
-
Edge-sensitive events: posedge clk, negedge reset
​
-
Level-sensitive signals: @(a or b or c) or @(*)
​
-
Mixed: @(posedge clk or negedge reset)
.png)
Types of always Blocks
​
A. Combinational Logic Always Block
Verilog
Key Points:
​
-
Use blocking assignments (=)
​
-
All inputs must be in sensitivity list or use @(*)
​
-
All outputs must be assigned in all execution paths
​
-
Synthesizes to combinational gates
​
B. Sequential Logic Always Block
Verilog
Key Points:
​
-
Use non-blocking assignments (<=)
​
-
Sensitivity list contains only clock and reset edges
​
-
Synthesizes to flip-flops/registers
​
-
Asynchronous reset: negedge rst_n in sensitivity list
​
-
Synchronous reset: no reset in sensitivity list
​
C. Latched Logic (Unintended - Usually a Bug)
Verilog
2.3 Comparison: initial vs always
.png)
