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

Signal Concatenation

Verilog Data Types

Example of wire concatenation using 'assign' statement

Open in IDE
design.v
  module des (input [1:0] 	a,
              input [2:0] 	b,
              output [4:0]	out1,
              output [3:0] 	out2            
             );

    assign out1 = {a, b};
    assign out2 = {a[1], 2'b01, b[2]};

  endmodule  
testbench.v
module tb;
  reg [1:0] a;
  reg [2:0] b;
  wire [4:0] out1;
  wire [3:0] out2;
  
  des u0 (a, b, out1, out2);
  
  initial begin
    a <= 0;
    b <= 0;
    
    $monitor("[%0t] a=%b b=%b, out1=%b out2=%b", $time, a, b, out1, out2);
    
    #10 a <= 3;
    #5  b <= 5;
    #10 a <= 2;
    #5  b <= 1;
    
    #10 $finish;
  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.