Parameterizing a data type in SystemVerilog/Verilog

OP (Company: Harvey Mudd College) #4422044
Rate this post
useful
not useful
Hi all,

I have a data structure that I'm building, and I'm wondering if it's 
possible to parameterize the datatype to be unsigned or signed.


Here's an example of what I'd imagine (although it's not valid syntax)
1
module myModule
2
# (parameter UNSIGNED = 1)
3
    generate
4
        if (UNSIGNED == 1)
5
            input logic [7:0] my_bus;
6
        else
7
            input logic signed [7:0] my_bus;
8
    endgenerate)
9

10
// data structure guts here
11

12

13
endmodule

Is something like this possible?

Thanks for taking a look!

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now