Commit Graph

686 Commits

Author SHA1 Message Date
Martin Erhart fec5764cab [Arc] Prefix filenames with dialect name
Add 'Arc' as prefix to the filenames to be consistent with the other dialects.
2023-04-07 12:50:23 +02:00
Martin Erhart e7285eda01
[CombToLLVM] Remove pass (#4926)
Instead users should use CombToArith+ArithToLLVM. There is still a pattern population function left for the comb.parity op, which does not have an equivalent in the arith dialect.
2023-04-06 20:24:06 +02:00
Fabian Schuiki 96f075a0b5 [Arc] Add simple runtime helpers
Add utilities to allow C++ to link against and drive a software model
generated from the arc dialect.

The `arcilator-header-cpp.py` utility accepts the state JSON file
generated by the `PrintStateInfo` pass and converts it into a C++ header
that makes the lowered LLVM model feel close to Verilator output. The
mapping is not perfect: there is no `eval` function, but dedicated clock
and passthrough functions to be called instead. The commonalities of the
generated C++ header are collected in `arcilator-runtime.h`.

The utilities and headers aren't installed yet properly.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-04-06 10:20:15 -07:00
Andrew Butt 5061640e30
[LoopSchedule] Add initial LoopSchedule dialect (#4935) 2023-04-05 11:58:08 -04:00
Will Dietz f070eeac60
[tools] Fix -Wunused-result after bump including D146785. (#4936)
Check for failure and propagate.

https://reviews.llvm.org/D146785
2023-04-04 18:59:32 -05:00
Hideto Ueno f915d621c8
[firtool] Move 1st DropName to after CSE. Delete 2nd DropName pass. (#4928)
This reduces entire execution time by 2~3%.
2023-04-04 23:37:20 +09:00
Robert Young b55e276edf
[FIRRTL] Add a convention attribute to modules (#4665) 2023-04-03 17:50:48 -04:00
Martin Erhart 35494a7a7d [Arc] Add MuxToControlFlow pass
After the muxes that represent enables and resets are factored out by
the `InterStateProperties` pass, there are still a lot of muxes left
that have big fan-ins and can be converted to proper branches for some
performance benefit.

There is still a bit of work to do in the backend, that I haven't
included here, to support lowering of if-statements (or nested regions
in general).

The heuristics for deciding whether to convert to if-statements are not
properly fine-tuned yet because I'm still working on a proper set of
benchmarks to evaluate it and it likely changes anyways until we have a
somewhat stable set of optimizations implemented.
2023-03-28 14:37:48 -07:00
Martin Erhart c465d1216e [Arc] Add pass to make resets and enables explicit in the state ops
A pass to detect resets and enables in arcs. Making them explicit allows
another pass to pick them up more easily and, e.g., group the ones with
the same conditions together to reduce the number of branches, position
the ones with the same resets next to each other in memory to do a
simple memset over a continuous region in mem, etc.

I don't particularly like the way this is represented in the IR right
now because it makes the state ops more complex and basically everything
is just represented with this single op. It also forces us to have a
static order of reset and enable (currently the reset operand always has
higher precedence).
2023-03-28 14:37:48 -07:00
Fabian Schuiki 90832beed7
[Arc] Add basic LLVM lowering (#4685)
Add two passes to lower a design to a software model.

The `LowerClocksToFuncs` pass outlines all `arc.clock_tree` and
`arc.passthrough` operations into separate MLIR functions. This
conceptually converts clocks from being a signal in the design into a
function that can be called in order to execute the state update
triggered by that clock.

The `LowerArcToLLVM` conversion pass does exactly as it says: it sets up
a dialect conversion from Arc and the core CIRCT dialects to Func/SCF,
and from there to the LLVM dialect.

Also add an output format option to the arcilator tool that allows for
the direct emission of LLVM IR (as opposed to the MLIR's LLVM dialect).

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-03-28 14:04:49 -07:00
Fabian Schuiki 10f157f0a3
[Arc] Add state allocation passes (#4730)
Add three passes that implement state allocation. The passes take the
abstract state allocation ops, compute a memory layout for the overall
state of the model, and replace the allocation ops with simple pointer
getter ops that access the allocated piece of memory. The passes operate
as follows:

- `LegalizeStateUpdate` detects read-after-write hazards and introduces
  temporary storage locations that allow the read and write ops to
  occur without infringing on each other.
- `AllocateState` computes the overall memory layout and replaces
  allocation ops with simple accessor ops.
- `PrintStateInfo` emits the memory layout as a JSON file. This allows
  other tools to reason about the exact memory layout of the design.

State update legalization is still lacking proper handling of memory
reads and writes, which are significantly more involved than the simple
scalar registers. Follow-up work.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-03-28 12:36:21 -07:00
Aditya Naik cc4073dc98
LLVM bump to latest master (c81f14e5898c) (#4881) 2023-03-28 02:24:59 -07:00
Fabian Schuiki 5c27da3970
[Arc] Add state lowering pass (#4729)
Add the `LowerState` pass and accompanying operations to convert a
design from a pure state transfer graph composed of arcs to a more
procedural read-modify-write representation. After this transformation
the design is a significant step down the path of becoming a software
model.

The `LowerState` pass proceeds as follows:

- Group all `arc.state` ops according to their clock into
  `arc.clock_tree`s. Operations that are on direct input-to-output
  passthrough or on state-to-output paths are grouped into a
  `arc.passthrough` op.
- Introduce an explicit state storage allocation op for every state op,
  memory op, as well as every input and output port of the root module.
- Replace the root `hw.module` with a `arc.model` which no longer has
  any input and output ports, but a storage pointer argument instead.
  Storage allocation ops represent specific chunks of memory behind this
  pointer.
- Split every `arc.state` op with latency >0 up into a `arc.state_read`,
  `arc.state` with latency 0, and `arc.state_write` operation. This
  essentially breaks `arc.state` up into two parts: a read for all users
  of the state, and a transfer function plus write for all operands of
  the arc.

In doing so, the sea-of-gates representation of the HW dialect, which
is a pure graph without op ordering constraints, is converted into a
a sea-of-clocks, where each group contains the parts of the circuit that
are triggered by the same clock. The actual computation that occurs on
that trigger is represented procedurally in a proper SSA/CFG block.

TL;DR: This goes from "How do the gates connect together?" to "How does
a computer simulate these gates?".

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-03-27 13:55:05 -07:00
Fabian Schuiki 7abbc43139 [reduce] Fix llvm::function_ref induced stack corruption
Use `std::function` for the `notifyOpErasedCallback` instead of
`llvm::function_ref`, since we want to capture things on the stack.
2023-03-21 11:48:46 -07:00
Fabian Schuiki 6d182f15d1
[reduce] Fix use-after-erase in operation pruner
Fix an issue where `pruneUnusedOps` would remove operations that the
overall `circt-reduce` driver would later still try to modify. Instead,
reductions can now notify the driver that an op was erased, and any
reductions on that op will just be skipped.
2023-03-20 17:04:47 -07:00
Albert Chen cbde1b3c13
Do not use non-const lvalue-refs with enumerate (#4855) 2023-03-21 07:18:06 +08:00
Mike Urbach 44d360705e
[OM] Initial implementation of the OM dialect. (#4836)
This defines the dialect boilerplate, as well as a rationale document
that explains the intended use case and initial core constructs that
will be added in future patches.
2023-03-20 12:45:08 -06:00
Fabian Schuiki 547fd86515
[reduce][NFC] clang-tidy 2023-03-20 11:06:55 -07:00
Fabian Schuiki 48578560bc
[reduce] Fix crash on nested ops; fix poor scaling of module op counting (#4860)
Fix a source of crash in `circt-reduce` where the tool would try to
apply a reduction to a parent operation *and* some of its nested child
operations at the same time. Add a set to keep track of which operations
were already affected by a reduction on their parent, and skip those.

Also fix poor scaling behaviour in `computeTransitiveModuleSize` which
made the FIRRTL module externalizer and instance stubber very slow. The
new simplified implementation doesn't produce reduction estimates as
accurately, but it is a lot faster and seems sufficient in most cases.

Implements parts of #4100.
2023-03-20 10:48:07 -07:00
Fabian Schuiki 846dd02bde
[Arc] Add tap op to observe ports/wires and AddTaps pass (#4684)
Add an `arc.tap` operation that allows us to assign a name to an
arbitrary SSA value such that it remains observable after any subsequent
transformations. Also add an `AddTaps` pass which adds an `arc.tap` op
to every module port and every wire, making them observable even after
transformations have completely flattened the original hierarchy.

Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-03-16 15:47:42 -07:00
Fabian Schuiki ee95300b53
[Conversion] Add Comb to MLIR Arith conversion pass (#4728)
Add an experimental pass to convert operations in the Comb dialect to
their equivalent in the Arith dialect. The pass isn't used anywhere yet,
but conversion to Arith allows all canonicalizations defined on that
dialect to take effect before mapping things to LLVM to generate a
software model.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
2023-03-15 21:54:35 -07:00
Fabian Schuiki 76719d549e
[Arc] Add pass to remove unused arc arguments (#4725)
Add the `RemoveUnusedArcArguments` pass that does exactly what it says.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
2023-03-15 21:43:52 -07:00
Fabian Schuiki fc36fad1c1
[Arc] Add makeshift input preprocessing (#4683)
Many CIRCT frontends don't generate clean HW representations of their
inputs, but instead intersperse SV dialect operations to explicitly
materialize named wires. Add a makeshift `StripSV` pass to remove some
of the trivial SV dialect ops (wires just for the sake of naming) and
to replace `seq.firreg` with `seq.compreg` throughout the input. At a
later point we'll want to introduce a "register" op interface such that
passes can inquire about a register op's semantics in a uniform manner.

Similarly, the Seq dialect lacks a memory construct. The FIRRTL pipeline
lowers its `firrtl.mem` ops into HW generator ops. Add a `InferMemories`
pass that converts this generator op into a proper `arc.memory` op with
associated `arc.memory_read` and `arc.memory_write` operations.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-03-15 21:42:01 -07:00
Fabian Schuiki 7921813f40
[Arc] Add lookup table generation pass (#4682)
Add the `MakeTables` pass which finds small arcs and converts them into
a lookup table where possible.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-03-15 21:41:12 -07:00
Fabian Schuiki c04d52e637
[Arc] Add constant sinking pass (#4715)
Add the `SinkInputs` pass which sinks constants into arc definitions
where possible. The arc conversion pass keeps constants out of arcs to
increase the chance of discovering arcs that only differ by constant
values, at the cost of additional arc arguments. The `SinkInputs` pass
is intended to run after deduplication, to simplify arc inputs that are
set to the same constant at all arc call sites.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-03-15 21:40:34 -07:00
Fabian Schuiki 5a299afee2
[Arc] Add loop splitting pass (#4714)
Add the `SplitLoops` pass which splits arcs with multiple results into
arcs with just one result. This is intended to break "false" loops among
`arc.state` ops. Grouping combinational ops into arcs may introduce
loops between the arcs even though the combinational ops had no loops
themselves. Ideally we'd be more clever about the splitting and only
separate the arc outputs that actually cause these loops, implementing
this is a bit more involved than the current solution though. Reducing
arcs to one output suffices for now.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-03-15 20:45:41 -07:00
Andrew Young 9620d656f8
[firtool] Remove many unsued CL options (#4820)
This PR removes many hidden developer options from `firtool`.  These
options were more useful when we would regularly have crashes in
specific passes and a developer would want to temporarily bypass the
pass.  Now that we are much more stable, these options don't add any
utility, and we risk that a user may find and start using one of these
options.

This change also:
  - removes the unused `emit-metadata` flag
  - stops predicating the dedup pass on `--disable-opt`, which allows us
    to disable optimization and run the dedup pass.
  - restores the original intent of the test in `chirrtl.fir`, which was
    to make sure that optimizations were not affecting enable inference
    of CHIRRTL read ports.
2023-03-14 16:39:47 -07:00
John Demme a858beb2d8
[PyCDE] Package collateral SV and binaries (#4808)
Necessary to synthesize and simulate ESI systems out-of-tree. Had to refactor some CMake files to increase reusability.
2023-03-13 18:23:25 -07:00
Fabian Schuiki c37e320a60
[Arc] Add arcilator convenience tool (#4700)
Add the `arcilator` convenience tool to make experimenting with the
dialect easier. The intended pass sequence performs the full conversion
from a circuit cut along port boundaries (through modules) to a circuit
cut along the state elements (through arcs). The tool simply executes
this pass pipeline.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-03-12 16:39:31 -07:00
Fabian Schuiki 034a9e9825
[Arc] Add deduplication pass (#4698)
Add the `Dedup` pass which deduplicates arcs with identical definitions.
If arcs differ only by constant values, the pass outlines the constants
such that the arcs can be deduplicated.

Identical arcs are surprisingly common since splitting modules along the
fundamental state elements yields a finer-grained subdivision than the
modules themselves, which has the potential to uncover additional
redundancies.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-03-12 16:37:35 -07:00
Andrew Lenharth b054d21b72
[FIRRTL] make IMCP correct for registers and more aggressive (#4777)
Make IMCP not try to optimize registers. All the existing firrtl register optimizations are unsafe in that they change visible behavior. For this reason, they those optimizations are to be moved out to a separate pass and IMCP will be left as purely behavior preserving.

Secondly, many folders can operate on incomplete operand information. Rather than giving up and not folding these, if we have some constants, we try to fold, but we don't over-define if some of the operands were unknown. This way things like or(const 0, unknown) can fold.
2023-03-08 16:14:46 -06:00
Hideto Ueno c187f68b3f [circt-opt] Print a version string
This commit adds `cl::AddExtraVersionPrinter` to circt-opt as we are doing
in firtool.
2023-03-07 04:31:56 -08:00
Robert Young 8575353c9a
[FIRRTL] Correct memory lowering behaviour for vb-to-bv conversion (#4746)
Perform vb->bv conversion before flattening memories. The vb-to-bv pass cannot
reshape memories that have been flattened.

Add a memory preservation option to lower types. Before, lower-types would
unconditionally fully scalarize memories. Now we can run lower types without
lowering memories.  This lets us use lowerTypes to scalarize the ports of
public modules, before running vb->bv, without affecting memories.
2023-03-03 09:02:44 -05:00
Robert Young 38b1f39856
[FIRRTL] Add a pass to convert VoB -> BoV conversion (#4654)
This pass converts objects with the shape vector<bundle> to bundle<vector>.
2023-03-01 13:57:42 -05:00
Hideto Ueno f7963642b6
[Support] Move FirtoolPassInstrumentation to a support header (#4738)
This commit moves FirtoolPassInstrumentation to a support header and rename FirtoolPassInstrumentation to VerbosePassInstrumentation. 

This subsumes https://github.com/llvm/circt/pull/3931/. Calling `isa<firrtl::CircuitOp>` caused circular deps between firrtl and support so this PR instead used template arguments to filter operation types.
2023-02-28 19:31:19 +09:00
Fabian Schuiki 55e2230e3f
[Arc] Add arc conversion pass (#4697)
Add the `ConvertToArcs` conversion which collects the combinational
operations in a module body, divides them into distinct sets split along
registers and a few other potentially state-holding operations, and
outlines these sets into arc definitions, inserting an `arc.state` op in
place of the original combinational ops.

Note that this merely replaces logic and registers with arc invocations,
but keeps the module hierarchy intact.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-02-23 22:27:01 -08:00
Fabian Schuiki 037bd2b012
[Arc] Add dialect (#4681)
Add the `Arc` dialect which is useful for capturing a canonical
representation of the state transfer in a circuit. It does this by
introducing function-like arc definitions (`arc.define`) and call-like
arc invocations (`arc.state`). The state op represents a transfer
function, given by the arc definition, and zero or more registers, as
specified by its latency attribute.

Co-authored-by: Martin Erhart <maerhart@outlook.com>
Co-authored-by: Zachary Yedidia <zyedidia@gmail.com>
2023-02-22 01:24:22 -08:00
Fabian Schuiki 8e911fa3c6
[NFC] Whitespace fix 2023-02-19 17:18:39 -08:00
Fabian Schuiki bb1236fb28
[circt-reduce] Steal CIRCT_DIALECT_LIBS from circt-as
Instead of listing all dialect libraries manually, query the list of
registered dialect libraries for circt-reduce.
2023-02-19 17:18:39 -08:00
Andrew Lenharth 4c1f0b4ee8
silence warning (#4678) 2023-02-18 00:31:52 -06:00
John Demme 14bb38c759
[ESI][Cosim Runner] Add support for running binaries (#4639)
Adds the '--exec' flag to tell this util to run the file instead of
parsing it and constructing a python script. Also removes unused
functionality SOURCES: and ARGS:. If `--exec` is used, the program's
first two args are the cosim port number and the path to the schema. If
the specified test application ends in '.py', it'll run the python
script with the python interpreter.
2023-02-07 19:20:38 -08:00
Andrew Young 601b33bcda
[firtool] Use CIRCT's StripDebInfo pass instead of upstream (#4632)
With the recent change to how port location information is handled, the
upstream pass StripDebugInfo no longer leaves the IR in a valid state,
as it does not update the debug information stored in module ops.  To
fix this problem, we just have to use the local version of this pass,
StripDebugInfoWithPred and tell it to remove all locations.

Closes #4631.
2023-02-06 11:12:05 -08:00
Schuyler Eldridge c210f1a2d5
[firtool] -lower-annotations-no-ref-type-ports
Add "-lower-annotations-no-ref-type-ports" option to firtool.  This is
an option that will cause the LowerAnnotations pass to only create
"real" ports, instead of ref type ports, when resolving WiringProblems.
The intended use case of this pass is to enable Grand Central Tap
collateral to be made synthesizable.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2023-01-27 16:57:41 -05:00
Schuyler Eldridge c9f7723269
[firtool] Add -grand-central-instantiate-companion
Add an option that will cause Grand Central companion modules to not be
bound in (they are directly instantiated) and interfaces are no longer
emitted.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2023-01-27 16:57:40 -05:00
John Demme 5bffaaaa93
Bump LLVM submodule (#4568)
* Bump LLVM submodule

Minimal progress, but worth sharing.

* compiling now

* clang-format

* remove unnecessary includes from msft dialect

* XFAIL'ing broken Calyx tests

* Bump LLVM submodule

Minimal progress, but worth sharing.

* compiling now

* clang-format

* remove unnecessary includes from msft dialect

* XFAIL'ing broken Calyx tests

* Fix Calyx tests and ASAN, and re-enable. (#4592)

* Bump to 26th Jan

* switch to ninja and latest cmake

* hopefully fix ci builds

* use full path

* [circt-reduce] Set the default op for pass manager to builtin.module

---------

Co-authored-by: Andrew Young <youngar17@gmail.com>
Co-authored-by: Mike Urbach <mikeurbach@gmail.com>
Co-authored-by: Prithayan Barua <prithayan@gmail.com>
2023-01-27 07:57:27 -08:00
Prithayan Barua e5271b1c2c
[circt-reduce] Explicitly nest the passes (#4594)
Nest the passes explicitly when adding to PassManager.
Required for the latest LLVM Bump, #4563
Relevant commit https://reviews.llvm.org/D137731
2023-01-26 00:08:29 -08:00
Will Dietz ddbb6c3a86
[firtool] Add --include-dir option, -I as alias. (#4576)
Support long-form version of option for readability.

Include usage in description to workaround `cl::value_desc`
not seeming to work for the alias.
2023-01-23 14:27:15 -06:00
Julian Oppermann 2d0430eac4
[Scheduling] Purge test passes. (#4572)
Use the SSP dialect and `-ssp-schedule` instead.
2023-01-24 08:38:48 +13:00
Will Dietz 54c8354662
[firtool] Add include directory flag (#4539)
Can be used to provide nicer diagnostics or to help find supporting files like annotations.
2023-01-12 08:00:28 -06:00
Prithayan Barua 0cf02d2132
[FIRRTL][CheckCombLoops] Switch to the new pass checkCombLoops instead of checkCombCycles (#4513)
Switch to the new CheckCombLoops pass and add a flag
 `--use-old-check-comb-cycles` to switch to the old `CheckCombCycles` pass.
2023-01-09 20:57:37 -08:00
Mike Urbach 7b92539575
[firtool] Run SymbolDCE as late as possible. (#4504)
This pass should generally be run as late as possible so it can clean
up after all prior passes. It currently runs just before the
BlackBoxReader pass, which happens to leave behind some dead symbols.

This moves it as late as possible: just before InnerSymbolDCE. While
there is no new integration test of the firtool pipeline with this
change, it has been shown to remove symbols that would otherwise
remain.
2023-01-05 19:33:27 -07:00
Will Dietz 023119d5d1
[FIRRTL] remove GrandCentralSignalMapping pass + tests. (#4505) 2023-01-05 16:14:50 -06:00
Hideto Ueno f42e66da49
[firtool] Strip mux pragmas by default, NFC (#4501)
This PR deprecates `strip-mux-pragmas` flag and add `add-mux-pragmas` flag. Mux pragmas will not be emitted by default. `strip-mux-pragmas` is not deleted for now so that we can deploy a new version of firtool more smoothly.
2023-01-05 18:04:52 +09:00
Will Dietz 1050a719d2
LLVM bump: move almost entirely to std::optional, fixes (#4470)
* LLVM.h: drop mlir::Optional.

It's an alias for std::optional now, just drop
instead of adding the templated using alias here as well
(which we'd have to remember to drop).

* Convert Optional -> std::optional.

Drop some unnecessary initializations, but keep them for fields for now.

Particularly:
StandardToHandshake.h: keep init for field, for omission in {} initializers.
FSMToSV: similarly keep the current initialization.
2022-12-22 18:57:38 -06:00
Will Dietz 23d4a87bae [ESI][Reduce] Add LLVM.h for forward-declarations. 2022-12-21 16:17:58 -06:00
Will Dietz 25ade39cec [Handshake] any_isa -> any_cast, will be deprecated. 2022-12-21 16:17:58 -06:00
Schuyler Eldridge 3abd698f6e
[firtool] Remove GCT Taps pass from pipeline
Remove the Grand Central (GCT) Data/Mem Taps pass from the firtool
pipeline.  All Annotations related to these features have been migrated
to be handled by LowerAnnotations using RefType infrastructure.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-12-20 01:19:36 -05:00
Will Dietz e92e10f34e
[LLHD] Install llhd-sim utility (when enabled). (#4464)
We already build+install its libraries, include tool too.
2022-12-19 16:22:26 -06:00
Nandor Licker ff7dcff13d
LLVM Bump (#4463)
Replaced `llvm::Optional` with `std::optional` where necessary and fixed warnings involving `.value()`.
2022-12-19 17:15:10 +02:00
Mike Urbach d0462e7ece
Bump LLVM to b6772e6e2045ab491b41d3767f788250800f97ea. (#4444)
This is NFC. The only change is related to the transition from
llvm::None to std::nullopt, so I cleaned those up.

This LLVM commit includes a few additions to the MLIR Python API that
will be good to build on top of.
2022-12-16 13:17:03 -07:00
Hideto Ueno 9bbd2e0357
Bump llvm (#4432)
This bumps llvm just before 53406427cd which will cause a lot of complication failures about FunctionOpInterface. This PR mostly replaces llvm::None with std::nullopt.
2022-12-13 03:21:28 +09:00
Andrew Lenharth 316421a20b
[FIRRTL] Add support for "intrinsics" (#4429)
Add support for intrinsics in FIRRTL. Until intrinsics are supported in the firrtl spec, or we have more complex intrinsics, do direct lowering of intrinsics into their ops.

It is expected that eventually something like an "intmodule" will exist and annotated extern modules will not be used for intrinsics or first they will lower to intmodules internally, then intmodules will be handled uniformly.

As an example, add a sizeof operator which returns the number of bits in the argument type. This let's you query the result of type inference from inside the circuit.

Also adds support for isX as an intrinsic and plusarg sv functions.
2022-12-10 10:34:18 -06:00
Andrew Young 359ffdfb56
[hlstool] Remove header include to fix flaky build (#4427)
The `InitAllPasses.h` header file includes all the generated pass header
files, e.g. `"circt/Dialect/SystemC/Passes.h.inc"`.  To make sure this
header file is generated properly before we try to include it, we have
to depend on the associated transform library.  Since hlstool does not
depend on every single transform library, this causes the build to
occasionally fail.  To fix this, we need to only include header files
belonging to the dialects we are actually depending on.

This error can be seen in the following build:
https://github.com/llvm/circt/actions/runs/3657570236/jobs/6181309548
2022-12-09 07:56:32 -08:00
Hideto Ueno 659a409ca5
[MergeConnections] Use vector/bundle create and enable aggressive merging by default (#4385)
This PR improves MergeConnections to use vectorcreate and bundle create op instead of bitcasting to aggregates.
2022-12-01 16:50:11 +09:00
Morten Borup Petersen 1109be96dc
[hlstool] Move extmem lowering in pass pipeline (#4376) 2022-11-30 13:02:19 +01:00
Julian Oppermann fa61059d0a
[SSP] Add pass to print instances as DOT graphs. (#4363) 2022-11-29 12:27:29 +13:00
Schuyler Eldridge fbe4f3c8bc
[FIRRTL] Add Inner Symbol DCE Pass (#3120)
This finds and removes any InnerSymAttrs that are not used.

It starts with a walk through the IR to find any InnerRefAttrs. This
looks through all operations' attributes, descending through nested
attributes using the sub element interface.

After finding all live InnerRefAttrs, it walks through each module in
parallel looking for operations with an InnerSymAttr. If the module
and symbol were not in the set of live inner references, the inner sym
is removed.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Co-authored-by: Mike Urbach <mikeurbach@gmail.com>
2022-11-23 11:07:53 -08:00
John Demme eff300e35c
[PyCDE] Support for BSP-defined packaging (#4338)
Introduce the notion of a "board support package" (BSP). It controls the top level of the design and assembles the system into a "package". A package generally includes the hardware output (+ any other collateral needed to build the design), the software runtime, and a script (makefile) to build the system and (for some BSPs) run it.
2022-11-21 11:45:43 -08:00
Hideto Ueno e9f443be47
[HWMemSim, LowerSeqToSV] Add a flag to annotate array registers with `(*ram_style = "distributed" *)` (#4288)
This adds an option `--add-vivado-ram-address-conflict-synthesis-bug-workaround` to add a workaround that vivado maps BRAM to memory register that has caused an incorrect synthesis result. To prevent vivado from using BRAM for registers, this expliclity specifies the ram style so that vivado selects LUTs. With this PR, registers used as memory are annotated in the following way:

```
  (* ram_style = "distributed" *)
  reg  [15:0] Memory[0:9];
```
2022-11-18 04:06:11 +09:00
Hideto Ueno 22d426cadf
[Seq] Use a new pass generation mechanism (#4304)
This applies a new pass generation method(ref:https://github.com/llvm/circt/issues/3962) to seq dialect passes, that automatically defines a struct of options (e.g. `LowerSeqFIRRTLToSVOptions`) and creates a pass constructor to take the option.
2022-11-15 14:23:19 +09:00
Schuyler Eldridge c676bc9173
[tools] Change tools to use CIRCT-specific bug msg
Change all existing CIRCT tools to use a CIRCT-specific bug report
message.  Previously a crash would tell people to file a bug on LLVM
which isn't correct.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-11-12 18:10:54 -05:00
John Demme 6ed5055917
[ESI] Move ESI collateral into build include directory (#4292)
These files are used by end users, so they need to eventually go into the install. Getting them into the build directory is a first step.
2022-11-10 19:58:39 -08:00
John Demme 42f1ae6b51
[RTL-SIM] Fix trace debug output in Verilator driver (#4293)
We were passing in a C macro improperly. Also add fix some asserts in the ESI capnp decoder modules to support `i0`.
2022-11-10 19:44:20 -08:00
Carlos Eduardo f415ef1987
Make flatten memory pass default. Create lower-memory flag. (#4275)
- Turn on FlattenMemoryPass by default
- Add -lower-memories flag to firtool
2022-11-09 20:33:07 -05:00
Will Dietz 937457399f
Add options for controlling emission of randomization code. (#4240)
Add `--disable-{mem,reg,all}-randomization` to firtool.

Fixes #4202.
2022-11-04 14:46:51 -05:00
Morten Borup Petersen bac3f28cbf
[HandshakeToHW] Fix extmem lowering (#4198) 2022-10-27 11:58:15 +02:00
Morten Borup Petersen 1db9d8499d
[Handshake] Add memref legalization pass (#4191) 2022-10-26 21:35:51 +02:00
Martin Erhart d6ca0e6ff9
[SystemC] Lower Interop pass for verilated operation (#4143) 2022-10-26 21:09:29 +02:00
Morten Borup Petersen a428ac7626
[HandshakeToHW] Add `handshake.memory` lowering (#4175) 2022-10-26 08:37:46 +02:00
Martin Erhart c0f0d4c97d
[RFC] Interoperability dialect (#4126) 2022-10-25 10:50:46 +02:00
Morten Borup Petersen dc255c6eb2 Add compile args string argument to circt-rtl-sim.py 2022-10-19 13:53:10 +02:00
Schuyler Eldridge 3a39b339f0 [firtool] Add TraceNames to firtool
Add the TraceNames pass to firtool.  This runs right before the LowerXMR
pass.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-10-17 18:26:52 -07:00
Mike Urbach 8358725dbb
[SV] Add feature flags to new SVExtractTestCode features. (#4094)
These new additions are both fairly significant departures from past
behavior, so add an ability to disable them. They remain enabled by
default. The new flags are plumbed out to firtool flags so they can be
disabled from firtool, and a test is added that this behavior can be
controlled from firtool.
2022-10-13 12:07:20 -06:00
Hideto Ueno 9197184795
[HWMemSimImpl] Add mux pragmas to memory reads (#3913)
This commit adds mux pragmas to memory reads in HWMemSimImpl in a similar way to https://github.com/llvm/circt/pull/3404. This commit also adds a flag `strip-mux-pragmas` for firtool 
to remove mux pragmas annotated at HWMemSimImpl and LowerToHW.
2022-10-12 03:15:31 +09:00
Andrew Lenharth 5498d926f4
Don't read lowering options from hidden global options (#4038)
Add a pass to overwrite lowering options on a module. This lets us get rid of the in-library cmdline option and move it to the two tools which need it. With this, prepare and export never change the lowering options.

Also make prepare a nested pass.
2022-10-04 15:41:03 -05:00
Morten Borup Petersen a63a23cb7b
[HandshakeToHW] Fix merge, control merge, buffer (#4053)
+ a small modification to `_findPort` in the handshake test driver to comply with ESI port naming.
2022-10-04 12:54:02 +02:00
Morten Borup Petersen 8ae35705be [hlstool] Add iverilog tracing option 2022-10-04 11:14:42 +02:00
Mike Urbach d4aade214b
Bump LLVM to c4ca3a2c4b00033c393f694c1d92d28ff55c69cd. (#4048)
This included three renames:
* Arithmetic -> Arith
* FunctionOpInterface::getBody -> FunctionOpInterface::getBodyBlock
* MemRef dialect switching to prefixed accessors (memref -> getMemref, etc.)
2022-10-03 20:36:21 -06:00
Morten Borup Petersen 74ce53c293 [hlstool] Fix nesting of extmem lowering pass 2022-10-03 09:40:39 +02:00
Morten Borup Petersen 5d51257539 [HandshakeToHW] extmemory now lowered in separate pass 2022-10-03 08:38:26 +02:00
Morten Borup Petersen f97396f9bb [hlstool] Run canonicalizer after HandshakeToHW 2022-09-30 12:41:36 +02:00
Hideto Ueno 4d7102f3d6
Bump llvm (#3996)
Bump LLVM to [585010b4b0a3f986f611](585010b4b0)
2022-09-26 21:02:59 +09:00
Will Dietz d7892c8a8c
[FIRRTL] Reuse HierPathOp's when creating in LA, fix GC(T) cleanup, add SymbolDCE to pipeline (#3979)
We create and manage many thousands of HierPathOp's unnecessarily.
Fix this by addressing the primary location they're added to the IR: LowerAnnotations, by using a simple cache to avoid emitting duplicate ops.
This reduces the count from thousands to tens on even small-ish designs.

Modify GC and GCT passes to stop deleting HierPathOp's as they don't know if they're still used. Indeed, in our tests we were deleting these ops despite them still being alive (breadcrumbs).

Add SymbolDCE to the pipeline to do this cleanup instead, thanks to various recent changes using private visibility in many places, particularly the HierPathOp's themselves (#3871).
2022-09-23 10:02:28 -05:00
Will Dietz 16faca3664
hlstool,circt-{as,dis}: gather options into category, hide unrelated options (#3980)
Add simple commandline tests as well.
2022-09-23 09:59:14 -05:00
Will Dietz fba580565b
circt-{as,dis}: init basic MLIR <--> MLIRBC utilities. (#3941) 2022-09-22 10:43:31 -05:00
Christian Ulmann ebc961730f
[hlstool] Add DHLS parallelism selection (#3969)
This commit adds a flag to `hlstool` that allows selecting the kind of parallelism to support. Currently, these options are "pipelining", "locking", and "none".
2022-09-22 15:52:55 +02:00
Christian Ulmann 3735292129
[hlstool] Expose buffer insertion cl options (#3964)
This commit adds the two options of the buffer insertion to the `hlstool`. Thus, it's now possible to specify both buffering strategy and buffer size when using the tool.
2022-09-22 07:56:23 +02:00
Schuyler Eldridge e61288bf32
[firtool] Lower annotations with -parse-only
Change `firtool -parse-only` to stop after parsing, verification, and
annotation lowering as opposed to stopping after parsing.  It is
incredibly rare that a user (or, much more likely, a developer) actually
wants the behavior of stopping after parsing as opposed to stopping
after annotation lowering.  This avoids a frequent pattern where a
user/developer will use something like the following instead of
`-parse-only` for any circuit that includes annotations:

  firtool -parse-only Foo.fir | circt-opt -firrtl-lower-annotations

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-09-21 18:24:46 -04:00
Prithayan Barua db16851776
[Reduction] Handle memory debug ports (#3958)
Handle the memory debug port in Reduction.
2022-09-21 06:05:16 -07:00
Morten Borup Petersen 16ed2b7ba8 [hlstool] Register ESI dialect 2022-09-19 16:38:26 +02:00
Morten Borup Petersen f626d0e67c
[HandshakeToHW] Add `seq` buffer lowering (#3933) 2022-09-19 10:04:13 +02:00
Andrew Lenharth 73967efeaa
[FIRTOOL] Run canonicalization prior to seq lowering. (#3904)
Register lowering is very sensitive to mux structure, so clean this up prior.
2022-09-16 11:49:34 -05:00
Morten Borup Petersen 616649b4b6
[Pipeline] Add pipeline stage register materialization pass (#3876)
[Pipeline] Add pipeline stage register materialization pass

This commit adds an intermediate transformation to the Pipeline dialect
which is responsible for converting `pipeline.stage` to `pipeline.stage.register`
operations. The purpose of this transformation is to 'fix' where
registers needs to be placed in the pipeline, after all stages have been
defined and placed.

In short, the transformation will scan through the pipeline (in order,
top to bottom) and insert `pipeline.stage.register` operations in place
of `pipeline.stage` operations. Any operand used in any operation will
be analyzed to determine if it originates in between the last seen stage
and the operation itself. If not, this means that the operand crossed
a pipeline stage, and as such, the value will be routed through the
predecessor stage (`routeThroughStage`).
2022-09-16 15:03:58 +02:00
Morten Borup Petersen 95b448f587 [hlstool] Split HW lowering into two steps
... To provide an intermediate point where things are in core RTL dialects, and haven't been converted to SV.
2022-09-16 11:30:21 +02:00
Andrew Lenharth 1646243a27
[NFC] LLVM bump for 2022/09/14 (#3889)
Bump LLVM.
2022-09-15 08:49:33 -05:00
Richard Xia fdc1dc30cf
Bump LLVM (#3872)
* [Calyx][FIRRTL] Put explicit type hints for TypedValue where necessary.

With the introduction of TypedValue in upstream llvm commit
688c51a5acc53b456014e53663051476d825e896, there are now a few cases
where we need to explicitly write the types. In some cases, we need to
explicitly upcast to Value to be consistent with other Values in the
expression, and in other cases, we need to upcast the type parameter of
TypedValue when there are ambiguous implicit conversions.

* [FIRRTL] Replace llvm::GreatestCommonDivisor64 with std::gcd.

GreatestCommonDivisor64 was removed in upstream LLVM in
87c38323a2cff5b26023b24c36a7c01741aba834, and the recommended migration
path is to use std::gcd. This performs an explicit cast to uint64_t for
the same reasons described in 4a2377afd69bcf014492cb665ee955eab3121c4c,
which is that std::gcd may have different and unexpected semantics when
its arguments are of different types and signedness.

* [NFC] Explicitly set dialect accessor prefix to kEmitAccessorPrefix_Raw.

Upstream recently changed the default value of emitAccessorPrefix to
kEmitAccessorPrefix_Prefixed. This patch explicitly sets
emitAccessorPrefix to the previous default value of
kEmitAccessorPrefix_Raw, which will allow us to the new accessor prefix
style more gradually and at our own pace. Upstream will completely
remove the _Raw style in the next couple of months, so we will need to
make the migration soon, though.

See [1] for more information.

[1]: https://discourse.llvm.org/t/psa-ods-generated-accessors-will-change-to-have-a-get-prefix-update-you-apis/4476

* [firtool] Pass config object to new writeBytecodeToFile API.

The third argument to writeBytecodeToFile() now takes a
BytecodeWriterConfig object instead of just the producer string.

* Bump llvm to 13f1bc41888e7d6555c532ba5fa925b9fe3e6b2f.
2022-09-14 09:00:27 -07:00
Morten Borup Petersen e7405f7be9
[Pipeline] Add `pipeline.pipeline` HW lowering (#3874)
This is a fairly straight-forward transformation since the brunt of the
work of detecting which values will be registered in a given pipeline
stage has already been performed by a prior pass.
This pass simply elaborates the `pipeline.stage.register` operations
into `seq.compreg` operations and stitches up the circuit.
2022-09-14 17:41:29 +02:00
Morten Borup Petersen f5a979e094 [hlstool] fix typo 2022-09-13 15:12:23 +02:00
Morten Borup Petersen a249757c1f
[hlstool] Add hlstool for composing high-level abstractions and passes (#3866)
... the long awaited.

This intends to be a mostly boilerplate-y commit for introducing an `hlstool` to circt. The goal is fairly clear - provide a tool which composes the various passes and abstractions in CIRCT which care about high-level design/synthesis.
By doing so, the tool intends to take out the guesswork in terms of how these abstractions are to be composed, as well as when and where to run a pass.

Benefits should be fairly immediate - both in terms of reducing the verbosity of integration tests (many of which currently have to manually describe a fairly long pass pipeline) as well as for newcomers to CIRCT, which can be pointed to a tool/pass pipeline that shows a verified phase ordering of lowering/transformation passes.

As for tests, this commit includes modifications to most of the Handshake integration tests using the 'all' driver.
To replace all tests, a follow-up commit should define how to handle flow-specific arguments to `hlstool`.
2022-09-12 19:30:35 +02:00
John Demme 23f4505a89 [ESI][Cosim] Add 'tmpdir' and 'interactive' options to runner
These new options support expanded ESI/PyCDE integration tests.
'interactive' runs the python script in the foreground to enable
interactive debugging. 'tmpdir' is generally used for finding the
generated ESI runtime API.
2022-09-09 12:45:31 -07:00
Richard Xia f486947e15
[FIRRTL] Use BitVector over ArrayRef/SmallVector for eraseArguments. (#3837)
* [FIRRTL] Use BitVector over ArrayRef/SmallVector for eraseArguments.

Upstream MLIR removed an overload of `eraseArguments()` in
27e8ee208cb2142514ee2e3ab342dafaf6374f9e, stating that the overload
isn't useful because we should probably be using BitVector in most
cases.

This mostly affected code in the FIRRTL dialect that used SmallVector
for holding the list of port indices to delete, which indeed can be
replaced with a BitVector.

One thing to be careful about is that while `push_back()` is still
defined on BitVector, it has different behavior than
`SmallVector<unsigned>::push_back()`, in that the former only allows you
to push back a boolean 0 or 1 to the end of the bit vector, while the
latter pushes back an integer index. `BitVector::set()` matches the
previous behavior.

Co-authored-by: Will Dietz <will.dietz@sifive.com>
2022-09-08 14:54:19 -07:00
John Demme fd1adf2a2d [ESI][Cosim] Automatically detect driver name
Endpoint IDs differ by simulator by prefix, wherein the prefix is based
on the top module. Instead of specializing tests to the simulator,
automatically prepend the endpoint ID prefix to endpoint IDs on open
requests.
2022-09-06 15:39:42 -07:00
Andrew Lenharth 5603877553 convert seq firrtlreg lowering into parallel pass 2022-09-02 10:26:02 -05:00
Martin Erhart 485952a28c
[SystemC] Add NewOp and DeleteOp (#3798) 2022-09-01 11:57:52 +02:00
Andrew Young f6a0d6921c
[firtool] Reorganize pass controlling options (#3794)
We have many flags which control whether or not we run a specific pass,
such as `--lower-types`.  Most of these flags should never be used by
regular firtool users; they are only really useful for circumventing a
crash in a pass and can often lead to other crashes.  This moves most of
the pass options to be of the form `--disable-mypass`, and makes them
 hidden by default.  The descriptions of these options were made
uniform, at the cost of a less detailed description.

The `GrandCentral` pass was enabled by default. Since its behavior is
controlled by annotations, it should always run.

This also did a small sweep to make sure that all our option
descriptions begin with a capital letter.
2022-08-30 09:18:01 -07:00
Andrew Lenharth 182d0fdcb6 [NFC] don't do both seq.reg and seq.firrtlreg in the same pass 2022-08-30 11:08:02 -05:00
Prithayan Barua c8086bda4a
[firtool] Enable LowerXMR by default (#3790)
This commit adds the `LowerXMR` pass to the firtool pipeline and enables it
by default. This is required since the `LowerToHW` pass cannot handle `RefType`,
so all ops and ports of `RefType` must be removed.
2022-08-29 10:27:38 -07:00
Hideto Ueno df1bb2d068
[FIRTOOL] Skip CheckCombCycles pass when aggregate preservation is enabled (#3767)
Towards aggregate preservation, this PR disables CheckCombCycles for now 
when aggregate preservation is enabled. This should be reverted once CheckCombCycles
pass support aggregate.
2022-08-29 16:13:51 +09:00
Will Dietz 2e876eba29
[FIRRTL][firtool] Add support for reading/writing bytecode (#3762)
Support emitting bytecode via new `-emit-bytecode` flag.

Use the `-f` flag to force printing to terminal.

Also, auto-detect and parse bytecode when passed to stdin.
2022-08-28 19:44:56 -05:00
Prithayan Barua d35d64e6cd
Bump LLVM to 1bcf21c (#3787)
Bump LLVM and the required updates:
1.  Rename getEnclosingAffineForAndIfOps to getEnclosingAffineOps: The utility was extended to also support affine.parallel ops) The commit: llvm/llvm-project@26fedf9
2. Update lit tests to make DefaultValueAttr, not optional! llvm/llvm-project@af3ed4a
3. Move hasValue to has_value
2022-08-28 11:34:18 -07:00
John Demme cb357a0704 [CIRCT Test Runners] Run the same Python binary as cmake found
If they happen to call APIs which need some of the shared libraries,
it's important they use the same Python version against which we
compiled those libraries.
2022-08-26 12:49:03 -07:00
Daniel Resnick 5f91346570
[ExportChiselInterface] Basic infrastructure for Chisel Interface file emission (#3760)
* [ExportChiselInterface] Basic infrastructure for Chisel Interface file emission

This commit adds a pass for FIRRTL that generates a Scala file with a module
class that represents the interface for the top module of the FIRRTL circuit.
This is to support the development of separable compilation of FIRRTL circuits.
The details about linking circuits together are to be determined. The generated
Scala module extends ExtModule, although a new module class may be introduced
in the future.
2022-08-25 11:56:50 -06:00
John Demme 418b790713 [RTL-Sim] Fix bug which caused tests to fail when killed with SIGINT
This is expected behavior for simulations which run forever.
2022-08-24 16:56:49 -07:00
John Demme 59661c8bbc
[ESI][Cosim] Switch from numeric IDs to strings (#3757)
Use the module instance path + an optional extension. Solves the multiple
instance problem.
2022-08-22 13:28:45 -07:00
Mike Urbach 342a1edf26
[FIRRTL] Extend register randomization to split up large registers. (#3748)
This now tracks when randomized registers exceed a threshold, and
splits them up into multiple registers. This is intended to work
around register size limits in simulators that may be exceeded by
using a single large register to hold all of the random bits for each
module.
2022-08-17 22:04:20 -06:00
Mike Urbach 261c5439af
[FIRRTL] Set the parameters for register randomization early. (#3714)
This adds a pass that collects all registers in each module, computes
how many bits of random data should be used to initialize them, and
saves this information for each module and register. In FirRegLower,
this is used to create one large random register per module, and
select out the appropriate bits for each register in the initial
block. This ensures the same large random register is created, and the
same bits are always selected for the same register, regardless of
optimizations that may remove registers.
2022-08-15 12:22:54 -06:00
Will Dietz 643b190703
[FIRRTL] Organize all existing types under FIRRTLBaseType. (#3666)
FIRRTLType is still base for all FIRRTL types,
but all current types are now under a new FIRRTLBaseType.

This makes it possible to add new (non-base) types to FIRRTL in the future.
2022-08-08 21:03:22 -05:00
Mike Urbach b706f4d78d
[Pipeline] Remove original PipelineOp and conversion. (#3685)
This representation and conversion aren't being used, and never
connected to Verilog output. The newer PipelineWhileOp could subsume
this use-case, and further evolution is coming to this dialect, so it
seems like a good time to clean out the older parts that aren't used.
2022-08-08 11:26:20 -07:00
Morten Borup Petersen b078252e67
[MSFT][NFC] Split MSFT passes into separate files (#3683)
Motivation:
1. This file is nearing 2000 LOC. I personally find that having a single file per pass helps in quickly navigating to/between implementations of different passes. Bunching everything into one file makes locating things just a bit harder.
2. This is the style used in the remainder of CIRCT.
3. Uses canonical CMake structure for declaring passes.
2022-08-08 19:41:59 +02:00
Martin Erhart 6e81996914
[ExportSystemC] Move pass from circt-opt to circt-translate (#3664)
Move to circt-translate because the pass does not modify the IR in any
way. Add basic code to emit each module or function to a separate file.
2022-08-05 20:28:48 +02:00
Will Dietz b5f763ff3f circt-reduce: avoid non-standard escape 2022-08-04 15:50:27 -05:00
Morten Borup Petersen b3359685c7
[StaticLogic] Rename dialect to 'Pipeline' (#3648)
It is probably fair to conclude that naming this dialect `StaticLogic` has been a pain point for a while. This commit proposes a dialect renaming to `Pipeline`, for a couple of reaons:

1. So far, we've only been working with pipeline abstractions within this dialect.
2. Pipeline representations aren't necessarily statically scheduled - we plan on adding switches to select between latency sensitive and latency insensitive lowerings of pipelines.

This name change does not preclude renamings in the future if we want to fit more stuff into this dialect. Personally, i think it is prudent to maintain a dialect name which reflects what's actually being done within the dialect, as well as the (near/mid/"someone actually intends to work on this"-term) future plans for the dialect.
2022-08-04 10:58:40 +02:00
Will Dietz 2be831fdb1
Update llvm::{Optional,FailureOr} uses to new methods (NFCI). (#3659)
Primarily:

getValue -> value
hasValue -> has_value

Value accesses not dominated by a presence check use 'value'.
(only use 'operator *' when clearly dominated by check)

"operator bool" and "operator *" used only when meaning was clear
(if variable looks like an integer, like getBitWidth(),
don't use operator bool unless the code already does so;
if returning result of a presence check prefer has_value, etc.)

Few places are slightly simplified, such as: using value_or,
avoiding calling same method for presence check and for the value,
and X.getValue().y -> X->y.

Fixes #3552.
(LLVM will be deprecating the old method names)
2022-08-03 21:29:41 -05:00
Nandor Licker 8b7f1ac966
[SV][Seq][FIRRTL] Lowered FIRRTL registers to `seq.firreg` (#3191)
In `LowerToHW`, FIRRTL registers are lowered to the Seq register.
2022-08-02 19:36:13 +03:00
John Demme 482e0ff366
[PyCDE] Integration test for ESI Cosim (#3632)
Adding an end-to-end cosimulation loopback pycde-driven flow integration test with ESI services. It works!
2022-08-01 17:21:14 -07:00
Bea Healy 2c95a38a71
[LLHDToLLVM] Refactor conversion patterns of each dialect to separate files (#3599)
Moves Comb to LLVM and HW to LLVM conversions out of the LLHDToLLVM pass and into their own dedicated lowering passes, as proposed in #3539.

The methods convertToLLVMEndianess and llvmIndexOfStructField are also encapsulated here within a HWToLLVMEndianessConverter class, in order to allow easier re-use between different passes.
2022-07-29 12:29:32 +02:00
John Demme f45ba4426d
[ESI] [Integration tests] [Tests] Switch from 'rstn' to 'rst' (#3618)
Rst seems more common, but the integration tests and ESI use 'rstn'.
Switch to the more common 'rst'.
2022-07-28 10:55:58 -07:00
Will Dietz 6657b714cb
Fix -Wreturn-stack-address warnings (#3616)
Apparently using an interface like FModuleLike as the source
for a isa/dyn_cast causes these errors.

Workaround by grabbing the actual operation and checking that.
2022-07-28 07:43:58 -05:00
Julian Oppermann 6c0681e95c
[SSP][Scheduling] SSP dialect rationale and boilerplate. (#3558) 2022-07-26 09:35:53 +02:00
Martin Erhart fcb83079d8
[circt-reduce] Invert test exit code requirement (#3591) 2022-07-25 14:14:37 +02:00
Morten Borup Petersen 14ca56c139
[CalyxToFSM] Add CalyxToFSM conversion pass (#3213)
This commit represents a lowering pass for converting a Calyx control schedule (seq/if/while/enable) into an FSM representation. The FSM is embedded within the Calyx component, and references both the group symbols and cell SSA values.

The lowering method is a fairly straight forward conversion, which leaves plenty of canonicalization opportunities to remove redundant states in the generated FSM. However, doing it as presented in this PR lends itself to some very clean code (which I prefer, rather than prematurely optimizing during lowering) as well as meaningful naming of states (which i think is fairly important).
2022-07-21 18:54:37 +02:00
John Demme fdeaf90894
[CMake] Reduce number of deps (#3569)
Cull unnecessary dependences. Reduces the number of files which need to
be compiled for check-circt by ~20%. Compiles and links fine on my machine,
but we've had linking issues in the past, so this may be bumpy.
2022-07-20 17:37:24 -07:00
Andrew Young 275e45fd8e
[firtool] Add optimization option `-O [debug|release]` (#3553)
This adds an option to `firtool` to specify the optimizations at a large
granularity, with two `release` and `debug`. Right now, this just
customizes the value preservation flag. The use of a hook allows these
options to compose sensibly with the finer grained options, s the last
command line option specified overrides previous settings.
2022-07-20 11:20:53 -07:00
Martin Erhart 4069407da9
[SystemC] Add exporter skeleton (#3523) 2022-07-19 21:59:50 +02:00
Martin Erhart 93bc76e091
[circt-reduce] Try reductions on promising ops first (#3562) 2022-07-19 18:57:53 +02:00
Fabian Schuiki d1b5d33616
[reduce] Fix invalidated iterator in RootPortPruner
Add a missing `make_early_inc_range` when going through users of block
args and erasing them.

Fixes #3555.
2022-07-19 18:04:31 +02:00
Martin Erhart ae3d1acd19
[RFC] Add a dialect for SystemC emission (#3520) 2022-07-19 17:14:36 +02:00
Hideto Ueno 79f45c2b68
[LowerTypes] Add flags to refine aggregate preservation (#3490)
This PR modifies LowerTypes to specify types preserved by aggregate preservation, i.e. `-preserve-aggregate={none, 1d-vec, vec, all}`.
Implementation wise, `peelType` takes the enum and selectively lower types.
2022-07-18 19:14:50 +09:00
Hideto Ueno 893eccb2ad
[LowerToHW][FIRTOOL] Add an option to emit chisel asserts as sva (#3545)
This commit adds an option `emit-chisel-asserts-as-sva` to emit chisel
asserts as SVA assertions at LowerToHW. Users sometimes want to emit 
only SVA for verification purpose and therefore, this commit provides a
command line option to emit "ifElseFatal" style assertion as SVA.
2022-07-18 17:15:02 +09:00
7FM 655cb61abd
[HWArithToHW] Add lowering boilerplate (#3546) 2022-07-18 10:03:22 +02:00
Martin Erhart c33340a839 [FIRRTL] Adopt prefixed accessors
Another step towards #2006
2022-07-16 22:05:18 +02:00
Morten Borup Petersen 56a260a1d4
[FSMToSV] Add FSM to SV conversion pass (#3483)
This commit introduces an FSM to SV lowering pass, as well as some small modifications to the FSM dialect to facilitate the conversion. This initial version of the pass does not support transition action regions and variables.

The lowering style is fairly straight forward; two processes are emitted, one `always_ff` for state register inference, one `always_comb` for next-state calculation and output assignments.

e.g.:
```mlir
fsm.machine @top(%a0: i1, %arg1: i1) -> (i8, i8) attributes {initialState = "A", argNames = ["a0", "a1"], resNames = ["r0", "r1"]} {
  %c_42 = hw.constant 42 : i8
  fsm.state @A output  {
    %c_0 = hw.constant 0 : i8
    fsm.output %c_0, %c_42 : i8, i8
  } transitions {
    fsm.transition @B
  }

  fsm.state @B output  {
    %c_1 = hw.constant 1 : i8
    fsm.output %c_1, %c_42 : i8, i8
  } transitions {
    fsm.transition @A guard {
      %g = comb.and %a0, %arg1 : i1
      fsm.return %g
    }
  }
}
```
emits as
```sv
typedef enum {A, B} top_state_t;
module top(
  input        a0,
               a1,
               clk,
               rst,
  output [7:0] r0,
               r1);

  reg  [7:0]       output_1;
  reg  [7:0]       output_0;
      top_state_t next_state;
  wire top_state_t to_A;
  wire top_state_t to_B;
      top_state_t state_reg;

  assign to_A = A;
  assign to_B = B;
  always_ff @(posedge clk) begin
    if (rst)
      state_reg <= to_A;
    else
      state_reg <= next_state;
  end
  always_comb begin
    case (state_reg)
      A: begin
        next_state = to_B;
        output_0 = 8'h0;
        output_1 = 8'h2A;
      end
      B: begin
        next_state = a0 & a1 ? to_A : to_B;
        output_0 = 8'h1;
        output_1 = 8'h2A;
      end
    endcase
  end
  assign r0 = output_0;
  assign r1 = output_1;
endmodule
```
2022-07-16 21:57:24 +02:00
Will Dietz 095f9572de
firtool: register passes to fix use of `--mlir-print-ir-{before,after}` options (#3503)
Ensure the passes we use are registered before parsing the command line
options, so that options such as `--mlir-print-ir-before=` work.

Add test.

It would be better if we didn't have to worry about this,
("did we remember to register all the passes" / early loading)
but in the meantime these options are very helpful for debugging
large designs.
2022-07-12 09:40:29 -05:00
Fabian Schuiki 63a841ce6d
[reduce] Make instance-stubber remove unused modules
Improve the `InstanceStubber` reduction to properly remove modules that
become unused after an instance has been dropped. This now eagerly gets
rid of stubbed-out modules instead of relying on some later
canonicalization and operation pruning to do this.
2022-07-11 17:30:46 +02:00
Fabian Schuiki c468158ee3
[reduce] Add granularity control options
Add options to set a lower and upper bound on the granularity at which
reductions are applied to operations. The limit can be set based on the
number of operations processed at once, or the number of chunks into
which the input is subdivided. This allows the user to perform coarse
passes over an input before advancing to more fine-grained reductions.

Also properly hides the MLIR/LLVM options from the default help page.
2022-07-11 17:30:46 +02:00
Fabian Schuiki 9d36ac8c64 [reduce][FIRRTL] Add eager inliner
Add a reduction that eagerly inlines modules. This should ideally be run
after the instance stubber and module externalization patterns, to avoid
a huge blow-up of the IR in case modules are multiply instantiated. But
as @darthscsi observed, removing hierarchy usually has a very beneficial
effect on reduceability.
2022-07-11 17:30:26 +02:00
Fabian Schuiki 86356fb470 [reduce][FIRRTL] Add wire removal pattern
Add a reduction pattern which replaces wires with the connected value.
This tends to be more aggressive than the canonicalizer and happily
nukes wires that may be marked as to be preserved for user inspection.
2022-07-11 17:30:26 +02:00
Morten Borup Petersen 5eba26e411
[HWArith] HWArith dialect rationale and boilerplate (#3456)
Please refer to RationaleHWArith.md.
2022-07-11 11:04:44 +02:00
Fabian Schuiki 5665ac7d90
[reduce] Improve reduction summary display
Improve the progress summary printed by `circt-reduce` by making it
actually end in a newline, adding additional information, and properly
overwriting the previous summary if no other output has been printed in
the meantime.
2022-07-07 15:21:02 +02:00
Tynan McAuley c8d4ab9bed
Fix code/comment typos (#3482) 2022-07-07 01:23:24 -04:00
Hideto Ueno ba8142d7bf
[Transform] [FIRTOOL] Add an pass to strip file locators with "fir" suffix (#3122)
This implements `-strip-fir-debug-info` option (enabled by default) to drop source locators of fir files
just before ExportVerilog emission. The pass StripDebugInfoWithPred is similar to StripDebugInfo
pass, but StripDebugInfoWithPred selectively strips locations using given predicate.
2022-07-06 21:12:32 +09:00
Andrew Young 817f00c7ea
[FIRRTL] Move all name preservation logic into the drop names pass (#3397)
This change moves more logic related to name preservation into the
DropNames pass.  The parser no longer determines if names should be
droppable at parse time, it always creates wires and registers with
`interesting_name`s.

The drop names pass used to unconditionally mark all operation as
"droppable_name"s when run.  The `DropNames` pass now takes a parameter
if it should preserve everything, nothing, or only things with meaningful
names.

I think that there is a problem with our current naming of "name
preservation": it is not about whether the "name" is preserved or
dropped, it describes whether a wire or register should be preserved or
dropped.  For this reason I think it makes more sense to refer to it as
"value preservation". As the first step toward moving the focus , I
changed the command line option of `firtool` from `-drop-names` to
`--preserve-values=[none | named | all]`.  Alternatives suggestions
welcome!

In the future, I think it would make sense to change the enum attributes
`interesting_name` to `preserved` and `droppable_name` to `droppable`.

This also changes firtool to mark all values droppable by default.
2022-06-30 09:42:42 -07:00
Schuyler Eldridge fe4ae458be
[FIRRTL] Remove SubAnnotationAttr (#3451)
Remove all logic related to handling SubAnnotationAttr inside FIRRTL
Dialect passes, utilities, and tools.  This is work towards fully
removing SubAnnotationAttr.

Remove the (now unused) SubAnnotationAttr.  This has been, in prior
commits, fully replaced with a "circt.fieldID" field that is added to
annotations which apply only to part of an aggregate.  This was done
because "circt.fieldID" is viewed as a lighter weight solution that
avoids the need for constant special casing of different "types" of
annotations, i.e., is this a dictionary or is this a SubAnnotationAttr.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-06-30 12:37:40 -04:00
Will Dietz b88c86c703
firtool: Avoid copying strings in loops. NFC. (#3445) 2022-06-29 19:44:45 -05:00
Prithayan Barua a975f08e0e
[FIRRTL] Replace SymbolNameAttr with a new InnerSymAttr (#3418)
This commit creates a new Attribute `InnerSymAttr` for inner_sym and replaces
 the `SymbolNameAttr` with `InnerSymAttr`.
 
The `InnerSymAttr` contains a single field `StringAttr` for the inner_sym name.
The plan is to extend the `InnerSymAttr` to specify symbols per field of an
 aggregate type, and also specify public/private visibility for each symbol.

Every `FIRRTLOp` that has the `InnerSym` trait, now has the `InnerSymAttr`
attribute. Also update the builders to either take the new attribute or
 convert a `StringAttr` to `InnerSymAttr`

Majority of the changes in this commit is to create an `InnerSymAttr`
 from a `StringAttr`.
2022-06-29 09:04:00 -07:00
Andrew Lenharth b523e45e1e [FIRTOOL] enable comb cycle checking by default 2022-06-29 08:22:52 -07:00
Richard Xia 725bc9a573 Fix SCF include paths. NFC.
The file was moved in upstream MLIR in
8b68da2c7d97ef0e2dde4d9eb867020bde2f5fe2.
2022-06-24 11:37:32 -07:00
Richard Xia acc005cc74 [CMakeLists] Match changes to upstream MLIR target names. NFC.
e16d13322b2617843511aebb29a502166824b07a renamed the MLIR
dialect-related targets to MLIR*Dialect, so all of CIRCT's CMakeLists
files need to match.
2022-06-24 11:37:32 -07:00
Morten Borup Petersen 9d8a8eeac8 [PyCDE] Add .py ext to py-split-input-file to make Windows happy 2022-06-17 14:13:46 +02:00
Hideto Ueno 0e1ea37e9c
[FIRRTL] Add inter-module DCE (#3324)
This pass performs inter-module liveness anaysis and deletes dead code
aggressively. A value is considered as alive if it is connected to a port
of public modules or a value with a symbol. We first populate alive values
into a set, and then propagate the liveness by looking at their dataflow.
The framework is almost same as IMCP except that lattice has two states
(knownAlive, assumedDead) and direction of propagation is opposite.
2022-06-17 01:56:42 +09:00
Morten Borup Petersen b7f6d475fd
Add py-split-input-file for better python test support (#3356)
Writing failing tests for PyCDE code gets cumbersome, quickly, without --split-input-file behaviour like we're used to in opt tools.
This commit adds a small python script which splits an input file based on a split token (# -----) and executes each split separately, catching any exceptions which might be thrown.
2022-06-15 19:56:13 +02:00
Hideto Ueno 35504ae329
[firtool] Rerun DropNamesPass after running middle-end passes (#3315)
Middle-end passes might introduce operations with interesting names so this
commit adds another instance of DropNamesPass so that we can clean up them.
2022-06-09 12:41:04 -07:00
Hideto Ueno b1d0aacb8a
[FIRRTL] Add DropNamesPass (#3254)
This commit adds a pass `DropNamesPass` to change names to droppable
in order to disable name preservation. The pass walks `FNamableOp` and 
drop their names. This pass should be executed in the very early pipeline 
so that other passes can get more freedom about their names.
2022-06-09 19:02:54 +09:00
Hideto Ueno 8d5891f708
[FIRRTL] Split name preservation semantics into a dedicated attribute (#3247)
This PR adds NameKindAttr to explicitly represent name preservations of node, wire and register ops. Previously, `name` is directly used to represent the preservation kind (useless or interesting name) but it would be nicer to have the information explicitly, considering that name attributes are used as SSA names too. NameKindEnum has two elements, `InterestingName` and `DroppableName`. `InterestingName` must be preserved. 

Example:
```scala
circuit Foo:
  module Foo:
    input a: UInt<1>
    node b = a
    node _c = a
```  

Parse only output:
```mlir
 firrtl.module @Foo(in %a: !firrtl.uint<1>) {
      %b = firrtl.node  %a  : !firrtl.uint<1>
      // same as %b = firrtl.node interesting_name %a: !firrtl.uint<1>
      %_c = firrtl.node droppable_name  %a  : !firrtl.uint<1>
 }
```
2022-06-09 16:59:36 +09:00
Hideto Ueno 5feec4085b [circt-reduce] Propagate names in `ConnectSourceOperandForwarder`
This commit changes ConnectSourceOperandForwarder to propagate
names of forwarded values.
2022-06-02 15:59:01 +09:00
Andrew Young 5613fffdaf
[FIRRTL] rename `mem-to-regOfVec` to `firrtl-mem-to-reg-of-vec` (#3205)
This adds the `firrtl-` prefix to the beginning of the command line
option for this pass, so that we keep our dialect passes namespaced.

I found the use of capital letters in the command line option to be a
unconventional, so I spread it out to the significantly longer
`firrtl-mem-to-reg-of-vec`.  In the future maybe we can think about
renaming this pass.
2022-05-26 12:49:40 -07:00
Andrew Young 5c1a2402aa
[FIRRTL] Remove unused BlackBoxMemory pass (#3187)
The `BlackBoxMemory` pass was an earlier implementation of SFC's
`ReplaceMemMacros` and has since been totally superseded by the newer
`LowerMemory` pass.
2022-05-25 15:29:58 -07:00
Andrew Young 658d3afe46
[firtool] Only blackbox SRAMs when `-repl-seq-mem` is specified (#3184)
Due some hasty changes when we realized that `MemToRegOfVec` transform
should not lower all memories, we started blackboxing seq mems which
we shouldn't be.  We need to make sure that the `LowerMemory` pass is
gated on the `repl-seq-mem` flag in firtool, which will allow SRAMs to
be lowered to generated memory modules instead of blackboxes.
2022-05-24 13:15:35 -07:00
Will Dietz 56196d490f
[FIRRTL] basic support for subcircuit signal driving flows (#3153)
* [FIRRTL] basic support for subcircuit signal driving flows

This is handled with a two-step flow:

* main.fir + subCircuit.json --(firtool)--> (normal output) + sigdrive.json (new)
* subcircuit.fir + sigdrive.json --(firtool)--> (normal output)

The new test in 'subcircuit-flow' demonstrates this in action.

There are many limitations, this is meant to just be enough to
support some specific existing use cases only.

See PR for more details.
2022-05-24 13:47:32 -05:00
Schuyler Eldridge 56c6f046b9
[FIRRTL] GCT View Scattering in LowerAnnotations (#3141)
Change firtool to always run LowerAnnotations.  Remove the "--new-anno"
option to conditionally run LowerAnnotations.

Move all logic related to Grand Central (GCT) view annotation scattering
from FIRAnnotations into the LowerAnnotations pass.  In this commit
there are difficult to spot changes to parseAugmentedType and
applyGCTView functions (where the latter is extracted from the body of a
method inside FIRAnnotations):

1. Functions now use ApplyState instead of parameters passed to the
   functions.

2. Any scattered annotations are handled by using ApplyState's ability
   to add annotations to the worklist.  E.g., parseAugmentedType will add a
   new annotation to the worklist for every ground type leaf.

Co-authored-by: Will Dietz <will.dietz@sifive.com>
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-05-24 11:04:48 -04:00
sinofp b7e1ad378e
[ExportVerilog] Include Build Information in Output Files (#2613)
This PR adds a functionality to include build information in output files. 
The format of the version string is  `<releases tag name>-
<how many commits since the tag>-g(means git)<current commit hash>[-dirty]`

Two cmake flags are added to control version strings, 
`CIRCT_RELEASE_TAG_ENABLED` (default is On) and 
`CIRCT_RELEASE_TAG` (default is `circtorg`). 
If `CIRCT_RELEASE_TAG_ENABLED` is false, the version string becomes 
"unknown" and cmake script is ran only at the first cmake configuration.  Example,
 
```
$ cmake .. -DCIRCT_RELEASE_TAG=pycde
// Generated by CIRCT pycde-0.0.5-28-ge846cf26e
module Bar(

$ cmake .. -DCIRCT_RELEASE_TAG=sifive
// Generated by CIRCT sifive/0/9/0-31-ge846cf26e
module Bar(

$  cmake .. -DCIRCT_RELEASE_TAG_ENABLED=Off
// Generated by CIRCT unknown git version
```

Co-authored-by: Hideto Ueno <uenoku.tokotoko@gmail.com>
2022-05-24 02:31:08 +09:00
Chris Gyurgyik 6e518751cc
[SCFToCalyx] [StaticLogicToCalyx] Separate lowerings to Calyx. (#3155)
Begin transition to separating the SCF and StaticLogic conversions to Calyx.
2022-05-20 15:53:56 -07:00
Nandor Licker 72838a205c
[Seq] Moved pass definition to a separate header (#3143)
Moved the definiton of `Seq` passes to a separate `SeqPasses.h`, similarly to other dialects.
Exposed the `createSeqLowerToSV` function to be used by other clients.
2022-05-19 10:42:27 +03:00
Schuyler Eldridge ba532693bc
[FIRRTL] Composable LowerAnnotations (#3129)
* [FIRRTL] Remove all-or-nothing LowerAnnos

Change the behavior of the LowerAnnos pass to work with existing
annotation scattering.  Previously, use of the `--new-anno` firtool
flag (and backing FIRParser option) would cause ONLY the LowerAnnos pass
to be used.  This changes that to use normal scattering and then apply
LowerAnnos.  This is done to enable piecemeal migration of scattering
work into LowerAnnos.

* [FIRRTL] Make LowerAnnos search non-standard attr

Change the LowerAnnotations pass to only process annotations from a
non-standard attribute on the circuit with key
"annotationsForLowerAnnotations".  This is done to enable the
LowerAnnotations pass to be run _after_ normal annotation processing
inside FIRAnnotations and FIRParser.  This then enables us to migrate
annotations one-by-one from FIRAnnotation/FIRParser handling (by moving
the annotation into "annotationsForLowerAnnotations").  This commit does
not put any annotations into this area for processing.  That will be
handled by subsequent commits.

* [FIRRTL] Add LowerAnnos passthrough in Parser

Modify the FIRRTL parser to let annotations that come in with the key
"annotationsForLowerAnnotations" to be placed in an attribute on the
circuit with this key.  This is currently unused infrastructure that
lets annotations inside FIRAnnotations be put behind this key to let
them be handled by the LowerAnnos pass.

* [FIRRTL] Add isAnnoClassLowered util, NFC

Add a utility, isAnnoClassLowered, that returns true if an annotation
class name is known to be handled by the LowerAnnotations pass.  This
effectively leaks internal information from the LowerAnnotations-defined
table of known annotations to let parsing/scattering logic know that
these annotations will be handled later.

* [FIRRTL] Skip LowerAnnos Annos During Parsing

Modify the Annotation parser to NOT handle annotations that are known to
LowerAnnotations.  This is done to enable seamless migration from
annotation handling in the parser to annotation handling in
LowerAnnotations.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-05-17 17:34:34 -04:00
Andrew Young 173962b8d0
[FIRRTL] Produce pre-extract seqmem metadata (#3123)
The metadata for seq_mems.json needs to be created before extract
instances runs, since it needs the original paths to the memory
operations.

This PR reverts the recent improvement to metadata emission, which used
symbols to ensure that the metadata reflected changes in the hierarchy.
It also modified the CreateSiFiveMetadata to pass to be able to run
before BlackBoxMemory. This just involved adding one extra annotation
to the list of known BlackBoxReader annotations.

Eventually, we will be getting rid of this particular piece of metadata, and
replacing it with OM.
2022-05-13 10:41:45 -05:00
Prithayan Barua b92396367a
[FIRRTL] Exclude testbench memories from MemToReg, and preserve MemOp (#3098)
Run the MemToRegofVec transformation only on DUT memories and ignore any
 modules in the testbench. Also retain MemOps marked with
 `ExcludeMemFromMemToRegOfVec` annotation.
LowerMemory pass should not error out on CombMems, but just retain them to be
 lowered by HWMemSimImpl to registers.
2022-05-11 00:15:39 -07:00
Andrew Young e4ecc625a0
[FIRRTL][CreateSiFiveMetadata] Base metadata on FMemModules (#3069)
This changes the memory-related metadata emitted by this pass to be
created from FMemModules instead of MemOps. The memories will have
already been lowered into modules. The pass can be simplified because
it no longer has to worry about deduplicating the memories itself.
2022-05-10 14:03:48 -07:00
Morten Borup Petersen fdc98b1e9c
[FSM] Implement graph traits for `fsm.machine` (#3073)
Initial implementation of LLVM graph traits for an FSM machine operation. This will most likely be a useful piece of code for building further transformations, visualizations, ... upon.
2022-05-10 09:30:29 +02:00
Prithayan Barua 26276bfc85
[FIRRTL] Add the Mem to Registers transformation (#3039)
This commit adds the MemToRegOfVec transformation to the FIRRTL pipeline.
This transformation converts all comb memories, to registers.
The mem tap and Async reset transformation are also updated to align 
with this transformation. 
(More details in the updated FIRRTL doc)
This transformation is enabled by default.
2022-05-09 22:03:02 -07:00
Andrew Young 8b559e45cd
[FIRRTL] Add LowerMemory pass (#3065)
This adds a pass to lower memory ops into instance of the new
FMemModuleOps.
2022-05-09 19:37:19 -07:00
Andrew Young 73f12d480f
[FIRRTL] Add AddSeqMemPorts pass (#3064)
This adds a new FIRRTL transformation which looks for
`AddSeqMemPortsAnnotation` and attaches the extra port specified to all
SRAMs under the DUT. The extra ports are always of type UInt<> with a
user specified width. The extra ports are wired up through the top of
the DUT and tied off to 0 in the testharness.

This pass requires that memories have been lowered to modules, and will
emit an error if it finds a regular mem op in the module. This is
because it is not possible to add arbitrary ports to a `mem` op that don't
match the schema of a memory `r`/`w`/`rw` port.
2022-05-09 19:36:57 -07:00
Christian Ulmann 185a943475 [handshake-runner] Add support for tuple operations
This commit introduces tuple types to the handshake runner. Tuple values
are represented as vectors of values.

Tuples can be feed to the handshake runner by using the `"(val1, ...,
valN)"` syntax.
2022-05-09 17:02:31 +02:00
Mike Urbach 4d26da9746
[FIRRTL] Add output-mlir option to firtool. (#3052)
This works similarly to output-omir: if specified, the final MLIR is
written into this file. This is useful to get the final MLIR output
alongside some other output, especially split-verilog.

This would close https://github.com/llvm/circt/issues/2946.
2022-05-08 21:39:08 -06:00
Andrew Lenharth 6f550cb956
Preserves FIRRTL names (#3050)
This does a simple wire preservation. This means:

nodes and wires become wires if they have names
names that don't start with '_' are preserved
names don't block constant propgation, but do block deleting wires.
2022-05-06 22:52:10 -05:00
Prithayan Barua b4ad9b98b2
[FIRRTL] Move extractInstance pass before GCT (#3060)
This commit moves the ExtractInstances pass before the GCT passes.
GCT passes can embed the instance paths into Verbatim ops, which can later be
 updated by the ExtractInstances pass, causing incorrect instance paths being
 generated into the verilog.
This commit should fix that bug with invalid instance paths.
2022-05-06 16:21:57 -07:00
Fabian Schuiki 30dad68da3
[FIRRTL] Add ExtractInstances pass (#3017)
Add a `ExtractInstances` pass which implements a combined version of the
Scala `ExtractBlackBoxes`, `ExtractClockGates`, and `ExtractSeqMems`
passes. The pass is split into two phases:

As a first step it traverses modules and instances in the design and
marks the ones appropriately annotated for extraction.

In a second step it repeatedly pushes the marked instances up one level
of the hierarchy until they reach the desired parent module (usually
indicated with a `MarkDUTAnnotation`). The extracted instances are then
optionally grouped into a submodule at their extracted location. Finally
the pass also emits a text file indicating where the extracted instances
were originally located in the design.
2022-05-06 09:02:58 +02:00
Schuyler Eldridge a9f6e33314
[LowerToHW] Remove Non-const Async Reset Check
Remove a check that asynchronous reset registers are only reset to
constant values from the LowerToHW conversion.  This check has been
moved into the SFCCompat test.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-05-05 15:03:31 -04:00
Schuyler Eldridge a13978527e
[FIRRTL] s/RemoveInvalid/SFCCompat/, NFC
Change RemoveInvalid pass (yet again) to be called SFCCompat.  This
better reflects that this pass is currently and will be later changed to
be where SFC compatible modifications or checks live.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-05-05 10:28:42 -04:00
Will Dietz ba79554f38
[FIRRTL] remove partialconnect (#3027)
Primarily, this removes PartialConnectOp!

Also adds type checking for partialconnect's in parser.

See PR for details/individual commits.
2022-05-04 13:00:14 -05:00
Will Dietz 61e5d42e6b
circt-reduce,firtool,llhd-sim: cleanup --help output, put options in category (#2979)
* circt-reduce: cleanup --help output, put options in category

Hides unrelated options from LLVM+co, and makes it easier
to find the most relevant options at glance.

When building CIRCT against LLVM built as shared libraries
(as preferred by many Linux distributions) this greatly
reduces the number of options printed.

* firtool: cleanup --help output, put options in category

Hides unrelated options from LLVM+co, and makes it easier
to find the most relevant options at glance.

When building CIRCT against LLVM built as shared libraries
(as preferred by many Linux distributions) this greatly
reduces the number of options printed.

* llhd-sim: group llhd-sim options in --help output

Hides unrelated options from LLVM+co, and makes it easier
to find the most relevant options at glance.

When building CIRCT against LLVM built as shared libraries
(as preferred by many Linux distributions) this greatly
reduces the number of options printed.

Even for the statically linked version more commonly used
with CIRCT, the help output is significantly reduced.

* llhd-sim: touchup optimizationLevel cl::opt to be static (NFCI)

* test/llhd-sim: Add commandline test

* circt-reduce: check categories in help test

* firtool: check categories in help test

* firtool: add new option to mainCategory too
2022-05-03 16:02:57 -05:00