Commit Graph

14 Commits

Author SHA1 Message Date
Schuyler Eldridge 5cffc8537b
[firrtl] Move LowerLayers after LowerXMR (#8405)
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>
2025-04-24 11:02:55 -04:00
Schuyler Eldridge bfdda7016c
[LowerToHW] Revert a1b7ca605 '%0d' default
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>
2025-04-01 17:05:49 -04:00
Schuyler Eldridge a1b7ca6051
[LowerToHW] Add '0' to format string width (#8354)
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>
2025-03-27 20:33:12 -04:00
Clo91eaf 7631807add [FIRRTL] Use PRINTF_FD macro instead of 0x80000002 as printf fd
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>
2025-01-07 13:07:26 -08:00
Schuyler Eldridge 38502160a3
[FIRRTL] Migrate tests to connect, invalidate, NFC
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>
2024-10-25 01:03:45 -04:00
Schuyler Eldridge 79af01e0a1
fixup! [FIRRTL] Use new layer ABI 2024-08-29 17:13:42 -04:00
Schuyler Eldridge cff52574a2
[FIRRTL] Use new layer ABI
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>
2024-08-29 17:10:17 -04:00
Schuyler Eldridge fb052d901a
[FIRRTL] Fix comment placement in test, NFC
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-19 19:48:21 -04:00
Schuyler Eldridge a2eec9e062
[FIRRTL] Whitespace test cleanup, NFC
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-08-19 19:19:29 -04:00
Schuyler Eldridge 31ed547abb
[FIRRTL] Combine LowerLayers firtool tests, NFC
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>
2024-08-19 19:19:29 -04:00
Robert Young ae1b8f778e
Fix paths in tests for windows builds (#7185)
* 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
2024-06-15 16:20:03 -04:00
Robert Young 41ebd04f88
[FIRRTL] Output directory control for layers and modules (#6971)
* 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
2024-06-14 14:51:28 -04:00
Robert Young f5831fa0f9
[FIRRTL][LowerLayers] Clean up names of artifacts generated by layers (#6733)
- 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.
2024-02-26 11:03:54 -05:00
Schuyler Eldridge 208058c22a
[FIRRTL] Support probes in LowerLayers (#6554)
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>
2024-02-13 15:49:07 -05:00