Parameterizing a data type in SystemVerilog/Verilog

OP (Company: Harvey Mudd College) #4422044
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

A question of your own? This thread is over 10 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.