I'm trying to understand how typedef and enum work in SystemVerilog and, in particular, if it's possible to use a "custom" data type in a module's port declaration.
So far, I've been able to create a custom data type in a package, here it is:
typedef enum logic[2:0] {
add_conf = 3'b000,
sub_conf = 3'b001,
and_conf = 3'b010,
or_conf = 3'b011,
xor_conf = 3'b100,
sll_conf = 3'b101,
srl_conf = 3'b110,
sra_conf = 3'b111
} iexu_conf
Now, I'd like to define an input port of type iexu_conf
in a module, like this:
module iexu_decoder
(
input iexu_conf conf,
output logic add_ctrl,
output logic[1:0] logic_ctrl,
output logic[1:0] shifter_ctrl,
output logic[1:0] outmux_ctrl
);
Is this possible? If so, is the syntax correct? I'm currently getting problems with Modelsim
** Error: (vlog-13069) iexu_decoder.sv(5): near "conf": syntax error, unexpected IDENTIFIER, expecting ')'.
but I can't tell if it's because of some stupid mistake or if it's due to a more serious conceptual error.