Module 8: RTL Coding for Quality & Synthesis · 8.4 Common RTL Bugs & Debugging

Multi-Driver Conflicts

Connecting multiple drivers to a single wire net is valid Verilog syntax. Simulators apply documented net resolution rules to determine the resulting logic state. However, conflicting drivers cause intermittent functional errors and physical hardware damage. This article examines how simulators resolve multi-driver nets and how to eliminate bus contention.

Simulator Resolution Rules

When multiple drivers connect to a wire net, the simulator evaluates the combination of all driving signals. If all active drivers output the same logic value, the net assumes that value. If two drivers output opposing logic values (1 and 0), the simulator resolves the net to x. The x state indicates conflicting drivers with an indeterminate voltage level.

// Bidirectional tri-state bus: intentional multi-driver architecture
assign bus_data = (mode == 1) ? data_a : 8'bz;
assign bus_data = (mode == 2) ? data_b : 8'bz;

In the tri-state example above, non-active drivers output a high-impedance 8'bz state. When one driver outputs data and all other drivers output z, the driven value controls the net. Tri-state buses operate correctly only when control logic prevents overlapping active states. In contrast, accidental multi-driver nets drive active values simultaneously:

// Defective code: both continuous assignments drive active values simultaneously
assign status = error_flag ? 8'hFF : 8'h00;
assign status = busy_flag  ? 8'h01 : 8'h00;

If error_flag and busy_flag assert at the same time, both assignments drive different logic values. The simulator resolves the net to x. This defect remains undetected in testbenches where both flags never assert concurrently.

Common RTL Defect Sources

Multi-driver conflicts typically originate from three design oversights:

  1. Duplicate continuous assignments: Designers inadvertently write multiple assign statements targeting the same wire identifier. This frequently occurs when copying code or merging branches.

  2. Shared top-level interconnects: Two submodules drive a shared top-level output net without an intermediate multiplexer. This defect occurs when integrating external intellectual property (IP) blocks.

  3. Multiple sequential procedural blocks: Writing to the same reg variable from multiple always blocks creates race conditions. Synthesis tools reject multi-driver registers with explicit compiler errors.

Two drivers on one wire: safe when one is always z, contention when both drive
Figure 1: When two drivers on a wire are safe and when they conflict

Detection and Resolution Strategies

Synthesis compilers and static linting tools generate explicit warnings when a net has multiple drivers. Always treat multi-driver warnings as critical design defects. Verify whether any operating condition permits multiple drivers to assert simultaneously. If concurrent activation is possible, restructure the RTL code.

Internal integrated circuits should avoid internal tri-state buses. Modern ASIC and FPGA architectures use multiplexers instead of on-chip high-impedance states. Replace tri-state logic with explicit combinational multiplexers:

// Robust structural multiplexing: guaranteed single driver
assign bus_data = (mode == 1) ? data_a :
                  (mode == 2) ? data_b : 8'h00;

A multiplexer guarantees that exactly one driver controls the net under all conditions. This structure eliminates simulation-synthesis mismatches and prevents electrical short circuits.

Practice Exercise

An SPI controller and a UART controller both drive a shared status_led net with continuous assignments. Each module asserts status_led when transmitting data. Explain the operational risk and provide a robust architectural solution.

Solution

If the SPI and UART controllers transmit simultaneously, both assign statements drive the net. If one controller drives logic 1 while the other drives logic 0, electrical contention occurs. In simulation, the net resolves to x. On physical hardware, this condition causes excessive current draw and indeterminate voltage levels.

To resolve this defect, implement explicit combinational arbitration logic. Combine the active signals using a logical OR gate:

assign status_led = spi_active | uart_active;

This single continuous assignment eliminates multi-driver contention.

Verilog permits multiple drivers on wire nets and resolves opposing values to x. Accidental multi-driver nets remain hidden until conflicting conditions execute concurrently. Designers prevent bus contention by using structural multiplexers and combinational logic instead of internal tri-state wires. The next article provides a comprehensive methodology for systematic RTL debugging.

← Reset Domain Problems A Systematic Debugging Method →