circt icon indicating copy to clipboard operation
circt copied to clipboard

firtool 1.131.0 generates references to non-existant layer files

Open oharboe opened this issue 3 months ago • 7 comments

When generating a single verilog file, the layer files are included, even if they are not generated, leading to errors.

  1. untar no-include.tar.gz
  2. Run firtool '--format=mlir' --disable-all-randomization -strip-debug-info '-disable-layers=Verification' '-disable-layers=Verification.Assert' '-disable-layers=Verification.Assume' '-disable-layers=Verification.Cover' counter_fir.fir -o counter.sv

Now we see that references to non-existant files are generated:

$ grep include counter.sv
  `include "layers-TestCounter-Verification.sv"
  `include "layers-TestCounter-Verification.sv"
  `include "layers-TestCounter-Verification.sv"
$ find . | grep layers
$

oharboe avatar Sep 25 '25 14:09 oharboe

@jackkoenig @seldridge Just FYI, I discovered this when hacking and slashing support for Chisel + sby in bazel. https://github.com/The-OpenROAD-Project/bazel-orfs/pull/387

@ollef and @TLoubiere made an effort to get LLVM CIRCT to work with sby without having to write the FormalCounter.v manually, but so far sby has proven to be a few Verilog features short of working.

oharboe avatar Sep 25 '25 14:09 oharboe

Disabling those layers should cause those includes to not be there. Could you may want to re-upload your test: that .fir is a symlink to a .cache directory in your home area.

seldridge avatar Sep 25 '25 15:09 seldridge

Disabling those layers should cause those includes to not be there. Could you may want to re-upload your test: that .fir is a symlink to a .cache directory in your home area.

Fixed.

oharboe avatar Sep 25 '25 17:09 oharboe

Okay, so I see two things:

  1. That input file is actually .mlir and it's all the way at SV dialect. At that point, things like --disable-layers will not have any effect. The layers are not stripped because this needs to be FIRRTL (or FIRRTL dialect).
  2. If you run with --split-verilog -o <output-directory> you shouldn't have any issues and this is the advised way to run. The problem is that in single-file output (what you get without --split-verilog), then the file separations are just comments. Hence, the output in single file mode is not correct and can't be fed to another tool. It's more for debugging, testing, and example use.

seldridge avatar Sep 25 '25 17:09 seldridge

I see....

Trying again:

  1. untar with what I believe to be prior to SV dialect(though I don't speak mlir well enough to know) split.tar.gz
  2. firtool '--format=mlir' --split-verilog --disable-all-randomization -strip-debug-info '-disable-layers=Verification' '-disable-layers=Verification.Assert' '-disable-layers=Verification.Assume' '-disable-layers=Verification.Cover' counter_fir.fir -o split

The layer files are still generated. For bazel reasons, it is useful to have a single file(bazel wants to know beforehand which files are generated, so a folder of files isn't great), so I want to cat *.sv into a single file, so having these files I don't need or want is causing constipation.

$ grep -r include split/*
split/verification/assert/layers-TestCounter-Verification-Assert.sv:  `include "layers-TestCounter-Verification.sv"
split/verification/assume/layers-TestCounter-Verification-Assume.sv:  `include "layers-TestCounter-Verification.sv"
split/verification/cover/layers-TestCounter-Verification-Cover.sv:  `include "layers-TestCounter-Verification.sv"
$ find split/
split/
split/TestCounter.sv
split/FormalCounter.v
split/Counter.sv
split/filelist.f
split/verification
split/verification/assert
split/verification/assert/layers-TestCounter-Verification-Assert.sv
split/verification/assume
split/verification/assume/layers-TestCounter-Verification-Assume.sv
split/verification/layers-TestCounter-Verification.sv
split/verification/cover
split/verification/cover/layers-TestCounter-Verification-Cover.sv

oharboe avatar Sep 25 '25 18:09 oharboe

Is there a Chisel argument not to generate these layers rather than firtool argument?

oharboe avatar Sep 25 '25 18:09 oharboe

Ah, I wasn't holding it right...

What confuses me is that firtool is now being invoked several times and I have to include these options every time?

From .fir to .mlir, from .mlir to .sv...

https://github.com/The-OpenROAD-Project/bazel-orfs/pull/395

oharboe avatar Sep 25 '25 18:09 oharboe