如何解决在 SystemVerilog 中声明接口时出现未声明的类型错误
我正在尝试使用以下接口的接口,该接口在 <Project Directory>/OtterMCU.srcs/sources_1/new/BranchPredictor.sv
中声明如下:
import Types::*; // a package that provides the func3_t enum
interface BranchPredictor(
input clk,input reset
);
logic id_is_branch;
func3_t id_branch_type;
logic [31:0] id_pc;
logic ex_branched;
func3_t ex_branch_type;
logic [31:0] ex_pc;
logic should_branch;
modport Predictor(
input id_is_branch,input id_branch_type,input id_pc,input ex_branched,input ex_branch_type,input ex_pc,output should_branch
);
modport ID(
output id_is_branch,output id_branch_type,output id_pc,input should_branch
);
modport EX(
output ex_branched,output ex_branch_type,output ex_pc
);
endinterface
当我在另一个模块中使用它时,Vivado 出现 undeclared type
错误:
[Synth 8-3892] undeclared type 'BranchPredictor' ["<redacted>/OtterMCU.srcs/sources_1/new/OTTER_MCU.sv":78]
以下是它在模块中的使用方式(文件名 <Project Directory>/OtterMCU.srcs/sources_1/new/OTTER_MCU.sv
):
module OTTER_MCU(/*...*/);
// ...
BranchPredictor ibpred(); // this is the offending line
// ...
IDStage id_stage(
.predictor(ibpred.ID),// this module uses one of the modports
// ...
);
// ...
endmodule
我做错了什么?
解决方法
我想出了解决办法。更改编译顺序以将接口放在最顶部解决了这个问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。