如何在 icarus verilog 中包含文件?

Har*_*pta 2 verilog mips cpu-architecture icarus iverilog

我知道基本的`include“filename.v”命令。但是,我试图包含另一个文件夹中的模块。现在,该模块还包括同一文件夹中存在的其他模块。但是,当我尝试在最顶层运行该模块时,出现错误。

C:\Users\Dell\Desktop\MIPS>iverilog mips.v
./IF/stage_if.v:2: Include file instruction_memory_if.v not found
No top level modules, and no -s option.
Run Code Online (Sandbox Code Playgroud)

在这里,我试图制作一个 MIPS 处理器,它包含在文件“mips.v”中。该文件的第一条语句是“`include“IF/stage_if.v”。并且,在 IF 文件夹中,存在许多文件,我已将它们包含在 stage_if.v 中,其中一个是“instruction_memory_if.v”。下面是目录层次图。

-IF
  instruction_memory_if.v
  stage_if.v
+ID
+EX
+MEM
+WB
mips.v
Run Code Online (Sandbox Code Playgroud)

Cha*_*ton 5

您需要iverilog使用标志来告诉要查看的位置-I

top.v

`include "foo.v"

program top;
    initial begin
        foo();
    end
endprogram
Run Code Online (Sandbox Code Playgroud)

foo/foo.v

task foo;
    $display("This was printed in the foo module");
endtask
Run Code Online (Sandbox Code Playgroud)

可以使用以下命令运行:

iverilog -g2012 top.v -I foo/
vvp a.out

>>> This was printed in the foo module
Run Code Online (Sandbox Code Playgroud)