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

Packed Array: Two-Channel Bus

SystemVerilog Arrays

A 2D packed array holding two 8-bit channels, with per-channel and per-bit access

Open in IDE
testbench.sv
module tb;
  bit [1:0][7:0] channel_data;   // 2 channels, 8 bits each

  initial begin
    channel_data = 16'hA53C;

    for (int i = 0; i < $size(channel_data); i++) begin
      $display("channel_data[%0d] = %b (0x%0h)", i, channel_data[i], channel_data[i]);
    end

    $display("channel_data[0] bit 3 = %b", channel_data[0][3]);
  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.