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

Part Selects

Verilog Vectors

Example of a part-select on vector

Open in IDE
Related tutorial:
design.v
module des;
  reg [31:0] data;
  integer i;
  
  initial begin
    data = 32'hFACE_CAFE;
    for (i = 0; i < 4; i = i+1) begin
      $display ("data[8*%0d +: 8] = 0x%0h", i, data[8*i +: 8]);
    end
  
    $display ("data[7:0] = 0x%0h", data[7:0]);
    $display ("data[15:8] = 0x%0h", data[15:8]);
    $display ("data[23:16] = 0x%0h", data[23:16]);
    $display ("data[31:24] = 0x%0h", data[31:24]);
  end
  
endmodule
testbench.v
// Enter testbench code
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.