VERILOG : 5. Gate-Level Modeling in Verilog

When we think of Verilog, most engineers picture RTL (Register Transfer Level) coding – writing always blocks, designing with if-else or case statements, and abstracting digital logic into behavioral or dataflow descriptions.

However, Verilog also provides a lower-level way of modeling hardware, called Gate-Level Modeling. This is where you describe your circuits directly in terms of logic gates, switches, and transistor-level primitives.

Even though gate-level coding is rarely used in RTL design, it plays a vital role after synthesis in ASIC and FPGA design flows. Let’s break it down.


🔑 Why Gate-Level Modeling Matters

👉 In short: You might not write gate-level Verilog daily, but the EDA tools you use definitely do!


⚡ Categories of Verilog Primitives

Verilog offers three main groups of gate-level primitives:

  1. Gate Primitives
    (AND, OR, XOR, NOT, etc.)

  2. Transmission Gate Primitives
    (Buffers, tri-state buffers, inverters with enable)

  3. Switch Primitives
    (nMOS, pMOS, CMOS, and resistive switches)


1️⃣ Gate Primitives

These represent basic logic gates.

📌 Syntax:

gate_type instance_name (output, input1, input2, ...);
  • First terminal = output

  • Remaining terminals = inputs

Supported Gates

Gate

Description

and

N-input AND gate

nand

N-input NAND gate

or

N-input OR gate

nor

N-input NOR gate

xor

N-input XOR gate

xnor

N-input XNOR gate

not

Inverter


🧩 Example

module gates(); wire out0, out1, out2; reg in1, in2, in3, in4; not U1(out0, in1); // Inverter and U2(out1, in1, in2, in3, in4); // 4-input AND xor U3(out2, in1, in2, in3); // 3-input XOR initial begin $monitor("in1=%b in2=%b in3=%b in4=%b | out0=%b out1=%b out2=%b", in1, in2, in3, in4, out0, out1, out2); in1 = 0; in2 = 0; in3 = 0; in4 = 0; #1 in1 = 1; #1 in2 = 1; #1 in3 = 1; #1 in4 = 1; #1 $finish; end endmodule

✅ This example simulates how inputs propagate through different gates.


2️⃣ Transmission Gate Primitives

Transmission gates are bi-directional elements that pass or block signals depending on enable controls.

📌 Syntax:

primitive_name instance_name (output, input, control);

Common Transmission Gates

Gate

Description

buf

Buffer

not

Inverter

bufif0

Tri-state buffer (active-low enable)

bufif1

Tri-state buffer (active-high enable)

notif0

Tri-state inverter (active-low enable)

notif1

Tri-state inverter (active-high enable)


🧩 Example

module transmission_gates(); reg data_enable_low, in; wire data_bus, out1, out2; bufif0 U1(data_bus, in, data_enable_low); // Tri-state buffer buf U2(out1, in); // Buffer not U3(out2, in); // Inverter initial begin $monitor("@%g in=%b en=%b out1=%b out2=%b bus=%b", $time, in, data_enable_low, out1, out2, data_bus); data_enable_low = 0; in = 0; #4 data_enable_low = 1; #8 $finish; end always #2 in = ~in; endmodule

✅ Observe how the data bus floats (Z) when the tri-state buffer is disabled.


3️⃣ Switch Primitives

Switch primitives model transistor-level behavior. These are used when you need to simulate MOS-level connectivity.

📌 Syntax:

keyword unique_name (drain, source, gate);

Types of Switches

Primitive

Description

nmos/pmos

Uni-directional switches

rnmos/rpmos

Resistive NMOS/PMOS

cmos/rcmos

CMOS switches (2 control signals)

tran/tranif0/tranif1

Bi-directional switches

pullup/pulldown

Weak resistors to force signals


🧩 Example

module switch_primitives(); wire net1, net2, net3; wire net4, net5, net6; tranif0 my_gate1 (net1, net2, net3); // Controlled transistor rtranif1 my_gate2 (net4, net5, net6); // Resistive transistor endmodule

✅ Used in transistor-level modeling and IO pad simulations.


🔢 Logic Values in Verilog

Unlike real hardware, Verilog allows multi-valued logic for accurate simulation.

Value

Meaning

0

Logic low

1

Logic high

z/Z

High impedance (floating)

x/X

Unknown/uninitialized/conflict

This is important for GLS (Gate-Level Simulation) where multiple drivers may compete for a net.


💡 Signal Strengths in Verilog

Not all signals are equal! Verilog allows modeling of signal strengths to resolve conflicts.

Strength

Keyword

7 (Strongest)

supply0, supply1

6

strong0, strong1

5

pull0, pull1

4

large

3

weak0, weak1

2

medium

1

small

0 (Weakest)

highz0, highz1


Example of Strength Resolution

  • A supply0 (strong 0) will override a pull1 (weaker 1).

  • Similarly, supply1 will override a large1.

This ensures realistic conflict resolution in circuits.


🎯 Conclusion

Gate-level modeling in Verilog is not just about drawing AND/OR gates — it is the foundation of the post-synthesis world.

  • RTL engineers design at a higher abstraction.

  • Synthesis tools translate RTL into gate-level netlists.

  • Verification engineers simulate these gate-level Verilog files with back-annotated timing (SDF).

Even if you don’t manually code in gates often, understanding gate-level primitives helps you debug and verify synthesized designs effectively.

👉 So, the next time you run a GLS simulation, remember: you’re working directly with Verilog’s gate-level modeling power. 



Comments

Popular posts from this blog

Fundamental of python : 1.Python Numbers