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

Interview Questions Set 2: What is verilog $random ?

Verilog Examples

Runnable example from the Verilog Interview Questions Set 2 tutorial (What is verilog $random ?)

Open in IDE
testbench.v
module testbench;
  reg [7:0] data;
  integer i;
              
  initial begin
    $display("Random numbers: ");
              
    // Generate 32b random numbers ten times and display 
    for (i = 0; i < 10; i = i + 1) begin
      $display("%d: %b", i, $random);
    end
  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.