Commit Graph

1222 Commits

Author SHA1 Message Date
John Demme bd3a6499f7
[MSFT] Wire cleanup pass (#2410)
Another step towards #2365. This pass 'bubbles up' wires which are merely pass throughs in a given module. It then 'sinks down' wires which are looped back in the instantiation. Together with the entity movement piece, this effectively moves the wires as well. Does not handle wire manipulation operations, which also need to be moved/copied.
2022-01-04 15:12:43 -08:00
John Demme 117262aa68
[MSFT] Use MSFTModuleOp for design partitions (#2415)
The design partitioning pass used to build HWModuleOps. The new wire
cleanup passes, however, will be operating on the design partitions so
the modifying extensions will come in handy.
2022-01-03 16:14:30 -08:00
Hideto Ueno d80618a17e
[SV] Allow verbatim to have non-integer type (#2408)
In aggregate preservation mode, GrandCentral may create VerbatimExpr ops
with aggregate types. This commit allows verbatim to have non-integer types 
such as a struct type or array type.
2022-01-02 12:40:16 +09:00
Schuyler Eldridge 91f308a32b
[FIRRTL] Whitespace cleanup, NFC
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-12-31 00:21:41 -05:00
Schuyler Eldridge 75fb99fa4e
[Support] Simplify Namespace.h Storage, NFC
Change Namespace.h to use a single, unified StringMap instead of a
StringSet and a StringMap.  This removes storage of duplicate keys in
two equivalent datstructures.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-12-30 14:43:55 -05:00
Hideto Ueno 2eea30198f
[FIRRTL] Add multibit_mux op and lowerings (#2392)
This commit adds new operation `multibit_mux` to make 
subaccess lowering more efficient. Subaccess ops are 
currently lowered into mux chains but in HW/Comb dialect
they are pulled back to `array_create` + `array_get`. 
`multibit_mux` will be directly lowered into `array_create`
+ `array_get` at LowerToHW.

This commit containts parser/printer, folder, LowerTypes 
and LowerToHW change. `multibit_mux` operations are
created only at subaccess lowering in LowerTypes.

This speeds up entire process after LowerTypes 5%~10%
for large circuits.
2021-12-28 16:54:41 +09:00
Mike Urbach 13948d32d8 [MSFT] Remove SwitchInstanceAttr and RootedInstancePathAttr.
These attributes and their use cases are now replaced by
hw::GlobalRefOp and hw::InnerRefAttr, respectively.
2021-12-27 13:52:14 -07:00
Mike Urbach a2a058b70e [MSFT] Refactor placement export to use hw::GlobalRefs.
This refactors ExportQuartusTcl to use the hw::GlobalRefs and arrays
of hw::InnerRefAttrs directly. This greatly simplifies the
implementation, and removes the need for SwitchInstanceAttr. That
attribute will be fully removed in a follow up.
2021-12-27 13:51:57 -07:00
Mike Urbach 6d7e0e9118 [HW] Add Python bindings for GlobalRefAttr.
This adds the necessary CAPI boilerplate and a basic Python type for
holding GlobalRefAttr.
2021-12-27 11:32:05 -07:00
Mike Urbach 9f7a01a865 [HW] Add Python bindings for InnerRefAttr.
This adds the necessary CAPI boilerplate and a basic Python type for
holding InnerRefAttr.
2021-12-27 11:32:05 -07:00
Julian Oppermann c5c8f79152
[Scheduling] Prepare simplex implementation for the modulo scheduler. (#2396) 2021-12-27 19:29:24 +01:00
Prithayan Barua 521f7a3273
[HW] Add a new op HW::GlobalRef, to replace the FIRRTL::NonLocalAnchor (#2312)
Add a new operation `GlobalRef` to `HW` dialect, that will eventually replace 
`FIRRTL::NonLocalAnchor`. 
`GlobalRef` can be used to identify a unique instance path of an operation globally.

This is part of the plan to move the `firrtl.nla` to `HW` dialect.
2021-12-27 07:03:26 -08:00
Hideto Ueno 4e20f1ad18
[Namespace] Improve newName trials to skip trivially used names (#2391)
This commit modifies the creation of new names to skip already used
ones. This fixes regression of LowerToHW caused by many creations of
RANDOM values.
2021-12-26 06:46:34 +09:00
Andrew Lenharth bd8043702c
[FIRRTL] handle testbench dir annotation in combination with dut annotation (#2382)
Get files in the correct directory.
2021-12-25 13:26:53 -05:00
Mike Urbach 7bdd9da49d [StaticLogic] Add a helper to get a pipeline stage number.
The stage number is computed as its index in the stages block. This is
useful to passes that may want to give a stage a meaningful name.
2021-12-24 10:42:40 -07:00
mikeurbach fba1ab7bfd
[AffineToStaticLogic] Flesh out support for converting to pipelines. (#2387)
This adds the necessary support to lower single affine loops to
pipelines. Broadly, this encompasses lowering affine structures like
if conditions into arithmetic, and building pipeline stages for each
scheduled group.
2021-12-24 10:30:55 -07:00
mikeurbach aa0b03ec6d
[MemoryDependenceAnalysis] Add ability to replace an op. (#2385)
This is useful to transformations that want to be able to reuse the
analysis during progressive lowering. If an affine.load or
affine.store is lowered, this API can be used to maintain any
dependences on the replacement op.
2021-12-23 14:41:31 -07:00
Morten Borup Petersen e5c4eacd1a [Docs] Pass descriptions should be a multiline string
... else, things do not end up formatting correctly in the generated documentation.
2021-12-23 08:48:29 +01:00
Morten Borup Petersen 7dbcd42df8
[Handshake] Move buffer insertion to Handshake transforms (#2381)
Long overdue - buffer insertion is not inherently tied to StandardToHandshake.

- Changed the name from `handshake-insert-buffer` to `handshake-insert-buffers`
- Removed the option of providing multiple buffer strategies at once - I've never seen it used in practice, and there are no guarantees provided for how multiple strategies are supposed to composed if provided at once. I think it's a better option to only allow a single strategy and then, if the user wants to, they can compose strategies manually through subsequent invocations of `handshake-insert-buffers`.
2021-12-23 08:33:51 +01:00
Schuyler Eldridge 85b24de8cb
[Support] Move FIRRTL Namespace to Support, NFC
Move the FIRRTL utility "BaseNamespace" to Support and rename it
"Namespace".  This class is generally useful for any dialect or
conversion which needs to generate names on the fly.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-12-22 21:18:07 -05:00
John Demme 0e5e797edf
[MSFT] Design partition support, part 3 (#2376)
One more step towards #2365. This PR adds the "bubble up" entities pass.
2021-12-22 15:11:32 -08:00
John Demme 87081b9896
[MSFT] Design partition support, part 1 (#2366)
The "design partition" feature supports scenarios wherein the designer needs the RTL output module hierarchy to be different than the logical hierarchy they are designing. With this feature, they just create a design partition then "tag" various entities with it. Upon compilation, CIRCT will refactor the hierarchy to move the tagged entities into the specified target partition. The design partition _must_ be found in the module hierarchy above (or in the same module as) the tagged entities.

Partial progress towards #2365.

- Modeling in CIRCT and PyCDE
- Move entities in the same module as the partition
2021-12-20 17:57:41 -08:00
Julian Oppermann 5bfb9ae3cc
[Scheduling] Define problem to model operator chaining. (#2233)
This commit defines a ChainingProblem, which models the accumulation of physical propagation delays on combinational paths along SSA dependences within a scheduling problem's abstract time steps/cycles.
2021-12-20 21:25:59 +01:00
Morten Borup Petersen 4d3c2080aa
[Handshake] Support source ops in FIRRTL emission (#2362) 2021-12-17 17:57:33 +01:00
Morten Borup Petersen 1e10bea5ee [Handshake] add constant operation verifier 2021-12-17 16:06:37 +01:00
Hideto Ueno 18d66b6af8
[FIRRTL/LowerTypes][FIRTOOL] Preserve aggregate at lowertypes (#2318)
This commit adds `preserve-aggregate` flag to enable experimental
feature to preserve passive aggregate wires/register/connection.
Currently, if preserve-aggregate flag is enabled, we change the
behavior of `peelTypes` function. We don't preserve aggregate if any 
of the following condition holds:

1. They are ports of MemOp (Ports of MemOp must be ground types)
2. They are non-passive types
3. They contain an analog type
4. They are types with zero width.
2021-12-17 07:25:16 +09:00
Hideto Ueno 2cb8bf3817
[SV] Allow constantX/Z to have non-integer types (#2338)
This commit allows constantX/Z op to have non-integer types.
2021-12-15 03:05:28 +09:00
Morten Borup Petersen 2dab46849f
[Handshake] Add new buffering strategy allFIFO (#2339)
This strategy simply combines the cycles and all strategies, using sequential buffers to break cycles, and transparent FIFO buffers on all other channels.
2021-12-14 12:59:11 +01:00
Morten Borup Petersen 073219feeb
[Handshake] Add fork and mux canonicalization patterns (#2334) 2021-12-14 08:38:34 +01:00
Morten Borup Petersen 3b90f8b82a [Handshake] Add fork/sink dematerialization pass 2021-12-13 15:19:54 +01:00
Morten Borup Petersen 66229dde5f [StandardToHandshake] support std.select operations 2021-12-13 12:31:10 +01:00
Hideto Ueno 6c5e0ce771
[HW] Use StringAttr instead of StringRef in FieldInfo, nfc (#2325)
* [HW] Use StringAttr instead of StringRef in FieldInfo, nfc

This commit changes to use use StringAttr instead of StringRef
in FieldInfo to avoid unnecessary copies of field names.
Changes are mainly about parser/printer and CAPI.
This commit also changes Struct/UnionTypeImpl to use ArrayRefParameter
instead of ArrayRefOfSelfAllocationParameter in their tablegen
definition. And this deletes unnecessary allocators too.
2021-12-12 15:52:52 +09:00
Hideto Ueno 2577910657
[FIRRTL/LowerToHW] Support bundle type lowering (#2323)
* [FIRRTL/LowerToHW] Support missing bundle type lowering

This commit makes LowerToHW handle bundle values properly:
(i) bundle registers initialization and (ii) extension of
`getLoweredAndExtendValue` to accept struct/bundle values.
2021-12-12 15:02:40 +09:00
mikeurbach c0eb58266c
[MSFT] Add new PrimitiveType for flip-flop devices. (#2313)
This adds a new FF primitive type in both ODS and the Python
bindings.
2021-12-09 08:08:17 -07:00
Hideto Ueno fb8a80da4a
[SV][ExportVerilog] Add sv.struct_field_inout op (#2306)
This commit adds an new operation `sv.struct_field_inout` to create
inout memory for hw::StructType. Potentially, this will be used to
modify elements of firrtl bundle types.
2021-12-09 23:14:23 +09:00
Andrew Young e05976427c Move CHIRRTL ops and types from the FIRRTL dialect
This is the final giant move of all the files. A new visitor was created
to handle CHIRRTL operations, which can be chained to the FIRRTL ops.
2021-12-08 18:02:15 -08:00
Andrew Young 2786ba5cc6 [FIRRTL] Move dialect definition to its own TD file
This moves the FIRRTL dialect to its own TD file so that it can be
included by the CHIRRTL dialect. This is needed to be able to reference
the FIRRTLTypes.td file from CHIRRTL.td.
2021-12-08 18:02:15 -08:00
Andrew Young 4df7fd6b06 [FIRRTL] Remove CHIRRTL name removing canonicalization
CHIRRTL operations will be long gone by the time we get to the
canonicalization pass, so instead of moving these to the CHIRRTL
dialect, just delete them.
2021-12-08 18:02:15 -08:00
Andrew Young e8a2b2a77c [FIRRTL] Expose printer for nested types
When an aggregate FIRRTL type is printed, we elide the `!firrtl` from
the element type.  This exposes the functionality so it can be shared
with the new CHIRRTL dialect.
2021-12-08 18:02:15 -08:00
Andrew Young 4ad3f85239 Add new CHIRRTL dialect
This dialect is going to contain the CHIRRTL operations and types
currently in the FIRRTL dialect.  This will provide better structuring
in the MLIR types as we don't want CHIRRTL types to be FIRRTL types.
For more information see this issue here:
https://github.com/llvm/circt/pull/2134
2021-12-08 18:02:15 -08:00
Chris Lattner fea28586bf [LLHD] remove the LLHD-specific Verilog printer.
We have one well tested and continuously refined verilog emitter
pass, lets use that instead of duplicating the logic.

This resolves Issue #2282, where it was approved by Martin Erhart.
2021-12-08 14:01:45 -08:00
mikeurbach 54db7ad68d
[Seq] Add innerSym attribute to CompReg and use it on RegOp. (#2303)
Adds an innerSym attribute to CompRegOp, which is passed to the RegOp
during lowering. This allows workflows to reliably give a register a
symbol that can refer to the underlying reg.
2021-12-08 14:56:57 -07:00
Morten Borup Petersen bdec206e00
[Handshake] Add pass to add unique IDs to each operation (#2294)
This commit introduces a new pass `--handshake-add-ids` which will add a unique ID to each operation within a `handshake.func` operation. When present, these IDs are used in both .dot graph printing and FIRRTL instance name generation. Having this provides a deterministic method of tracing back FIRRTL modules to handshake IR or the .dot file.
2021-12-07 08:25:57 +01:00
Schuyler Eldridge b31ce1e65a
[FIRRTL] Add RemoveResets Pass (#2287)
Add a new pass, RemoveResets, that replaces RegResetOps that have
invalidated initialization values with RegOps.  This is part of a series
of patches that are intended to align CIRCT with the Scala FIRRTL
Compiler (SFC) interpretation of invalid.  Previously, CIRCT relies on
canonicalization/folding of invalid values to do this optimization.
This pass enables future canonicalization/folding of invalid values to
zero (as the SFC does) without having to worry about performing this
optimization.

Run the RemoveResets pass as part of firtool after ExpandWhens and
before the first canonicalization.  This enables conversion of
invalidated RegResetOps to RegOps before canonicalization (eventually)
interprets invalid values as zero.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-12-06 16:13:27 -05:00
Prithayan Barua 6f9d5515a5
[SV] Add option to ignore read enable (#2271)
This change adds an option to ignore the memory read enable signal during
 memory lowering to register banks.

According to the FIRRTL spec, the read output is undefined if the read
 enable signal is disabled.
But the `firrtl` implementation ignores the read enable signal on latency 0.

This change ensures that, in `HWMemSimImpl` by default the read output is set
 to `X` if read enable is disabled, but if `ignore-read-enable-mem` option
 is passed, then the read output is set with the data at the read address,
 irrespective of the enable signal.

This provides an option to match the Scala FIRRTL compiler behavior.
2021-12-06 06:29:12 -08:00
Fabian Schuiki c351dc6017
[FIRRTL] Improve canonicalization involving `invalidvalue` (#2251)
This extends the FIRRTL fold and canonicalization patterns to treat
`invalidvalue` as a zero if it is an input to a primary operation. This
is inline with what the Scala implementation of the FIRRTL compiler
does.

Doing this removes quite a few of the special cases where certain ops
are aware of `invalidvalue`s and will fold as if it was a zero. The
addition of the `getConstant`, `isConstantZero`, and
`canonicalizePrimOp` helpers allow for most folders and canonicalizers
to not having to bother with `invalidvalue`s, as these helpers
implicitly map `invalidvalue`s to zero constants.

This also subsumes the work done in #2278 and #2198, which selectively
added handling for `invalidvalue`s to the `PadPrimOp`.

The extension of the folders and canonicalizers now makes all the cases
in `invalid-reg-fail.fir` pass, albeit some only after accepting that
the MLIR implementation folds *additional* cases where the Scala one
might just leave an operation untouched. These are marked with a
`<-- fixed; upstream to Scala FIRRTL impl?` and should probably be
upstreamed as additional canonicalizations on the Scala side as well.
2021-12-04 09:22:04 +01:00
mikeurbach fa29173eaa
[Moore] Specify -attrdefs-dialect when generating attributes, NFC. (#2280)
This flag appears to be needed to support an upcoming revision of
LLVM. Without this, TableGen complains with:

```
error: defs belonging to more than one dialect. Must select one via
'--(attr|type)defs-dialect'
```
2021-12-03 13:14:36 -07:00
Andrew Young eafba50792
[FIRRTL] Add method to insert ports into instance ops (#2275)
This adds a method to insert ports into an instance op.  Since this
increases the number of results of the instance op, it actually has to
be cloned.  It is assumed that the user will manually call
`replaceAllUses` and erase the original instance operation.  This
functionality is useful for any pass that adds ports to modules.
2021-12-03 09:21:54 -08:00
Andrew Young 9e74f40f82
[FIRRTL] Make Annotation hold on to the actual attribute (#2276)
When an annotation targets only part of the thing it is attached to, it
is represented using a `SubAnnotationAttrs`, which contains the field ID
of its target.

The Annotation wrapper class can be only be created from a
DictionaryAttr.  When using a SubAnnotationAttr, it is created from its
internal DictionaryAttr, and the stored field ID is ignored. This makes
it impractical to use `SubAnnotationAttrs` with most of the Annotation
APIs.

This change makes it so the Annotation wrapper holds on to the original
annotation attribute, instead of just a DictionaryAttr.  The annotation
wrapper will check which kind of annotation it has internally when calls
are made.

This change then adds a call to `getFieldID`, which return 0 for regular
annotations, and the field id for `SubAnnotations`.

This also changes the equality comparison for two annotations: a
Annotation created from a SubAnnotationAttr will no longer be equal to a
regular annotation when the dictionary attribute is the same.
2021-12-03 09:21:21 -08:00
Morten Borup Petersen f1b191d397
[Handshake] Add buffer removal pass (#2285)
A very simple pass which removes any buffers present in the circuit. This pass can come in handy if:
1. one would like to re-buffer a circuit
2. one would like to simulate without buffers
3. one would like to simplify the circuit (for visual/.dot inspection)
2021-12-03 17:28:59 +01:00