我試圖將一個結構作爲輸入並在另一個結構中獲取輸出。但是我在模擬過程中遇到了一些問題。以下示例代碼編譯在questasim細,然而模擬提供了以下錯誤:Systemverilog:將結構作爲模塊輸入輸出傳遞時出現模擬錯誤
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
我在想什麼G?。
我知道接口是這裏建議的工作流程,但是使用DPI將模型的輸入傳遞給C例程。 DPI接口支持結構,我不認爲它支持接口。這就是爲什麼我想堅持簡單的結構。
如果結構中的項是'int'而不是'real',它能工作嗎? – Greg
不,它仍然失敗,但它似乎是特定於questasim。在尖銳,它工作正常。 – user3716072