Skip to main content

3. The four modeling levels

Verilog lets you describe the same circuit at four different levels of abstraction. Each level trades control for conciseness.

#LevelVerilog constructWhat you describeSynthesizable
1Switch levelnmos, pmos, cmosIndividual transistorsNo — simulation only
2Gate leveland, or, nor, not, nand, xor, …Logic gatesYes
3DataflowassignBoolean equations on netsYes
4Behavioralalways, case, if, forAlgorithmic behaviourYes (with care)

3.1 The running example​

The same 2-input NAND gate is written at all four levels throughout this course, so you can compare them directly.

aby = NOT (a AND b)
001
011
101
110
  • Switch level: two PMOS in parallel (pull-up), two NMOS in series (pull-down).
  • Gate level: one nand primitive.
  • Dataflow: assign y = ~(a & b);
  • Behavioral: an always @(*) block with an if/case.

3.2 How the levels relate​

Switch level ← transistors
↓ (abstraction)
Gate level ← gates
↓
Dataflow ← equations
↓
Behavioral ← algorithms and description
  • Moving down the list gives you more explicit control over the final hardware.
  • Moving up gives you more compact, more portable, more readable code.
  • Modern RTL is written almost entirely at the dataflow and behavioral levels; gate level is used for small timing-critical structures, and switch level mostly for and library characterisation.

Hint — how to choose a level. As a designer moves up from switch level toward behavioral, control over the final hardware decreases and productivity increases. To keep the most control over the implementation, start from the lowest synthesizable level that makes sense for the block — gate level for small, timing-critical structures, dataflow for simple equations, behavioral for anything sequential or complex. Switch level sits below gate level, but because it is not synthesizable, it is used for understanding and analysis, not as a starting point for implementation. If a design cannot be expressed sensibly at the current level, move up one level and reconsider.

3.3 Design vs. verification: one table​

Design (levels 1–4)Verification (lesson 8)
PurposeDescribe the circuitCheck the circuit
Constructsassign, always, primitivesinitial, #delay, $display, $dumpfile
SynthesizableYesNo
Ends up in siliconYesNever
Examplebehavioral_dff.vtb_dff.v

3.4 Which level should you use?​

SituationLevel
Learning how transistors make a gateSwitch
Writing a standard-cell library modelSwitch / gate
Small combinational logic, direct equationsDataflow
Anything sequential, FSMs, arithmetic, memoriesBehavioral
Checking that any of the above worksVerification

A practical rule: write combinational logic as dataflow, sequential logic as behavioral.

Next: Switch-level modeling →