Ready-to-run snippets

Code Examples

Ready-to-run Verilog, SystemVerilog, and UVM examples. Click any to open it live in the IDE.

← All examples

Strength: Modeling an Open-Drain Bus

Verilog Examples

Runnable example from the Verilog Strength tutorial (Modeling an Open-Drain Bus)

Open in IDE
testbench.v
module tb;
  reg  d1, d2;
  wire bus;

  assign (highz1, strong0) bus = d1;   // Open-drain driver 1
  assign (highz1, strong0) bus = d2;   // Open-drain driver 2
  pullup (bus);                        // Pull-up resistor

  initial begin
    $monitor ("[%0t] d1=%b d2=%b bus=%b (%v)", $time, d1, d2, bus, bus);
    d1 = 1; d2 = 1;
    #10 d1 = 0;
    #10 d1 = 1; d2 = 0;
    #10 d2 = 1;
  end
endmodule
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.