fyr*_*r91 2 cpu verilog modelsim
我正在使用 ModelSim 来模拟 Verilog。我创建了一个define.v 文件,并希望将此define.v 包含在多个其他verilog 模块中。
Define.v的部分内容如下:
// defines
`define RSIZE 4
`define ISIZE 16
`define DSIZE 16
`define ASIZE 16
`define NREG 4
`define ADD 4'b0000
`define SUB 4'b0001
`define AND 4'b0010
`define OR 4'b0011
`define SLL 4'b0100
`define SRL 4'b0101
`define SRA 4'b0110
`define RL 4'b0111
`define LW 4'b1000
`define SW 4'b1001
`define LHB 4'b1010
`define LLB 4'b1011
`define BR 4'b1100
`define JAL 4'b1101
`define JR 4'b1110
`define EXEC 4'b1111
...
...
Run Code Online (Sandbox Code Playgroud)
我已将此文件包含在多个其他模块中,例如: alu.v
//ALU.v
`include "define.v"
module alu(
input [`DSIZE-1:0] a, b, //operands
input [3:0] op, //operation code
input [3:0] imm, //immediate
output reg [`DSIZE-1:0] out, //output
output reg [2:0] flag //flag for N, V, Z in sequence
);
...
...
Run Code Online (Sandbox Code Playgroud)
但是编译时好像没有包含define文件,错误如下:
** Error: //psf/Home/Desktop/Projects/project1/alu.v(3):
Cannot open `include file "define.v".
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
如果不在当前目录中,您需要指示 Modelsim在搜索包含的文件时define.v
使用包含的目录。define.v
执行此操作的选项是+incdir+path
.
因此,例如,如果您有以下文件结构:
project/src/alu.v
project/include/define.v
Run Code Online (Sandbox Code Playgroud)
如果您从 运行project
,那么您需要将其+incdir+include
作为参数包含到 Modelsim 中。
作为旁注,如果您多次包含同一文件,则应使用“包含防护”以避免有关重新定义宏的警告。
`ifndef DEFINE_V
`define DEFINE_V
`define RSIZE 4
`define ISIZE 16
....
`endif
Run Code Online (Sandbox Code Playgroud)