Prev Problem
Next Problem

37. Tri-State Buffer

Implement a tri-state buffer:

  • When en=1, output y = a.
  • When en=0, output y = z.

Requirements

  • Module: tribuf_prim
  • Inputs: a, en
  • Output: y
  • Use the built-in primitive bufif1 (no assign, no always).
Need Help? Refer to the Quick Guide below

Verilog Primitives or Inbuilt gates & switches

n_input gatesn_output_gatesThree-state gatesPull gatesMOS switchesBidirectional switches
andbufbufif0pulldowncmosrtran
nandnotbufif1pullupnmosrtranif0
nor notif0 pmosrtranif1
or notif1 rcmostran
xnor   rnmostranif0
xor   rpmostranif1

n-input Gates

Basic combinational logic gates with n inputs (2 or more).

  • and, nand, or, nor, xor, xnor
  • Used to build basic Boolean functions directly.
  • Synthesizable (mapped to standard logic cells).

n-output Gates

Single-input, multiple-output primitives.

  • buf β†’ buffer (copies input to output(s)).
  • not β†’ inverter (logical NOT).
  • Multiple outputs can be driven by a single source.

Three-State Gates

Output can be 0, 1, or high-impedance (Z).

  • bufif0, bufif1 β†’ buffer with active-low or active-high enable.
  • notif0, notif1 β†’ inverter with active-low or active-high enable.
  • Commonly used for tri-state buses.

Pull Gates

Provide weak constant logic values.

  • pullup β†’ weak β€˜1’.
  • pulldown β†’ weak β€˜0’.
  • Often used for default bus values or test benches.
  • Synthesizers usually replace them with explicit tie cells.

MOS Switches

Model ideal MOS transistors (digital switch-level).

  • nmos, pmos β†’ NMOS/PMOS transistors.
  • cmos β†’ CMOS transmission gate (p- and n-MOS pair).
  • rnmos, rpmos, rcmos β†’ resistive versions (weak drive strength).
  • Mostly for switch-level simulation, not synthesizable in RTL.

Bidirectional Switches

Transmission gates passing signals both ways.

  • tran β†’ bidirectional wire connection.
  • rtran β†’ resistive bidirectional.
  • tranif0/tranif1 β†’ conditional pass switch, controlled by enable (low/high).
  • rtranif0/rtranif1 β†’ resistive conditional pass switch.
  • Used in switch-level modeling, not synthesizable.

πŸ‘‰ Rule of thumb for RTL design:

  • Use n-input gates and n-output gates sparingly (structural design).
  • Use three-state gates for I/O buffers (top-level ports).
  • Avoid MOS and bidirectional switches in RTL (simulation-only).