Verilog_Guy
Newbie level 3
- Joined
- Nov 18, 2014
- Messages
- 4
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 62
Trying to write reusable System Verilog code using structures (and unions) using parameters. The code needs to be synthesizable. I've having trouble passing parameterized structures through ports. Here's what I'd like to do:
module my_top_module
parameter FOO = 8;
typedef struct packed {
my_struct_t my_struct;
assign my_struct.bar = 8'h01;
my_core_module #(
endmodule
// ----------------------------
module my_core_module #(
typedef struct packed {
However, this code gives me the following error:
Error-[SV-UIOT] Undefined interface or type
../rtl/my_top_module.sv, 27
my_struct_t, "my_struct"
The definition for the forward-referenced interface 'my_struct_t' is missing
or 'my_struct_t' is the name of an undefined user type.
Check to see if the interface definition file/work library is missing or the
definition of the user type is missing.
After doing extensive experiments, I've found that the only way I've been able to make this work is if I switch back to using the old non-ANSI port declarations, as shown below. However, it seems wrong to me that I should have to do this.
What am I missing? Is this a shortcoming of the languange? If so, it seems that structures are broken (for all practical purposes) in System Verilog as they exist today....
Thanks!
module my_top_module
parameter FOO = 8;
typedef struct packed {
logic [FOO-1:0] bar;
} my_struct_t;my_struct_t my_struct;
assign my_struct.bar = 8'h01;
my_core_module #(
.FOO(FOO)
) my_core_module (.my_struct(my_struct)
);endmodule
// ----------------------------
module my_core_module #(
parameter FOO = 4
) (input my_struct_t my_struct
);typedef struct packed {
logic [FOO-1:0] bar;
} my_struct_t;
However, this code gives me the following error:
Error-[SV-UIOT] Undefined interface or type
../rtl/my_top_module.sv, 27
my_struct_t, "my_struct"
The definition for the forward-referenced interface 'my_struct_t' is missing
or 'my_struct_t' is the name of an undefined user type.
Check to see if the interface definition file/work library is missing or the
definition of the user type is missing.
After doing extensive experiments, I've found that the only way I've been able to make this work is if I switch back to using the old non-ANSI port declarations, as shown below. However, it seems wrong to me that I should have to do this.
module my_core_module #(
) (
parameter FOO = 4;
typedef struct packed {
input my_struct_t my_struct;
) (
my_struct
);parameter FOO = 4;
typedef struct packed {
logic [FOO-1:0] bar;
} my_struct_t;input my_struct_t my_struct;
What am I missing? Is this a shortcoming of the languange? If so, it seems that structures are broken (for all practical purposes) in System Verilog as they exist today....
Thanks!