Move the `LowerLayers` pass after the `LowerXMR` pass. To do this, all
passes at the end of the CHIRRTL to Low FIRRTL pipeline are moved after
`LowerXMR`. This is necessary because the `LowerLayers` pass cannot, at
present, be moved after the passes at the end of the pipeline.
This is done to enable forcing out of layers. By lowering probes to XMRs,
the layers can be lowered trivially to modules/instances and their XMRs
will now (seemingly) magically just work. By doing the loweirng in this
way, it avoids ever having to represent an input probe in the FIRRTL
dialect.
A consequence of this is that there are now simplifying
assumptions (preconditions) that can be made about the `LowerLayers` pass:
1. It will never see a number of probe ops because the `LowerXMR` pass has
a postcondition that all of these are removed.
2. Input and output ports can never be created on modules created from
layer blocks.
While I am generally always in favor of passes being relocatable anywhere
in the pipeline, this is one pass that really does _not_ make sense to be
relocatable. In effect, this pass is part of the lowering from FIRRTL to
HW. There is no point in being able to use it earlier in the pipeline.
That said, it still is tested to work with things which we may one-day
preserve, like `WhenOp`s.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Revert a change introduced in a1b7ca605 that would cause all FIRRTL radix
substitutions to get an automatic `%0` width specifier. While this is a
sane default, this exposed situations where users were relying on this
behavior as an actual interface. I.e., while this was brought up as a
stylistic concern, it was also a functional breakge.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Add a zero width to all format string substitutions when lowering from
FIRRTL to HW/SV. E.g., this will lower `%x` into `%0x`. This is almost
always preferred and avoids the need for (right now) adding width
specifiers to Chisel and FIRRTL. While we would like to do this, we don't
want to do it as passthrough from Chisel where Chisel users write Verilog
format substitutions.
As @jackkoenig and I got to bottom of, there are non-standard format
specifiers that people might want (e.g., `%-` for left justified) that
tools support differently and we would like to figure out how to actually
lower these if they matter.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
updates the FIRRTLToHW conversion to use the PRINTF_FD macro for specifying the file descriptor, allowing the fd to be obtained externally. This change enhances flexibility by enabling the file descriptor to be defined outside the conversion logic.
Signed-off-by: Clo91eaf <Clo91eaf@qq.com>
Migrate all FIRRTL tests to FIRRTL spec version 3.0+. Many tests were
still using "a <= b" and "c is invalid" syntax which was deprecated in
FIRRTL 3.0. This was _not_ deprecated in CIRCT's FIRRTL parser, though.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Align CIRCT with the finalized layer ABI [[1]]. This changes the file
name of the bind file used to enable a layer. This specifically switches
from using underscore as a delimiter to a hyphen. This avoids a problem
where a circuit that contained modules or layers whose names contained
underscores could result in multiple layer enable files that had, by the
ABI, the exact same name.
[1]: https://github.com/chipsalliance/firrtl-spec/pull/233
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Combine two tests of LowerLayers end-to-end behavior into a single
`-split-input-file` test. This is done to add more tests to this file in
the future.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
* Fix paths in tests for windows builds
* Fix patterns that check mlir: backslashes are rendered as double backslashes
* Fix fir emitter for output dirs with backslashes
* Try fixing patterns, again
* FIRLexer: parse escaped backslashes in strings
* Fix more patterns with backslashes
* This time, for an absolute path
* Add getDirectoryAttr helper to HWOutputFileAttr
This helper gets the directory component of an output file name, or returns
nullptr if there is none.
* Output directory control v2
Instead of using an explicit precedence declaration anno to help guide the
assignment of floating modules to output directories, use the directory
hierarchy itself. So if a module is used under directory A/B and A/C, it will
be placed into directory A.
* Support absolute output directories for modules
* Add comment
* Make it so output dir annos only apply to public modules
* Simplify lower layers
* Add ability to configure the output directory of assign-output-dirs
* Update tests
* Address review comments
* Clean up whitespace in test
* clang-format
* Fix up firtool integration test excercising dedup + output dirs
* Address review comments
- Layer module name: move into helper.
- Layer instance name:
- don't put the parent module name in the instance name,
- lowercase each part of the instance name, not just the first word.
- Layer file name: move into helper.
- Captured port names: don't prefix the port name with an underscore.
Updates to LowerLayers to support driving layer-associated probes.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Co-authored-by: Robert Young <rwy0717@gmail.com>