Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations36
  • Combinational Design25
    • Combinational Timing Overview
    • Muxes, Decoders and Encoders
    • Arithmetic Blocks
    • Comparators and Shifters
    • Tri-State and Shared Buses
      • Tri-State Basics
      • Bus Holders, Floating Nets and Wired Logic
      • When Not to Use Internal Tri-State in ASIC RTL
    • Latch Inference
    • Arithmetic Datapaths
  • Sequential Design27
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
  • Senior & Interview76
  • Glossary and Notation
Loading lesson

‹Tri-State and Shared Buses
  1. Topics
  2. RTL Design
  3. Combinational Design
  4. Tri-State and Shared Buses
  5. Tri-State Basics

Part 2 · Combinational · Intermediate

Tri-State Basics

One wire, many drivers: the four net values, the one-driver rule, and the pad driver.

On this page

    Why this matters

    Two drivers that disagree on a shared net give x in simulation and a short circuit in silicon. A bus is safe only if exactly one driver is enabled at a time.

    After this lesson you can: use the four net values, write a tri-state driver and a bidirectional pin, and read the resolution table.

    Four values on one net

    Shared buses place many devices on one set of wires, so each device must be able to let go. That release is high impedance, and it gives a wire four values.

    Value

    Meaning

    0

    Driven low.

    1

    Driven high.

    z

    Released: nobody drives.

    x

    Unknown: usually a clash or unset.

    Watch the bottom row, bus. On a phone, swipe the diagram sideways to see the clash.

    e1/d1 are driver 1 enable/data and e2/d2 are driver 2 enable/data.

    • Slot 1: nobody drives, so bus = z.

    • Slot 2: driver 1 is enabled with 0, so bus = 0.

    • Slot 3: driver 1 drives 1, so bus = 1.

    • Slot 4: driver 2 adds 0 while driver 1 drives 1, so bus = x.

    • Slot 5: both released, so bus = z.

    Only one driver at a time

    Only one driver at a time. If two drivers disagree, the net becomes x. In real hardware that is a short circuit.

    This table is the whole story.

    Driver 1

    Driver 2

    Net value

    Why

    0

    z

    0

    Only driver 1 is active.

    1

    z

    1

    Only driver 1 is active.

    z

    z

    z

    Nobody drives the net.

    1

    1

    1

    Both agree.

    0

    1

    x

    Contention: conflicting drivers.

    The 1-plus-1 row holds because both drivers agree.

    Check yourself Driver 1 drives 0 and driver 2 drives 1, both enabled. What is the net value?

    x. A 0-versus-1 clash is contention.

    Check yourself Both drivers are released. What is the net value?

    z. Nobody drives the net, so its value is undefined until something drives or pulls it.

    Check yourself Driver 1 drives 1 while driver 2 is released. What is the net value?

    1. Only driver 1 is active, so its value wins.

    The driver and the pin

    tri_driver.v
    1
    2
    3
    4
    5
    6
    module tri_driver (
      input  wire d, oe,
      output wire y
    );
      assign y = oe ? d : 1'bz;      // drive d when enabled, otherwise release the net
    endmodule
    • Drives d when oe is 1.

    • Releases the net (z, disconnected) when oe is 0, so others can drive.

    • Net type is wire or tri: only nets allow several drivers.

    One pin, two jobs

    One pad drives and receives through the same net:

    bidir_pin.v
    1
    2
    3
    4
    5
    6
    7
    8
    9
    module bidir_pin (
      inout  wire pad,
      input  wire drive_en,
      input  wire drive_val,
      output wire sampled
    );
      assign pad     = drive_en ? drive_val : 1'bz;    // drive the pad when enabled
      assign sampled = pad;                            // always read the pad level
    endmodule

    Do and avoid

    Do

    Avoid

    Sample sampled while drive_en is 0 for normal receive (the pin is an input)

    Assuming sampled while drive_en is 1 always equals drive_val: it reads the resolved pad, so it matches only when uncontended and shows x where another driver disagrees

    Enable one driver at a time

    Enabling two drivers that can disagree sends the net to x

    Interview

    Likely question: “What happens when two drivers drive the same net with different values?”

    • Simulation reads x.

    • Silicon sees a short circuit with extra current and noise.

    • Avoid it with one-hot enables: only one enable on at a time.

    Warning

    Keep oe glitch-free. A glitch while another device drives briefly shorts the bus, spiking current and noise.

    Check yourself Two drivers both output 1 and a third drives 0. What is the net value?

    x. Any 0-versus-1 clash gives x, no matter how many drivers agree.

    Testbench

    This testbench checks every row of the resolution table.

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    module tb_tristate;
      reg d1, e1, d2, e2;
      tri bus;
      assign bus = e1 ? d1 : 1'bz;
      assign bus = e2 ? d2 : 1'bz;
      int errors = 0;
    
      initial begin
        e1 = 1; d1 = 0; e2 = 1; d2 = 1; #1;
        if (bus !== 1'bx) errors++;            // 0 versus 1: contention
        e1 = 1; d1 = 1; e2 = 1; d2 = 1; #1;
        if (bus !== 1'b1) errors++;            // both drive 1: agree
        e1 = 0; e2 = 0; #1;
        if (bus !== 1'bz) errors++;            // nobody drives
        e1 = 1; d1 = 0; e2 = 0; #1;
        if (bus !== 1'b0) errors++;            // one driver
        e1 = 1; d1 = 1; e2 = 0; #1;
        if (bus !== 1'b1) errors++;            // sole driver high: the remaining table row
        if (errors == 0) $display("PASS: tri-state resolution table confirmed");
        else $display("FAIL: tri-state resolution errors=%0d", errors);
        $finish;
      end
    endmodule

    Remember

    • A net has four values: 0, 1, z (nobody drives) and x (clash or unknown).

    • Two drivers that disagree on a bit give x; two that agree give that value.

    • Keep the output enable glitch-free, because a glitch while another device drives is a brief short.

    Rule of thumb: enable one driver at a time, and make the enables one-hot.

    Keep going

    • Interview: run a mock interview on this topic

    Related topics

    • Bus holders and floating nets

    Previous

    51 / 350

    Next: Bus Holders, Floating Nets and Wired Logic

    Up next

    Up nextBus Holders, Floating Nets and Wired Logic

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • When Not to Use Internal Tri-State in ASIC RTL
    clke1d1e2d2bus
    Two drivers sharing one net