I am trying to pass one structure as an input and get the output in another structure. However I am having some issues during simulation. The following example code compiles fine in questasim, however the simulation gives the following error:
Connection type 'core_tb_sv_unit.struct ' is incompatible with 'core_sv_unit.struct ' for port (struct_in): Struct/union types must match.
MyStruct.sv
`ifndef _DEF_
`define _DEF_
typedef struct {
real instr;
real addr;
} instr_packet_s;
`endif
core.sv
`timescale 1ns / 1ns
`include "MyStruct.sv"
module core(
input instr_packet_s struct_in,
output instr_packet_s struct_out
);
initial begin
$display("Initial");
end
endmodule
core_tb.sv
`include "MyStruct.sv"
module core_tb();
instr_packet_s struct_in_tb,struct_out_tb;
assign struct_in_tb.instr=2;
assign struct_in_tb.addr=3;
core u_core(
.struct_in(struct_in_tb),
.struct_out(struct_out_tb)
);
endmodule
What am I missing?.
I know interfaces are the suggested workflow here,but the input to the model will be passed to a C routine using DPI. The DPI interface supports structures, I do not think it supports interfaces. This is why I would like to stick to simple structures.