VERILOG 9 :Abstraction Levels and Procedural Blocks

Verilog HDL (Hardware Description Language) is widely used for modeling digital systems. It allows designers to describe circuits at different levels of abstraction, making it easier to go from high-level behavior to gate-level implementation. In this guide, we’ll explore these abstraction levels, procedural blocks, and important Verilog constructs with practical examples.


Abstraction Levels in Verilog

Verilog supports multiple modeling styles depending on the level of detail required:

  1. Behavioral Modeling

    • Describes the functionality of the design rather than its structure.

    • Suitable for quick prototyping.

    • Example: writing algorithms for counters, FSMs, or arithmetic operations.

  2. RTL (Register Transfer Level) Modeling

  3. Structural Modeling


Procedural Blocks in Verilog

Verilog allows behavioral code to be written inside procedural blocks.
There are two main types:


Example: initial Block

module initial_example(); reg clk, reset, enable, data; initial begin clk = 0; reset = 0; enable = 0; data = 0; end endmodule

Here, all signals are initialized only once at the start of simulation.


Example: always Block

module always_example(); reg clk, reset, enable, q_in, data; always @(posedge clk) if (reset) data <= 0; else if (enable) data <= q_in; endmodule

This block executes on every rising edge of clk, updating the register accordingly.


Procedural Assignments in Verilog

  • Allowed on: reg, integer, time, real types.

  • Not allowed on: wire (nets).

  • Assignments can be:

    • Blocking (=) – executed sequentially.

    • Nonblocking (<=) – executed in parallel.


Blocking vs Nonblocking Example

module blocking_nonblocking(); reg a, b; initial begin a = 0; // blocking b <= 1; // nonblocking end endmodule

👉 Tip:


Statement Groups: begin-end and fork-join

When multiple statements are needed inside a block, Verilog provides grouping constructs:


Example: Sequential Block

initial begin #1 clk = 0; #10 reset = 0; #5 enable = 0; #3 data = 0; end

Statements run one after another → total delay accumulates.


Example: Parallel Block

initial fork #1 clk = 0; #10 reset = 0; #5 enable = 0; #3 data = 0; join

Here, assignments happen in parallel, each after its specified delay.


Continuous Assignments with assign-deassign and force-release

Apart from normal procedural assignments, Verilog also supports temporary continuous assignments:

  1. assign and deassign

    • Used to override procedural assignments temporarily.

    • Can only be applied to registers (reg).

  2. force and release

    • Stronger than assign/deassign.

    • Can be applied to both reg and wire.

    • Useful for debugging or injecting errors during simulation.


Example: Force and Release

always @(preset) if (preset) force U.q = 1; // force assignment else release U.q; // release control

This allows direct control over a signal, bypassing its normal behavior, until released.


Key Takeaways

  • Verilog supports three abstraction levels: Behavioral, RTL, and Structural.

  • initial block runs once, always block runs continuously.

  • Use blocking (=) for sequential execution, nonblocking (<=) for parallel updates.

  • begin-end → sequential grouping; fork-join → parallel grouping.

  • assign/deassign and force/release allow overriding signals for special conditions.





Comments

Popular posts from this blog

Fundamental of python : 1.Python Numbers