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

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

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.