I have a module that can be configured with two parameters. Depending on the values of these parameters, I either need to pad or truncate an output vector when assigning it to an input vector. For example:
module my_mod(vector_in,
vector_out);
parameter IN_BITS = 10;
parameter OUT_BITS = 8;
// or
// parameter IN_BITS = 8;
// parameter OUT_BITS = 10;
input [IN_BITS-1:0] vector_in;
output[OUT_BITS-1:0] vector_out;
// assign vector_out to vector_in
// when OUT_BITS > IN_BITS => pad MSB's with zeors
// when OUT_BITS < IN_BITS => truncate LSB's of in
// else just assign
endmodule
What is the best way to do this?