1

Is there a command for Yosys, which creates a dependency file equivalent to the gcc option -MMD? (This option outputs a small Makefile fragment, which lists all files included by the compilation unit. See Using g++ with -MMD in makefile to automatically generate dependencies)

Background: I try to build a Makefile, which synthesizes a verilog project using Yosys. The project uses a single top verilog file, from which other verilog dependencies are included. To do that I use the following make rule, which works very well:

$(HARDWARE_BLIF_FILES): $(SUITE_OBJ_DIR)/%.blif : $(SUITE_SUPPORT_HARDWARE_DIR)/%.v
    $(HARDWARE_YOSYS) -q -p 'read_verilog -I/path/to/hwlib $<' -p 'synth_ice40 -blif $@'

Since I don't want to mention the other verilog files in the Makefile explicitly, I would like to use a dependency file. This would allow to detect changes applied to any of the dependency files and trigger a recompilation.


Thanks to the new yosys -E option added by Clifford, I could change the Makefile rule above as follows:

-include $(HARDWARE_BLIF_DEP_FILES)

$(HARDWARE_BLIF_FILES): $(SUITE_OBJ_DIR)/%.blif : $(SUITE_SUPPORT_HARDWARE_DIR)/%.v
    $(HARDWARE_YOSYS) -q -E $(SUITE_OBJ_DIR)/$*.v.d -p 'read_verilog -I/path/to/hwlib $<' -p 'synth_ice40 -blif $@'

Now, the blif file is generated, whenever one of the implicitly referenced Verilog files changes.

Alexander
  • 1,068
  • 6
  • 22
  • Hi Alexander, I'm looking into implementing this in my Makefile. Is your project publicly available on Github, could you share the link? I'm trying to generate the .v.d file from a "top.v" . Do I need to explicitely add `include macros in each module.v file so that yosys -E can detect them? – Alexandre Dumont May 09 '20 at 12:03

1 Answers1

3

A feature like this has now been added to Yosys git head (a96c775). Simply add -E <depsfile> to your yosys call to generate a dependencies file.

CliffordVienna
  • 7,995
  • 1
  • 37
  • 57
  • 1
    Hi Claire, when I run yosys -E top.v.d top.v, the generated file starts with ":" followed by the name of all explicitely included modules (.v/.vh...). SHouldn't there be something on the left hand side of the ":" ? On the LHS should be the target, right? – Alexandre Dumont May 09 '20 at 16:19