1

I was trying to generalize a module that had the parameter "int max=15". Is there some way to set an output of the module to the value of the parameter. For example, if the parameter max was set to the value 8, zout would be set to the value of 4'b1000.

    module example
    #(parameter int max=15,
    parameter int bw=$clog2(m))
    (input logic ............,
    .........................,
    output logic [b-1:0] zout);
    assign zout = [value of max];

1 Answer 1

1

You can directly assign it:

module example #(
    parameter int max=15,
    parameter int b=$clog2(max+1)
) (
    output logic [b-1:0] zout
);

    assign zout = max[b-1:0];

endmodule
Sign up to request clarification or add additional context in comments.

3 Comments

My log keeps saying "continuous assignment width mismatch, 4 bits (lhs) versus 32 bits (rhs), source info: assign max=m"
That's because int is 32 bits, but it should still work that way. I updated the answer to match it up, try that.
You are an absolute beaut Justin :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.