2

I know the basic `include "filename.v" command. But, I am trying to include a module which is in another folder. Now, that module further includes other modules present in the same folder. But, when I try to run the module on the most top-level, I am getting an error.

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.

Here, I am trying to make a MIPS processor, which is contained in the file "mips.v". The first statement of this file is "`include "IF/stage_if.v". And, in the IF folder, there are numerous files present which I have included in stage_if.v, one of which is "instruction_memory_if.v". Below is the directory level diagram.

-IF
  instruction_memory_if.v
  stage_if.v
+ID
+EX
+MEM
+WB
mips.v
Harshit Gupta
  • 51
  • 1
  • 5
  • Usually you want to create a file that lists all RTL files (and paths) used in your design and pass this file to the tool. A quick google search revealed that this is also the case for this tool. – RaZ Nov 23 '17 at 10:48
  • have you tried '-h' qualifier for help? if you did, you should have seen `-I includedir` this, which you could yous on the command line to specify the directories where to search for include files. – Serge Nov 23 '17 at 13:21

1 Answers1

5

You need to tell iverilog where to look using the -I flag.

In top.v:

`include "foo.v"

program top;
    initial begin
        foo();
    end
endprogram

In foo/foo.v:

task foo;
    $display("This was printed in the foo module");
endtask

Which can be run using the commands:

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

>>> This was printed in the foo module
Charles Clayton
  • 17,005
  • 11
  • 87
  • 120