Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect different port width

Suppose my module has a 8-bit input and 8-bit output

module MyModule (input logic [7:0] in, output logic [7:0] out);
    ...
endmodule : MyModule

If I want to connect a 1-bit input in and leave the other bits as zero, the following works:

MyModule (.in({7'b0, a}), .out(b))

How can I do the same if I want a 1-bit output, ignoring the other bits? Something like this

MyModule (.in(a), .out({7'b0, b}))

vcs says its invalid, and connecting b directly gives a warning. I'd ideally like a solution that doesn't throw warnings.

Here's what I've thought of:

  • Use .out(b) and use b[0] for bit
  • Create unused logic variable unused and use .out({unused, b}) which does work
  • Use assign statment (I'd like to avoid this)

Any solution better than these?

like image 339
qwr Avatar asked Dec 06 '25 18:12

qwr


1 Answers

You could use the streaming operator:

MyModule M (.in(a), .out({<<{b}}));

But I think your first idea is the most straightforward.

like image 69
dave_59 Avatar answered Dec 09 '25 07:12

dave_59



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!