Commit Graph

325 Commits

Author SHA1 Message Date
John Demme 5d9b1a4e64
Update LLVM submodule (#2928)
Updating to 6b0bed7ea563624622c3c1fb1a3c90cd32c78db6.
2022-04-20 16:25:01 -07:00
Hideto Ueno 9a9e5b245f
[firtool] Rerun CSE after canonicalization in HW/SV pipeline (#2918)
This commit adds CSE after hw canonicalization to clean up values
created by canonicalization. Even though it will increase compile time slightly,
I believe it is very beneficial to run CSE again in terms of verilog qualify.
I have seen 20% simulation speed up for large designs.

This also closes #2449
2022-04-20 00:32:04 +09:00
Nandor Licker e0fd4846c6 [NFC][HV][SV] Removed HWMemSimImpl from --ir-hw output 2022-04-18 14:43:09 +03:00
Nandor Licker abe722fe5a
[firtool] Add --ir-sv flag (#2902)
Added a separate flag to dump the IR with `sv` ops, replacing `--ir-hw`.
From this point onwards, `--ir-hw` will dump IR in HW form, while `--ir-sv`
will include constructs (such as registers) expanded into SytemVerilog form.
2022-04-15 22:07:18 +03:00
Schuyler Eldridge c61f6ef69e
[FIRRTL] mv RemoveResets RemoveInvalid, NFC
Change the name of FIRRTL Dialect's RemoveResets pass to RemoveInvalid.
This is done in preparation to add functionality to RemoveResets to
remove all invalid values after it removes resets.  In effect, this pass
is now an "invalid removal" pass.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-04-12 18:04:09 -04:00
Hideto Ueno 73be86f405
[FIRParser] Create more precise timing scopes (#2875)
This commit adds a few timing scope for FIPParser so that
we can profile elapsed times more precisely.
FIRParser is the most expensive pass in firtool which spends 30%
of whole time. This commit puts 3 nested timing scopes such as
"annotation parsing", "module parsing" and "circuit verification".
2022-04-12 10:05:31 +09:00
Schuyler Eldridge 45638038c4
create_directory considered harmful
Change two usages of create_directory to create_directories as the
former will error if parent directories do not exist while the latter
will create parent directories.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-04-07 17:04:12 -04:00
Nandor Licker 1709d70a33
[HW] Introduce `hw::InstanceGraph` based on `InstanceGraphBase` (#2847)
Added an instance graph which can be used on HW, supporting
post-order traversals required by FireSim.
2022-04-07 19:35:06 +03:00
Mike Urbach 44166f4daf
[firtool] verbose-pass-execution should print the final passes. (#2855)
In a recent refactoring, firtool was split into two pass managers, so
we could stop before the "export" passes if any of the "lower" passes
failed. However, this neglected to include adding the
FirtoolPassInstrumentation to the "export" pass manager. This closes
https://github.com/llvm/circt/issues/2854.
2022-04-06 14:55:32 -06:00
Hideto Ueno 17436a74a3
[firtool] Print parsing time with verbose-pass-executions option (#2837)
This commit makes firtool print emit logs about parsing if
verbose-pass-executions option is enabled. Currently I just hard-coded
the logging messages to keep the implementation simple.

Example:
```
[firtool] Running fir parser
[firtool] -- Done in 0.056 sec
[firtool] ...
```
2022-04-05 05:29:25 +09:00
huanghuang 7168841105
[LLHD] Refactor enum class and move header file locations. (#2805)
Refactor `enum TraceMode` to `enum class TraceMode` to enrich
  the readability. And move header files to avoid re-declare like
  enum TraceFormat.
2022-03-28 09:47:45 +08:00
Nandor Licker a0a2ef9219
[Tests] Added Icarus Verilog test harness (#2739)
If questa or vivado are not found, `iverilog` is used to run supported tests. Tests which cannot be executed using this simulator can be disabled by adding `// DISABLED: ieee-sim-iverilog` or `// DISABLED: iverilog`.

Icarus verilog tests can be disabled altogether by passing `-DIVERILOG_DISABLE=ON` to cmake, similarly to other simulators.

resolves llvm/circt#879
2022-03-26 10:21:20 +02:00
Schuyler Eldridge 449384a51e
[FIRRTL] Remove BlackBoxResourceAnno Support
Remove all support for BlackBoxResourceAnno.  This annotation was
deprecated in FIRRTL 1.5.0 and is no longer emitted by any Chisel APIs
as of Chisel 3.5.0.

Fixes #2785.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-03-25 12:29:25 -04:00
Schuyler Eldridge dd00d8d0e9 [FIRRTL] Fix black box directory from GCT
Change Grand Central Views to modify existing black boxes which are
instantiated in a companion so that they will be written to the Grand
Central extraction directory.  This is done to match SFC behavior around
where black boxes are written.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-03-25 01:32:57 -04:00
Nandor Licker 1d59e2e074
Bump LLVM to 5cd9fa551e (#2789)
- `AttrDef` and `TypeDef` custom assembly has changed: https://reviews.llvm.org/D121505
- `FunctionOpInterface::getType()` renamed to `getFunctionType()` https://reviews.llvm.org/D121762
2022-03-19 01:52:27 +02:00
Schuyler Eldridge 80e0e7a288 [firtool] Fix --mlir-timing
Fix a bug when running `firtool --mlir-timing` where the timing
information of the second pass manager (which handles Verilog emission)
was being elided from the output.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-03-14 11:25:55 -04:00
Fabian Schuiki 246d4fdd34
Bump LLVM to 61814586 (#2758) 2022-03-14 14:13:45 +01:00
Mike Urbach b8a8c68bf4
[FIRRTL] Add signalPassFailure to LowerToHW and exit early. (#2745)
This adds early returns with signalPassFailure when failure bubbles up
in the LowerToHW pass. In order to catch such failures and exit before
the ExportVerilog passes, the firtool pass manager is split into two
pipelines. The first pipeline handles the main lowering passes, and
only if those succeed, the second pipeline handles ExportVerilog.
2022-03-11 10:43:58 -07:00
Fabian Schuiki a42366ba8b
[reduce] Run module externalizer and stubber before others
The `ModuleExternalizer`, `InstanceStubber`, and `MemoryStubber`
reductions are pretty aggressive and usually do a good job at pruning
the non-interesting hierarchies of the design. Move these up such that
they run very early on, making subsequent fine-grained reductions able
to iterate a lot faster.
2022-03-04 11:14:40 +01:00
Fabian Schuiki 17b71145b5
[reduce] Make MSVC happy
No comment.
2022-03-03 16:05:16 +01:00
Fabian Schuiki 1d259e6638
[reduce] Add a reduction to dissolve aggregate wires/regs
Add the `detach-subaccesses` reduction which replaces subaccesses on a
wire or register with a new wire of the subaccess' type. The reduction
is done on entire wires, if the only uses of those wires are
subaccesses. The original wire and all its subaccesses are deleted, such
that only the newly-created, detached wires are left. This has the
ability to dissolve large aggregate wires that are invalidate through
subaccesses, which the reducer cannot otherwise remove efficiently if
the wire type is non-passive.

This reduction greatly improves `circt-reduce`'s ability to deal with
inputs that have not seen type lowering.
2022-03-03 15:39:44 +01:00
Fabian Schuiki 3bda6d4d5e
[reduce] Add FIRRTL IMConstProp reduction
Run inter-module constant propagation as part of the reduction process.
This can help remove a lot of unused and unnecessary code across module
boundaries.
2022-03-03 15:39:44 +01:00
Fabian Schuiki 20842ea2aa
[reduce] Handle StrictConnectOp
Extend those parts of `circt-reduce` that interact with connect
operations and check for `ConnectOp` and `PartialConnectOp`, and make
them also check for `StrictConnectOp`.
2022-03-03 15:39:44 +01:00
Fabian Schuiki 26814cc00d
[reduce] Make reducer NLA aware
Extend `circt-reducer` with some additional mechanism to appropriately
remove `firrtl.nla` ops when instances, modules, or ports are modified
or removed. Currently this is very FIRRTL-specific, but I hope to make
this more general-purpose in the future. With this fix the reducer
becomes more useful on FIRRTL inputs that make heavy use of non-local
annotations and non-local anchors, which is very likely if they use some
form of deduplication or proper multiple instantiation.
2022-03-03 15:39:44 +01:00
Morten Borup Petersen c7c0765933
[HandshakeToHW] Initial commit for handshake-to-hw (#2680)
This initial commit handles building of the top-level hw.module when converting a handshake.func operation. All handshake modules are created as external hw modules. By doing so, follow-up commits may gradually implement each of the handshake operations using RTL dialect logic.

To transition from FIRRTL bundles with explicit ready/valid/data bundles, this commit relies on ESI channels for handshake module I/O as well as the top-level I/O.

Some changes to the flow are that:
- We're no longer inlining the handshake operations into the hw module. Instead, we maintain a value mapping from SSA values in the handshake.func to those in the hw.module, and maintain this using BackedgeBuilder operations. In general, an approach is taken of maintaining state outside the IR instead of inside the IR.

This is just the first commit in the process of transitioning away from FIRRTL for lowering Handshake operations; transitioning to be ESI based should hopefully also create a good basis for composing Handshake circuits with other parts of future HLS and CIRCT infrastructure.
2022-02-26 11:26:50 +01:00
Schuyler Eldridge 106815aea4
[FIRRTL] Preserve/Tap all "Named" Nodes or Wires (#2676)
Change end-to-end FIRRTL compilation behavior to preserve (via tapping) all
nodes and wires which are "named".  A "named" node or wire is one whose name
does not begin with an underscore.  Tapping is done by creating a "shadow node"
that is assigned the value of the actual wire and marked "don't touch".

This is done to enable better debug-ability of Chisel designs by enabling users
to always have references to named things they define in Chisel.  More
specifically, anytime a Chisel user defines a `val foo = <expression>`, CIRCT
will now produce a wire called "foo" in the output Verilog.

Add a parser option for controlling whether or not "named" wires and
nodes will be preserved from FIRRTL to Verilog.

Add a firtool command-line option for disabling name preservation during
FIRRTL parsing.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-02-25 18:34:27 -05:00
Andrew Lenharth 2755c0630c [NFC] Move SymCache to its own header 2022-02-24 16:23:32 -06:00
sinofp fda69295a3
[firtool] Add --strip-debug-info to Emit Without Source Locator Comments (#2652) 2022-02-18 19:43:10 -05:00
Andrew Lenharth bb21827888
Bump LLVM to 761bc83af4ee70c6c5156f73ed88947a5d9f013f
Bump LLVM to 761bc83af4ee70c6c5156f73ed88947a5d9f013f
2022-02-16 23:32:32 -06:00
Andrew Young 11673fc3c1
[FIRRTL] Add Dedup pass (#2524)
This adds a deduplication pass which will remove structurally similar modules
from the circuit.
2022-02-11 11:59:12 -08:00
Hideto Ueno 415032b0ac
[firtool] Implement simple logging of pass executions (#2604)
This implements a simple logging to firtool by using
mlir::PassInstrumentation. Currently it only prints 
elpased time of each toplevel modules passes.
2022-02-11 01:45:49 +09:00
Hideto Ueno 1206cc0323
[FIRRTL] Implement MergeConnectionsPass (#2459)
This commit implements MergeConnectionPass to merge expanded connections into one connection.
LowerTypes fully expands aggregate connections even when semantically
we don't have to expand because it is necessary for ExpandWhen.

More specifically this pass folds the following patterns:
```
%dest(0) <= subfield %a(0)
%dest(1) <= subfield %a(1)
...
%dest(n) <= subfield %a(n)
```
into
```
%dest <= %a
```
This pass also merge connections if their source values are known to be
constant. If `aggressive-merging` flag is true, we will merge all connections 
even when source values are not simplified.
2022-02-10 15:21:20 +09:00
Hideto Ueno 6791a4f427
[circt-reduce] Replace PortPruner with RemoveUnusedPortsPass (#2591)
This commit adds RemoveUnusedPortsPass to reduction passes and replaces
PortPruner with RemoveUnusedPortsPass. RemoveUnusedPortsPass would be
more powerfull since it prunus ports interprocedurally.
2022-02-08 01:09:17 +09:00
Andrew Lenharth 8f1c7a5294
[NFC] Bump llvm to b0cd3abf032e (#2577)
[NFC] Bump llvm to b0cd3abf032e
2022-02-03 08:48:35 -06:00
Morten Borup Petersen 63e5bf5aa3 [Handshake] Support buffer initialization in handshake runner
Can only support single-value initialization, since the handshake runner does not model SSA values as potentially representing a queue of values.
2022-01-31 11:05:04 +01:00
Hideto Ueno 6b458efcf1
[FIRRTL] Add RemoveUnusedPortsPass (#2522)
This commit adds RemoveUnusedPortsPass to prune unused ports.
RemoveUnusedPortsPass removes unused ports from the bottom of the
instance graph so that we can remove ports optimally. Ports are
not removed if they have annotations or inner sym.
2022-01-28 14:16:23 +09:00
Andrew Young 5834af868a
[FIRRTL] add WireDFT pass (#2277)
This adds a pass to wire the "test_en" port of all modules named
EICG_Wrapper to a signal marked by the "DFTEnable" annotation.  This is
used to support the Design For Testing clock gating.
2022-01-24 00:27:33 -08:00
uenoku 7205a2cb2d
LLVM bump (#2467)
* mlir::Identifier deprecated
* StringAttr::get(string, context) deprecated
* Many api changes in std dialect e.g. op.res() ==> op.getRes()
* getAsmBlockArgumentNames is moved to interface (https://reviews.llvm.org/D116018)
* populateFuncOpTypeConversionPattern => 
  populateFunctionLikeOpTypeConversionPattern
* SmallVector::set_size() becomes private (https://reviews.llvm.org/D115380) replaced with resize()
* #dialect.mnemonic is elided by default https://reviews.llvm.org/D113873.  For now, migrate by marking every type directive in asmFormat as qualified(https://reviews.llvm.org/D116905).
* Indices of LLVM::GEPOp are now required to be constant (https://reviews.llvm.org/D116759)
2022-01-22 06:01:19 +09:00
uenoku 39c0903589
[LowerTypes] Add `preservePublicTypes` option (#2424)
This commit adds preservePublicTypes option to preserve port types of 
top-level and exeternal modules. 
In chisel, external modules and top-level modules are implicitly assumed to have
lowered types. Therefore even in the aggregate presevartion mode, we
can't preserve them.
2022-01-18 23:51:54 +09:00
Prithayan Barua 1f0bf86298
[FIRRTL] Add InferReadWrite Pass (#2428)
Add a FIRRTL pass to merge the read and write ports of a memory, if their
 enable condition is mutually exclusive.
This is an implementation of the Scala InferReadWrite pass,
  `passes/memlib/InferReadWrite.scala`.
The heuristic used to infer mutually exclusive conditions, 
  1. First constructs the And expression tree for both the read and write
     enable conditions.
  2. The conditions are mutually exclusive if any of the product terms is a
	 complement of each other.
  3. Also check if both the ports are connected to the same clock.
  
This pass only looks for Seq memories, that is memory with read and write
 latency of 1, and exactly two ports.
2022-01-17 15:05:41 -08:00
Hideto Ueno f40cf9418a [LowerTypes][firtool] NFC: Remove word 'experimental' for aggregate preservation mode 2022-01-11 17:44:24 +09:00
Andrew Young 319535af03
[Reducer][FIRRTL] Fix memory stubber for memories with bundles (#2383)
This adds some additional casting and proper connections to the memory
puts in the face of bundle types.
2022-01-07 19:30:24 -05:00
Hideto Ueno ef6424c5a1
[firtoo] Move HWCleanup after canonicalizer (#2395)
Some canonicalizers create new sv.if ops. As a result,
we get redundant if statement in output verilog.
This commit fixes the issue by moving HWCleanup to the later.
2021-12-28 12:23:46 +09:00
Hideto Ueno 56e0cb130e
[reduce] Add `ConnectSourceOperandForwarder` reduction (#2369)
* [reduce] Add `ConnectSourceOperandForwarder` reduction

This commit adds a new reducion called `ConnectSourceOperandForwarder`.
If a wire is used only once as a destination of a connect, we can
forward the wire to one of operands of the source value.

For example, consider the following IR.
```mlir
%a = firrtl.wire : !firrtl.uint<1>
%src0 = firrtl.wire : !firrtl.uint<2>
%src1 = firrtl.bits %src0 0 to 0 : (!firrtl.uint<2>) -> !firrtl.uint<1>
firrtl.connect %a, %src1
```
ConnectSourceOperandForwarder reduces the IR above into
```mlir
%a = firrtl.wire : !firrtl.uint<2>
%src0 = firrtl.wire : !firrtl.uint<2>
firrtl.connect %a, %src0
```

This reduction is potentially useful for cleaning up chains of bits/pad
op inserted by the reducer.

Co-authored-by: Fabian Schuiki <fabian@schuiki.ch>
2021-12-20 22:06:07 +09:00
Andrew Lenharth 196a3f2999
make firtool output options and pipeline structure a bit more sensible (#2358)
make firtool output options and pipeline structure a bit more sensible
2021-12-17 10:14:43 -06: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
Morten Borup Petersen f771865bea [handshake-runner] Support `arith::XOrIOp` operations 2021-12-13 10:08:34 +01: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
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