Verilog 13: Procedural Block Control in Verilog
Understanding Procedural Block Control in Verilog
In Verilog, procedural blocks form the foundation for describing behavioral models of hardware. These blocks define how a circuit reacts to inputs over time — enabling both combinational and sequential logic modeling.
Procedural blocks become active at simulation time zero and execute when triggered by events or signal changes defined in their sensitivity list.
Let’s explore how procedural control works, along with key examples and best coding practices.
🔹 What Are Procedural Blocks?
Procedural blocks are code regions that describe behavior rather than structure. They are defined using either of the two keywords:
These blocks can be controlled using event controls such as level or edge triggers.
🧩 Example 1 – D Latch Using always Block
Let’s begin with a basic example: the D Latch, one of the simplest sequential elements.
🧠 Concept:
Whenever d or enable changes, this block executes. The latch captures the input (d) only when enable is high.
📂 File: d_latch_always.v
⚙️ Combinational Logic with Procedural Blocks
To create combinational logic, your procedural block must be sensitive to all input signals that affect the output.
If using conditional statements (if), remember to include an else clause. Missing it can accidentally create a latch.
💡 Example 2 – 1-Bit Full Adder Using always
🧠 Note:
This model performs bitwise addition using procedural combinational logic.
📂 File: full_adder_always.v
🚫 Avoiding Unintentional Latches
Unintended latches occur when certain conditions are not covered in procedural logic.
You can prevent this in two ways:
✅ Method 1 – Use else Conditions
✅ Method 2 – Initialize Outputs Inside the Block
🧠 Tip:
Initializing inside the block ensures outputs get defined in every condition, preventing synthesis issues.
⏱️ Sequential Logic Using Procedural Coding
Sequential logic relies on clock edges and optionally reset/preset signals.
Always use non-blocking assignments (<=) for sequential circuits to avoid timing errors.
💡 Example 3 – D Flip-Flop with Asynchronous Reset
🧠 Explanation:
-
The flip-flop responds instantly to a reset (
posedge reset). -
On every clock edge, it captures the input
d.
⚠️ Example 4 – Incorrect Coding (Multiple Clocks)
Avoid using two clocks in a single sequential always block.
This is invalid for synthesis even if it works in simulation.
🧠 Why Wrong:
Real hardware can have only one active clock edge per flip-flop. This is simulation-only behavior.
🧱 Procedural Block Concurrency
In Verilog, all procedural blocks start together at time 0 and execute concurrently.
Multiple always or initial blocks in the same module run in parallel, just like independent hardware components.
💡 Example 5 – Parallel Blocks in a Module
🧠 Concept:
Both always blocks execute concurrently, like real digital hardware.
🧩 Example 6 – Named Blocks and Disable Statement
You can name a block to control its execution using the disable statement.
This is useful for early exit from loops or condition-based termination.
🧠 Explanation:
This example identifies the first ‘1’ bit from LSB and stops the loop using disable.
🚀 Key Takeaways
|
Concept |
Description |
|
Behavioral
modeling using always and initial |
|
|
@() defines
when a block executes |
|
|
Sensitive to
all inputs; no latches |
|
|
Uses clock
edges and non-blocking assignments |
|
|
All blocks
start and run in parallel |
|
|
Enable
control and termination of loops |
🏁 Conclusion
Procedural blocks are the core of behavioral modeling in Verilog HDL.
They bring hardware to life — enabling logic that reacts to inputs, clocks, and resets just like real-world circuits.
Whether designing a simple D latch or a complex synchronous flip-flop, mastering procedural control is the key to writing accurate, synthesizable Verilog code.

Comments
Post a Comment