1

Say I have a module foo with a bus input A and a bus output B:

module foo ();
    input [7:0] A;
    output [7:0] B;
endmodule

And foo is instantiated inside top module, and I want something like below(likely to have syntax error):

module top ();
     wire [2:0] bus1;
     wire [2:0] bus2;
     wire [2:0] bus3;
     wire [2:0] bus4;

     foo myfoo (
        .A[7:5](bus1[2:0]),
        .A[4:3](2'b00),
        .A[2:0](bus2[2:0]),
        .B[7:5](bus3[2:0]),
        .B[4:3](),
        .B[2:0](bus4[2:0])
     );
endmodule

What is the syntax correct and most elegant way to do that?

1 Answer 1

2

Use concats, something like the following. Use a temporary signal as a filling for the unconnected slice.

 wire tmp[1:0];

 foo myfoo (
    .A({bus1[2:0], 2'b00, bus2[2:0]),
    .B({bus3[2:0], tmp, bus4[2:0]})
 );
Sign up to request clarification or add additional context in comments.

1 Comment

Is there a way not to use "tmp" to skip the bits in the middle?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.