在我的模塊中,我有一個名爲Cmd的輸出端口,它是'reg'類型的。調試幫助:enum reg與reg端口不兼容
module ddesign (clk, rst, addr, data, Cmd);
input clk;
input rst;
input [31:0] addr;
input [31:0] data;
...
output reg [2:0] Cmd; // this is the signal concerned
...
always @(posedge clk) begin
if (rst == 0) begin
Cmd = IDLE; // I wanted to drive enum values
end
else begin
Cmd = WR;
...
end
end
endmodule;
我也使用typedef定義了信號Cmd,如下所示在另一個文件中。
typedef enum logic [2:0] {
IDLE,
WR,
RD,
RDX,
RDL,
WRN,
WRC,
BROADCAST
} Cmd_t;
接口的定義如下
Interface intf (input clk);
Cmd_t Cmd;
...
endinterface
在我實例化的模塊頂部文件,
module top;
...
intf vif(clk); // interface instantiation
ddesign dut(
...
.Cmd(vif.Cmd), // the module port and interface are connected like this, but here is the incompatibility problem
...
);
endmodule
,所以我得到了以下錯誤:
**錯誤:(vsim-3906)F:/folder1/project1/DV/top/top.sv(79):連接類型'file_list_svh_unit.enum reg [2:0]'is incomp用於端口(Cmd)的'reg [2:0]'。
如何解決此錯誤,前提是我可以在設計模塊中驅動Cmd信號的枚舉類型值?
您可以使用構建[MCVE](http://stackoverflow.com/help/mcve)來完成。我在[EDA遊樂場](https://www.edaplayground.com/x/6Fz9)上這樣做,發現沒有錯誤。我也在Questa上試過了,發現沒有錯誤。 –