Search code examples
verilogyosys

Yosys Can't open include file


I am getting a Can't open include file error with yosys. Is there a command line argument to define include directories and/or is there a default directory it is looking for include files in?


Solution

  • Include directories can be passed as arguments to read_verilog:

    read_verilog -Ipath/to/includes rtl/main.v
    read_verilog -Ipath/to/includes rtl/stuff.v
    

    Alternatively the command verilog_defaults can be used to set options for all subsequent calls to read_verilog. For example:

    verilog_defaults -add -Ipath/to/includes
    read_verilog rtl/main.v
    read_verilog rtl/stuff.v
    

    By default, read_verilog is looking for include files in the current working directory and in the directory that contains the verilog file with the `include statement.


    Edit re. the comments:

    I have created the following example:

    $ cat a.v 
    `include "b.v"
    module test;
    initial $display(`message);
    endmodule
    
    $ cat b.v 
    `define message "Hello World!"
    

    I can successfully run this with yosys -p "read_verilog a.v" as well as with yosys a.v. Please edit the question so it includes an example where processing of the include files fails.