Commit Graph

325 Commits

Author SHA1 Message Date
Richard Xia d8d7153320
[HWExportModuleHierarchy] Directly emit JSON to a file instead of an sv.verbatim op. (#1931)
* [Support] Factor appendPossiblyAbsolutePath() into lib/Support.

This was duplicated between ExportVerilog.cpp and BlackBoxReader.cpp,
but it is a generally useful utility function.

* [HWExportModuleHierarchy] Directly emit JSON to a file instead of an sv.verbatim op.

Previously this pass created an sv.verbatim op with the entirety of the
module hierarchy JSON file embedded into it, with the expectation that
the --split-verilog mode of firtool would actually be the one to create
it. This is now problematic because we'd like to move name legalization,
into the ExportVerilog pass, which means module names could change after
ExportVerilog runs.

Moving the HWExportModuleHierarchy pass after ExportVerilog guarantees
that names match the final verilog, but that means that
HWExportModuleHierarchy may no longer rely on the sv.verbatim op
output_file method to actually emit the file.

This commit changes HWExportModuleHierarchy to directly write the module
hierarchy JSON files. Note that firtool will now only run the
HWExportModuleHierarchy pass when --split-verilog mode is enabled, since
we now only want to run it when we have an output directory to dump
files to.
2021-10-05 16:53:00 -07:00
Chris Lattner 28b5a881c1 Various code cleanups, NFC.
Clean up some tblgen files and wrap to 80 columns, delete some commented out
code, and improve the export verilog pass names.
2021-10-04 22:30:45 -07:00
Chris Lattner 1a6961434b [firtool] Move createHWExportModuleHierarchy back ahead of VerilogEmission.
I misunderstood how this worked and accidentally broke it: it isn't printing
anything itself, it is mutating the IR and having verilog emission print its
output.
2021-10-04 21:46:24 -07:00
Chris Lattner 1cfa8710ce [CombFolds] Work around (my) bug in APInt::concat.
This was exposed building a large core.  I will fix this and add
a regression test upstream.
2021-10-04 18:12:22 -07:00
Chris Lattner 910ee76fbd [include/circt/Conversion] Flatten out a level of directories, NFC.
Move singleton headers like circt/Conversion/LLHDToLLVM/LLHDToLLVM.h
up to circt/Conversion/LLHDToLLVM.h since that is the only thing in that
directory.
2021-10-04 16:29:31 -07:00
Chris Lattner 0de4aac499 [ExportVerilog] Move into Conversions/ tree.
ExportVerilog was an outlier living as the only child of the Translations
tree, move it into Conversions to be more similar to other passes.
2021-10-04 16:24:12 -07:00
Chris Lattner 93b4f3564f [ExportVerilog] remove support for circt-translate, use circt-opt instead. 2021-10-04 11:58:51 -07:00
Chris Lattner a1c27c6528 [firtool] Switch to using ExportVerilog as a pass.
This also moves HWLegalize*Names next to it, in preparation for it being
slurped in.  This, in turn, allows us to run it before
HWExportModuleHierarchy pass.
2021-10-04 11:23:34 -07:00
Chris Lattner ffea59251e [ExportVerilog] Start moving ExportVerilog to being a pass.
ExportVerilog was initially conceived as a translation that read the
IR and printed out verilog text.  However, it evolved to being a pass
that mutates the IR (e.g. its prepare pass).  As such, it makes more
sense to model it in CIRCT as a transformation: we want to be able to
run passes after it in the pass pipeline, e.g. to generate metadata.

This takes one step towards that, adding new entrypoints that make it
available in circt-opt.
2021-10-04 11:21:06 -07:00
Schuyler Eldridge 36a3253887
Object Model 2.0, Part 1: Read in OM 2.0 (#1915)
Add a new option to firtool, "--omir-file <file>", which will parse an
Object Model 2.0 JSON file into an OMIRAnnotation.  This only handles
parsing.  No scattering is performed.

Add one test that the "--omir-file <file>" option used to ingest an
Object Mdoel 2.0 JSON file works for firtool.  Check that the
information in the OMIR is preserved and is wrapped in an
OMIRAnnotation on the circuit.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-10-01 20:55:54 -04:00
Fabian Schuiki 51c9985c20
[FIRRTL] Add first implementation of EmitSignalMappings (#1665)
Add a first implementation of Grand Central's `EmitSignalMappings` pass,
which populates a module in a circuit with `force` statements and
cross-module references that access things in a second circuit. This 
requires a lot of polishing and ironing out of kinks and the design in 
general later, but this is a first bare-bones implementation in the 
spirit of the other Grand Central passes (use verbatim SV to get 
something going, even if it's brittle and needs some cleaning up later).

To avoid having to deal with the issue that `EmitSignalMappings` 
actually operates on two circuits in parallel, the current 
implementation only operates on the circuit where the `force` statements
are to be inserted, and uses some text manipulation to guess what name 
the forced/probed things in the remote circuit will end up having in the 
output Verilog. This will need proper XMRs in the future, but works as a 
first shot.

Co-authored-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-09-30 10:16:44 +02:00
Morten Borup Petersen 0f9ec1249f [HandshakeRunner] Remove commented-out code 2021-09-29 11:12:56 +01:00
Morten Borup Petersen fca7f273cd [HandshakeRunner] Rename "toplevelFunction" argument to "top-level-function"
We dont usually use camel case in clang/mlir arguments.
2021-09-29 11:09:52 +01:00
Morten Borup Petersen b454861b75 [HandshakeRunner] Use op->emitError instead of asserts 2021-09-29 10:58:02 +01:00
Morten Borup Petersen 1e4ee719e5 [HandshakeRunner][NFC] Use preincrement where applicable 2021-09-29 10:19:23 +01:00
Morten Borup Petersen f2fd3c04be [HandshakeRunner][NFC] Use `enumerate` where applicable 2021-09-29 10:17:22 +01:00
Morten Borup Petersen bbdf4b3914
[Handshake] Refactor handshake runner to be visitor based (#1821)
This commit refactors the handshake-runner to be based on a visitor pattern rather than manually checking for the type of each possible operation. The commit takes a step towards reducing the code duplication between executing a mlir::FuncOp and handshake::FuncOp. Many more opportunities for cleanup and refactoring exists, however, I decided to focus on wrapping the existing code into a visitor for this commit.
2021-09-29 10:03:59 +01:00
Andrew Young 578b569d65 [FIRRTL] Rename EmitMetadata to CreateSiFIveMetadata
Since this is creating verbatim operations instead of emitting files
directly, `create` makes more sense as a verb.

Since the metadata emitted is specific to SiFive build flows,  this
renames the pass to make it clear that it is not generically useful.
This leaves the pass on by default since the pass will only do anything
if the correct annotations exist.

This change was suggested here:
https://github.com/llvm/circt/pull/1875#discussion_r716070526
2021-09-27 11:42:15 -07:00
Andrew Young 2bd1858dee [FIRRTL][EmitMetadata] Add SitestBlackBox metadata support
This adds another metadata emitter.  This purpose of this pass is to
collect every blackbox module (or extmodule) which will need to be
stubbed or filled in. This excludes blackbox modules which have inlined
or imported verilog.

There are two separate metadata files generated for this: one for
blackboxes instantiated under the DUT as denoted by the
MarkDUTAnnotation.  The other is a list of blackboxes not instantiated
under the DUT.
2021-09-24 12:53:09 -07:00
mikeurbach 82b9de0f35
[Analysis] Add a DependenceAnalysis for checking memory accesses. (#1845)
This is currently a simple class that traverses pairs of Affine memory
access operations and uses the upstream `checkMemrefAccessDependence`
function. The results are stored in a convenient data structure that
can be queried to inform scheduling decisions. A test pass is added,
which outputs the results as attributes for verification.
2021-09-23 15:47:41 -06:00
Andrew Lenharth c4ac7b8fb5
Annotation Scattering and trivial processing Pass (#1808)
Add a pass to handle all annotation scattering. This pass is table driven, with customizable scattering per-annotation-class. When this is fleshed out, it will replace the annotation handling code in the parser.

Right now, this supports a couple testing annotation to make test cases against.

Until this is live in the pipelines, add an option to the parser to bypass annotation handling and scattering to enable testing.
2021-09-22 13:55:55 -05:00
Morten Borup Petersen e4731d4b5b
[SCFToCalyx] Add SCFToCalyx boilerplate [1/13] (#1812)
This is the initial commit for the SCFToCalyx pass. The commit sets up the boilerplate required for adding a new conversion pass.
2021-09-20 23:56:47 +01:00
Richard Xia e97cff3fd5
[SV][LowerToHW] Add ExportModuleHierarchy pass. (#1792)
* [LowerToHW] Lower mainModule and DesignUnderTest attributes into moduleHierarchyFile attribute.

Since these are currently only used for the export module hierarchy
pass, these have been replaced with a more generic attribute marking
which modules should have their hierarchies exported to output files.

* [SV] Add ExportModuleHierarchy pass.

This adds a pass that collects the full module hierarchy into a JSON
string, which is then exported as part of an sv.verbatim op. The pass
collects a hierarchy for each module with the firrtl.moduleHierarchyFile
attribute.

The pass can be enabled in firtool by providing the
--export-module-hierarchy option.
2021-09-18 12:14:58 -07:00
Andrew Young 50904ee377
[FIRRTL] Add PrefixModules pass (#1183)
This adds the prefix-modules pass to FIRRTL.  This pass looks for
modules annotated with the `NestedPrefixModulesAnnotation` and prefixes
the names of all modules instantiated underneath it. This pass will
duplicate modules as necessary to give submodules unique names. The
annotation can be attached to module definitions, as well as specific
instances.

The supported annotation is:
```json
{
  class = "sifive.enterprise.firrtl.NestedPrefixModulesAnnotation",
  prefix = "MyPrefix_",
  inclusive = true
}
```

If `inclusive` is false, it will not attach the prefix to target module,
only to modules instantiated underneath it.
2021-09-16 10:55:17 -07:00
Chris Lattner b6988dd725 [HW/FIRRTL] Rename ModulePortInfo to just "PortInfo" NFC.
This applies to both instances and modules, and the more verbose name
doesn't help anyway.
2021-09-12 21:18:41 -07:00
Andrew Lenharth ba9c344ace
[FIRTOOL] Allow multiple annotation files (#1674)
A build flow might have multiple annotation files. Allow passing them all.

Co-authored-by: Prithayan Barua <prithayan@gmail.com>
2021-08-31 09:08:45 -05:00
Hanchen Ye bbecc5fc2b
[FSM] Add an empty FSM dialect (#1671) 2021-08-30 17:28:46 -05:00
Martin Erhart 8b5f5e216b
[LLHD] Use integer, array and struct types from HW dialect (#1669)
* [LLHD] Use integer, array and struct types from HW dialect

* Simplify HWDialect declaration
2021-08-30 23:02:16 +02:00
Andrew Lenharth ec6cfbcdb1
[NFC][FIRRTL] FModuleLike to provide nicer-typed accessors for things you can take instance of (#1650)
Get rid of globals used to unify code for FModule and FExtModule and replace it with FModuleLike interface.
2021-08-30 10:16:43 -05:00
Morten Borup Petersen 5e3c116ce6 [Handshake] Rename dialect from "HandshakeOps" to "Handshake" 2021-08-28 09:03:30 +01:00
Morten Borup Petersen 036a2f2c54
[Handshake] Refactor inclusion of Handshake TableGen'erated files (#1648)
* [Handshake] Refactor handshake tablegen files

No functional changes; this commit creates an identical structure to the rest of the dialects in CIRCT wrt. how and where the various TableGen'erated files are included.
2021-08-28 09:01:10 +01:00
Martin Erhart f5055566f4
[LLHD] Use comb dialects ops where possible (#1649)
* [LLHD] Use comb dialects ops where possible

* Clang-format

* Remove redundant code

* Remove unused includes, add tests, remove redundant code
2021-08-28 08:39:06 +02:00
Chris Lattner 83f5500ac8 [firtool] Tidy up some logic, NFC.
No need for "else" after "return" etc.
2021-08-27 12:25:12 -07:00
Chris Lattner 648a7f3e95 [firtool] Refactor firtool.cpp, emit more specific --mlir-timing output.
Just pass down the output filename instead of a lambda, there is no
need for the extra abstraction here.  While here, change the timer
in the various flavors of output to be more specific than "Output".
2021-08-27 10:31:41 -07:00
Morten Borup Petersen 7eb47cf637
[Handshake] Support handshake.InstanceOp in handshake-runner (#1542)
* [Handshake] Support handshake.InstanceOp in handshake-runner

This commit adds support for executing handshake.InstanceOp operations in the handshake-runner.

This is enabled by mostly leveraging the existing executeHandshakeFunction function. When encountering an InstanceOp, a new value- and time map is created, representing the values accessible within the scope of the function referenced by the InstanceOp. In this map, associations between the operands passed to the InstanceOp and the SSA names of the arguments of the function that the InstanceOp references, are created. Return values from the InstanceOp are inserted into the valueMap of the enclosing (caller) scope.

Apart from this, made a slight modification to the structure of the handshake-runner; split up a few functions as well as added an enclosing class to reduce the number of arguments being passed around (i.e., the store, which is global across all std.op executions, InstanceOp executions, etc.).
2021-08-27 16:53:04 +01:00
Chris Lattner c6e386e601 [HWLegalizeModules] Give generated wires (somewhat) useful names 2021-08-21 17:25:01 -07:00
Andrew Young 0413d52355
[firtool] move BlackboxMemory before LowerTypes (#1618)
BlackBoxMemory creates modules with bundles types to replace memory
operations.  If this runs after LowerTypes, then we hit the LowerToHW
pass with a bunch of bundle types around.  This pass is not often used,
and this must have regressed at some point.

This also adds an integration test to ensure that CHIRRTL memories are being
properly lowered to verilog.
2021-08-21 15:29:04 -07:00
Chris Lattner 7ccdb3d8cc [hw] Introduce a HWLegalizeModules pass and a new `disallowPackedArrays` lowering option.
This pass provides a structured way to handle IR features that are not
supported by all tools, and this lowering option reflects a specific
limitation of the Yosys tool.

Right now the pass isn't super helpful: it just rejects unsupported operations
with an error.  This is progress towards Issue #1592.
2021-08-21 13:28:09 -07:00
Andrew Young 0a0ee65287
[FIRRTL] Implement SFC's RemoveCHIRRTL pass (#1540)
This adds an implementation of the RemoveCHIRRTL pass called
LowerCHIRRTL.  This pass takes the CHIRRTL memory operations, `seqmem`
and `combmem`, and transforms them into standard FIRRTL `mem`
operations.
2021-08-21 12:23:56 -07:00
John Demme 21485874c8
[llvm] Update submodule to latest (#1589)
Co-authored-by: Andrew Lenharth <andrew@lenharth.org>
Co-authored-by: Fabian Schuiki <fabian@schuiki.ch>
Co-authored-by: Andrew Young <youngar17@gmail.com>
2021-08-18 19:37:43 -07:00
Fabian Schuiki 0c0f314301
[firtool] Add --parse-only option (#1603)
Add a `--parse-only` option to `firtool` which causes the program to
stop after the FIR/MLIR and annotation input files have been parsed and
processed, and writes the resulting MLIR module to the output. This is
interesting and useful since `firtool` performs a unique combination of
input translation and annotation scattering that is not trivially
reproduced with `circt-translate` and `circt-opt`. Useful for test case
reduction.
2021-08-18 18:36:03 +02:00
Fabian Schuiki cacbaf7210
[reduce] Add a first proof-of-concept reducer implementation with sample FIRRTL dialect reducers (#1591)
- Update/rewrite the `circt-reduce` tool with a custom proof-of-concept
  reducer for the FIRRTL dialect. This is supposed to be a pathfinding
  exercise and just uses FIRRTL as an example. The intent is for other
  dialects to be able to produce sets of their own reducers that will
  then be combined by the tool to operate on some input IR.

  At this point, `circt-reduce` can be used to reduce FIRRTL test cases by
  converting as many `firrtl.module` ops into `firrtl.extmodule` ops as
  possible while still maintaining some interesting characteristic.

- Extend `circt-reduce` to support exploratively applying passes to the
  input in an effort to reduce its size. Also add the ability to specify
  an entire list of potential reduction strategies/patterns which are
  tried in order. This allows for reductions with big effect, like
  removing entire modules, to be tried first, before taking a closer
  look at individual instructions.

- Add reduction strategies to `circt-reduce` that try to replace the
  right hand side of FIRRTL connects with `invalidvalue`, and generally 
  try to remove operations if they have no results or no users of their 
  results.

- Add a reduction pattern to `circt-reduce` that replaces instances of
  `firrtl.extmodule` with a `firrtl.wire` for each port. This can
  significantly reduce the complexity of test cases by pruning the
  module hierarchy of unused modules.

- Move the `Reduction` class and sample implementations into a separate
  header and implementation file. These currently live in
  `tools/circt-reduce`, but should later move into a dedicated reduction
  framework, maybe in `include/circt/Reduce`, where dialects can easily
  access them and provide their own reduction implementations.
2021-08-18 17:22:43 +02:00
Fabian Schuiki c3573eed43
[FIRRTL] Add InferResets pass (#1304)
* Extract reset-related test cases from the existing Scala FIRRTL
  compiler code; specifically from `InferResets`, `CheckResets`,
  `RemoveReset`, and `FullAsyncResetTransform`.

* Add the `InferResets` transformation pass to the FIRRTL dialect, which
  assigns asynchronous resets to registers without reset, and replaces
  `reset` types with either `uint<1>` or `asyncreset`, as appropriate.

* Add the `--infer-resets` option to firtool, on by default.
2021-08-13 12:15:45 +02:00
Fabian Schuiki 3c6987ca74 [firtool] Run the canonicalizer after inlining/imconstprop
Inlining and IMConstProp generate additional opportunities for
canonicalization, especially around registers with invalid/constant
reset signals and values. To leverage these, firtool should run the
canonicalizer again just before going into the output-specific
pipelines.
2021-08-12 19:50:40 +02:00
Fabian Schuiki d6dcf37fcc [firtool] Add split-input-file and verify-diagnostics options
Add the `--split-input-file` and `--verify-diagnostics` options to
firtool. This brings it more in line with other tools such as circt-opt,
and simplifies writing integration tests against firtool.
2021-08-06 19:33:17 +02:00
Fabian Schuiki bff6411032 Add circt-reduce
Add a `circt-reduce` utility, which basically follows the "build a
custom mlir-reduce" steps described in the MLIR documentation. The
intent here is to have a first step towards a CIRCT-specific reduction
utility. At a later stage, we may want to start populating the reducer
framework with reduction patterns specific to CIRCT (like fan-in/-out
cone isolation, port removal, etc).
2021-08-04 13:19:48 +02:00
Chris Gyurgyik e1c6592852
[Calyx] Add CalyxToHW scaffolding. (#1502)
Adds scaffolding for a Calyx to HW conversion pass.
2021-08-03 18:34:11 -07:00
Hanchen Ye fefe356aab
[FIRRTL] Add a CheckCombCycles pass (#1388)
This pass runs a strongly connected components (SCC) detection to check
combinational cycles in the IR. The current implementation assumes the
firrtl-lower-types and firrtl-expand-whens has been applied before this pass.
2021-08-03 15:35:14 -05:00
Chris Lattner 242f1988c4 [FIRRTL] rename the parser entry points to "importFIRFile". NFC.
The previous names "importFIRRTL" were a bit ambiguous.  What this
really does is parse a .fir file into a firrtl dialect representation.
2021-07-31 09:48:13 -07:00
Andrew Young a1a0188f49 [firtool] Enable `-inline` by default
This turns on the FIRRTL inliner by default.  This pass has some
questionable behaviour where it will delete any module not reachable
from the top level module.  This is an optimization that prevents the
pass from performing uneccesary work, while not leaving unprocessed
modules in the code.  This is also the mechanism through which modules
which had all instances inlined will be deleted. We may want to decide
if this behaviour is desirable before merging this commit.
2021-07-22 20:07:30 -04:00
Hideto Ueno d284a97c4e
[NFC] Eliminate simple canonicalizer (#1454)
* eliminate simple canonicalizer

* small fix

* fix cmake

* remove circt/Transforms

* clang-format
2021-07-22 12:23:01 +09:00
Fabian Schuiki b0a6986b2b [FIRRTL] Merge CheckWidths into InferWidths
Merge the `CheckWidhts` pass into the `InferWidths` pass, which already
has all the necessary information to complain to the user about
uninferred widths. This commit also improves error reporting a bit by
tracking additional location information on the constraint expression
such that we can point the user at the sites where a connection may
cause problems.

Fixes #1297.
2021-07-16 18:44:21 +02:00
Andrew Young 65c72e5856
Disable llhd-sim tests when the executable is not built (#1425) 2021-07-14 18:42:45 -04:00
Andrew Lenharth 4f7c50791e
[FIRRTL] Replace Lower Types with new version. (#1421)
Rename new version and remove old version.
2021-07-14 13:08:05 -05:00
Andrew Young f4e3b236cb
[CMake] Fix incorrect file dependencies for configured files (#1397)
In a couple of places in our build system, we wanted to create targets
that depended on generated files. We were not passing the full path to
the generated files, e.g. `CosimScheme.h`, and CMake was unable to find
the it. CMake was then searching the current directory for a
matching file with a prefix, and would find the unprocessed
file, e.g. `CosimSchema.h.in`, and use that instead.  A policy change
CMP0115 in newer version of CMake causes this to spit out many warnings
about it how it will no longer search for source files. For more
information about the policy see
https://cmake.org/cmake/help/latest/policy/CMP0115.html

This change provides the full path to the generated file, which allows
cmake to find the intended file and not produce so many warnings.
2021-07-08 23:32:48 -07:00
Andrew Lenharth e0de28f0e2 [NFC] Fix options for lower types 2021-07-08 08:42:12 -07:00
Julian Oppermann 06c5ae9e98
[Scheduling] Provide an ASAP scheduler for the basic problem. (#1358) 2021-07-06 11:54:49 -07:00
Andrew Lenharth e5246fe83c
[FIRRTL] Rewrite LowerTypes with simpler structure (#1275)
Rewrite LowerTypes to simplify and improve performance.

Walks the operations in reverse order. This lets it visit users before defs. Users can usually be expanded out to multiple operations (think mux of a bundle to muxes of each field) with a temporary subWhatever op inserted. When processing an aggregate producer, we blow out the op as appropriate, then walk the users, often those are subWhatever ops which can be bypassed and deleted. Function arguments are logically last on the operation visit order.

Each processing of an op peels one layer of aggregate type off. Because new ops are inserted immediately above the current up, the walk will visit them next, effectively recusing on the aggregate types, without recusing. These potentially temporary ops (if the aggregate is complex) effectively serve as the worklist. Often aggregates are shallow, so the new ops are the final ones.

There is no global map. When you update an aggregate producer, you build a small vector of it's expansion, which you use to update it's users. Once the users of an aggregate are updated, there is no reason to store mapping data on them any longer.

This structure makes it relatively easy to to do connect-expansion and partial-connect-legalization along the way. connects get processed before their source and dest.

This gives a 40% improvement on a medium sifive core and hasn't been tuned yet.


Co-authored-by: Prithayan Barua <prithayan@gatech.edu>
Co-authored-by: Prithayan Barua <prithayan@gmail.com>
2021-07-06 11:36:54 -05:00
Prithayan Barua 0dca40bc75
[FIRRTL][LowerToHW]Emit warning on unprocessed remaining annotations (#1341)
Emit a warning after lowering `FIRRTL` operations to `HW` dialect, 
if there are `annotations` remaining on the `FIRRTL` operation.
This is required to detect missing passes in FIRRTL dialect to remove the annotations. 
The warnings are disabled by default.


- Use a set to record all the annotations remaining on different operations. 
- Emit a warning for each annotation only once. So if the same annotation is found on different operations, only one warning is emitted.
- Add an option to `LowerFIRRTLToHW` pass to enable the  warnings
  - The option is disabled by defailt
  - Use`emit-annotation-warning=true` to emit the warnings
- Add option `emit-annotation-warning` to `firtool` , which should be passed to `createLowerFIRRTLToHWPass`
- Note: The `emitWarn` will crash when trying to print the `InstanceOp`. Reason for crash:
    1. If we try to print the old `InstanceOp` operation while traversing the operations in a module, the symbol referring to the module is invalid. Hence `getReferencedModule` crashes. 
    2. The traversal is on the new temporary module body, which has moved(`splice`) the old operations,  https://github.com/llvm/circt/blob/main/lib/Conversion/FIRRTLToHW/LowerToHW.cpp#L825
    3. Seems like the original symbol on the operation gets deleted during the `splice`, hence the invalid  temporary IR. 
- To fix the crash, we don't print the operations by using `mlir::emitWarn`, and just print the source location.
- Use `std::mutex` when updating the `StringSet<> alreadyPrinted` in class `CircuitLoweringState`
  - `CircuitLoweringState` object is shared between threads working on modules, hence the lock is required when updating the set. (https://github.com/llvm/circt/blob/main/lib/Conversion/FIRRTLToHW/LowerToHW.cpp#L208)
2021-07-05 18:35:07 -07:00
Chris Gyurgyik c9226d32a5
[Calyx] Add scaffolding for passes. (#1370)
Adds registration and scaffolding for Calyx passes.
2021-07-05 14:40:25 -07:00
Chris Gyurgyik 5db02d71fb
Calyx dialect initial commit. (#1287)
* Initial commit for Calyx dialect (WIP).

* ws

* Remove empty test.

* Calyx component printing (cont)

* nit todo

* Mess around with components.

* Remove ops for scaffolding review.

* [obvious] Remove extra `-`s.

* Remove extra stuff.

* nits

* Address comments pt1.

* address comments pt2.

* Add Attrs.
2021-06-18 10:14:36 -04:00
Andrew Young 4a939ea312
[firtool] Move CSE very early (#1277)
CSE can work with full efficacy on IR without inferrred widths.
Moving it early improves WidthInferrence and LowerTypes performance.
2021-06-16 14:50:38 -07:00
Fabian Schuiki 77ea524da3
[FIRRTL] Add pass to handle grand central data and memory taps (#1178)
* Add a `GrandCentralTaps` pass which consumes the FIRRTL Grand Central
  data and memory taps annotations, and generates the corresponding
  blackbox data tap modules with hierarchical Verilog identifiers
  inside.
2021-06-16 20:04:41 +02:00
Schuyler Eldridge 6da2131b0f
Grand Central Interface Support (#1170)
* [FIRRTL] Add Grand Central Interface Support
* [FIRRTL] Add Grand Central Interface Tests

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-06-16 00:22:06 -04:00
Chris Lattner b6737713ad [firtool] Stop disabling multithreading for the parser. NFC.
We previously disabled multithreading when parsing the input file
to save cost on some mutexes etc, since the parser wasn't threaded.
Now however, the verifier is threaded, and disabling multithreading
is disabling it as well.

Just stop doing this.  This provides an aggregate speedup for me,
e.g. shrinking total firtool time from 29.9s to 26.7s on a large
design (18.6s -> 15.2s in the parser) which is a pretty big speedup.
2021-06-14 22:17:36 -07:00
Fabian Schuiki 1e99c0ac2d
[firtool] Enable width inference by default (#1242)
* Switch the `--infer-widths` option to run by default. The user can
  still disable the pass through `--infer-widths=false`.
2021-06-12 08:16:09 +02:00
Andrew Lenharth 3a179c4336 [FIRTOOL] unify format of cli options for passes [NFC] 2021-06-10 13:12:28 -05:00
Andrew Young c4b2257007
[FIRRTL] Rename Blackbox to BlackBox (#1227)
It was decided that "black box" should be consistently used as two words
in the code base. See #1209.
```
Blackbox     -> BlackBox
the blackbox -> the black box
```
2021-06-09 10:13:20 -07:00
Fabian Schuiki a2a92d7b75
Remove FIRRTLToLLHD pass
* Remove the `FIRRTLToLLHD` pass in favor of a separate lowering from
  FIRRTL to HW, and then from HW to LLHD.

* Fixes #1175.
2021-06-09 13:59:36 +02:00
Chris Lattner e73115d596 [firtool] Turn on -imconstprop by default.
To paraphrase Aliaksei over slack, "The people always wanted
imconstprop, what could possibly go wrong" 🙈

Admittedly, I might be paraphrasing that wrong.
2021-06-01 20:24:17 -07:00
Andrew Young 0f378b5f06
[firtool] Enable expand-whens by default (#1174)
This pass has been subjected to fuzz-testing for quite some time, and it
is surprising (in a negative usability sense) that it is not enabled by
default.

Some FIRRTL-to-LLHD tests were using firtool with uninitialized ports,
and this change switched them to use circt-translate instead.
2021-05-28 09:04:57 -07:00
Fabian Schuiki 5f6502c151
[firtool] Add blackbox resource search path option
* In addition to the `--blackbox-path` option which specifies the
  overall search path for black box files (including `BlackBoxPathAnno`
  annotations), add a separate `--blackbox-resource-path` option which
  only affects the `BlackBoxResourceAnno` annotations. These get moved
  into the Scala/sbt artifacts directory, and the resource path should
  generally point there. Path annotations in general will want to remain
  relative to the input FIR file, which this additional enables.
2021-05-27 09:27:24 +02:00
Andrew Lenharth 5046209ee3 [FIRTOOL] formatting 2021-05-26 15:58:19 -05:00
Andrew Lenharth 4dd1845152 [FIRTOOL] Add support for using an arbitrary root directory for blackbox searches. 2021-05-26 15:55:56 -05:00
Fabian Schuiki e539a7bcfb
[firtool] Move width inference before canonicalization (#1147)
* Move the width inference pass up in the pipeline such that it runs
  before the canonicalization passes. This is useful since width
  inference itself does not depend on canonicalization, but in turn
  enables a lot of canonicalization patterns to run.
2021-05-26 10:57:07 +02:00
Chris Lattner 12e2b8efb4 [firtool] really-don't-delete the ModuleOp before quitting. NFC.
This avoids running the destructor for the module before exiting the
firtool process, saving ~6% of "dark" runtime.
2021-05-24 18:19:46 -07:00
Fabian Schuiki 928e6fdb2d
[FIRRTL] Add black box reader pass (#918)
* Add the `BlackBoxReader` transformation pass which is modeled after
  the `BlackBoxSourceHelper` Scala implementation. It honors a set of
  FIRRTL annotations that declare source code for black boxes to be
  copied to an output directory. This pass reads those source files into
  an operation in the IR, such that they can be written to the output
  during emission. Annotation can be done inline, as a separate path, or
  the rather Java-specific resource mechanism.
2021-05-21 20:01:58 +02:00
Andrew Lenharth 15f1687a11 Fix some release and gcc warnings. [NFC] 2021-05-21 10:37:03 -05:00
Fabian Schuiki c10ca772f9
[firtool] Fix whitespace 2021-05-21 16:12:07 +02:00
Andrew Lenharth b4028edb19
enable lower-types by default (#1086) 2021-05-19 14:00:13 -05:00
Andrew Young 327dfb7aa6
Update LLVM (#1067)
Required changes:
- The vector namespace in MLIR was colliding with the std::vector type
- Missing MemRef dialect dependency in circt-opt
- Missing Standard dialect dependency in ExportLLHD
2021-05-18 15:04:12 -07:00
Chris Lattner 53b1c077d6 [RTL->HW] Rename C++ namespace, command line flags and a bunch of other stuff. 2021-05-15 14:33:45 -07:00
Chris Lattner 4d43103122 [RTL->HW] Rename the string "RTL" to "HW"
This makes sure not to rename FIRRTL to HWRTL :-), and I spot checked a
many things to avoid changing general references to RTL (e.g. when referring
to external tools) but I suspect that I missed some.  Please let me know (or
directly correct) any mistakes in this mechanical patch.
2021-05-15 12:44:05 -07:00
Chris Lattner 61e70086c6 [RTL->HW] Move a few more files in conversions and documentation. NFC. 2021-05-15 12:23:45 -07:00
Chris Lattner 91f77cf64b [RTL->HW] Move RTL directory structure/filenames to HW. NFC
This doesn't change the types or stuff declared in the file, just moves
things into place.
2021-05-15 12:07:47 -07:00
Chris Lattner c934a581ab [firtool] Change the firtool driver to exit() instead of return.
The difference is that we no longer run the dtor for the MLIRContext
that we parse a bunch of IR into.  This avoids spending time
deallocating memory, which is pointless immediately before process
exit.
2021-05-14 14:34:28 -07:00
Chris Lattner 22c4082c1b [firtool] Refactor the top level of the tool a bit, NFC. 2021-05-14 14:16:47 -07:00
Chris Lattner fb5390f064 [firtool] Make the -mlir-timing output of firtool a bit more explicit. 2021-05-14 12:47:29 -07:00
John Demme 99cd210a45
[circt-rtl-sim] Fix Verilator test driver for non-debug builds #1043 2021-05-12 12:11:40 -07:00
Fabian Schuiki 969dbfec75
[firtool] Add parser and output emitter timing (#816)
* Use the new `TimingManager` in MLIR to include the parser and output
  emitter in the timing statistics.

* Renames the `--pass-timing` option to `--mlir-timing`.

Fixes #608.
2021-05-12 21:05:28 +02:00
John Demme 16fe5fb1d7
[circt-rtl-sim] [Verilator] Compile with trace options when in Debug mode (#1041)
This incurs some cost in the generated simulator. Monitoring and saving the
waveforms to disk incurs yet more overhead, so enable this via an environment
variable.
2021-05-11 18:58:28 -07:00
Fabian Schuiki 2891bdfadc
[firtool] Run CheckWidths pass, add option for InferWidths (#1036)
* Run the `CheckWidths` pass when lowering to the RTL dialect to ensure
  there are no uninferred widths that will cause the lowering to fail.

* Add a `--infer-widths` option that runs the `InferWidths` pass.

Fixes #1032.
2021-05-10 20:03:54 +02:00
John Demme a9fb106319
[circt-rtl-sim] Run each simulation in its own directory (#1031)
Some simulators don't like being run in parallel in the same directory.  Also, reset the handshake tests to include all IEEE simulators.
2021-05-07 16:23:29 -07:00
Andrew Young 48b994e6ba
[FIRRTL] Add module inlining pass (#909)
The module inlining pass handles module flattening and instance
inlining.  Module flattening is recursively inlining every instance in a
module.  Module inlining is inlining only the instances of  modules
which are marked for inlining.
2021-05-05 22:48:42 -07:00
Chris Lattner ac491f9a37 [firtool] Wire the PrettifyVerilog pass into firtool when exporting verilog. 2021-05-05 10:49:37 -07:00
mikeurbach 880eb40530
Update LLVM to 4dfddf715b94857998601aa79c25e4f327d44dfa. (#972)
This includes a couple breaking changes:
* AttrDef has a new argument for attribure traits.
* Several includes we depended on appear to have been moved to forward
declarations, so add the explicit includes we needed.
2021-04-28 14:51:27 -06:00
Fabian Schuiki 1696f2c129
[ExportVerilog] Add file list output (#953)
* Stop generating stub files for external modules when split Verilog
  output is enabled. This will collide later with black box annotations
  supplying the actual files to be included for external modules.

* Rather than printing the list of emitted files to standard output,
  generate a dedicated `filelist.f` file for split Verilog output with
  one line for each emitted file.
2021-04-26 11:11:56 +02:00
Chris Lattner 00b068f2a4 Switch firtool and the testsuite to SimpleCanonicalizer.
This also stops linking it into circt-opt to make sure we don't accidentally
add new uses of the old pass.
2021-04-25 17:21:48 -07:00
Chris Lattner 44dcc358cd Introduce a new -simple-canonicalizer pass, which is currently just a clone of Canonicalize.
Canonicalize does a bunch of stuff that is slow and not useful for either
the RTL or the firrtl dialects, because it is heavily focused on CFG-like
things.  We'll trim some of this fat out in our local clone, as the main
MLIR canonicalizer is carrying some significant compatibility issues that
make it difficult to improve.
2021-04-25 16:47:25 -07:00
Mike Urbach 377c1042cf [Python][NFC] Run yapf on the entire repo.
This executes `yapf -i -r .` from the top-level directory. It is a
purely formatting change.
2021-04-21 15:38:02 -06:00
Mike Urbach b0e69ae120 [Python][CI] Add yapf formatting guidelines and run check in CI.
This follows the same setup as MLIR and NPCOMP, using yapf and the
Google style guidelines, with two-space indentation.
2021-04-21 15:38:02 -06:00
Andrew Lenharth 804f5e4a24
Lower firrtl::memop to generator modules (#864)
Lower MemOp to generator modules and enable the pass in firtool to convert those to implementations.
2021-04-15 09:31:16 -05:00
Andrew Young 613cd010fe [firtool] Change command line options for enabling passes
This changes the `--enable-lower-types` flag to `--lower-types` and it
changes `--circt-lowering-options` to `--lowering-options`.
2021-04-14 13:27:25 -07:00
Andrew Young 544f747360 [FIRRTL] Add expands whens pass
This ports the expand whens pass from the Scala FIRRTL compiler.  This
pass handles last connect semantics, and replaces all When operations
with equivalent statements. For example:
```firrtl
module MyModule :
  input en: UInt<1>
  input a: UInt
  input b: UInt
  wire w: UInt
  when en :
    w <= a
  else :
    w <= b
```
is expanded to:
```firrtl
module MyModule :
  input en: UInt<1>
  input a: UInt
  input b: UInt
  wire w: UInt
  w  <= mux(en, a, b)
```
2021-04-13 10:47:47 -07:00
mikeurbach 8f57a05cf5
Add support for Vivado to circt-rtl-sim. (#903)
This does not include DPI support.

Tested locally with Vivado 2020.2.
2021-04-12 21:50:24 -06:00
Andrew Lenharth cca2ba9832 cmake will find a file for questa, not a directory 2021-04-08 13:43:38 -05:00
John Demme e1b22e19b9
[Seq] Computational register op and lowering to SV (#883)
Model of the compreg op outlined in the Seq dialect rationale dialect. This is just a starting place and I do expect it to change and/or have siblings for different flavors. Lowers to sv.alwaysff with posedge clock and sync reset -- for now.

Also adds a few mechanical things required to make the Seq dialect actually work which I neglected in the PR which added the dialect.
2021-04-05 17:24:06 -07:00
Andrew Young 94ff0a1764 [firtool] Enable CSE on RTL
The CSE pass has been fixed upstream to not crash on graph regions with
use-before-def's in the IR.
2021-03-31 21:39:17 -07:00
Andrew Young a82d76b2f6 [ExportVerilog] Add option to control alwaysff printing
This change adds the ability to control the verilog emitter using a set
of attributes on the top level ModuleOp. This is controlled by an
attribute key on the top level module, `circt.loweringOptions`, with a
StringAttr parameter.

This adds a command line option which will amened the IR after parsing
with the options.

The options used in the attribute and the commandline match.
2021-03-31 20:44:45 -07:00
Andrew Young 23b16c6655
Remove extra semicolons
This removes a couple errant semicolons, which silences a few warnings.
2021-03-31 20:23:35 -07:00
Andrew Young c68fad7003 [firtool] Allow multithreading to be disabled on the command line
Small logical bug enabled mulithreading while passes were being executed
unconditionally. This change saves the multithreaded mode and restores
it to the previous value.
2021-03-29 16:26:08 -07:00
Andrew Young 2b07a5f30b [FIRRTL] Parallelize RTL canonicalization
This is following the same change to the FIRRTL opimizations.
2021-03-29 16:26:08 -07:00
Andrew Young ffd49ba28c [FIRRTL] Nest CSE+Canon passes to run on FModuleOp
The compiler can parallelize pass which are running on distinct
IsolatedFromAbove operations. Moving these passes to run on the
FModuleOp will increase the ability of the compiler to parallelize their
execution. Since there are no operations under the CircuitOp other than
FExtModule and FModule, this does should not change what gets CSE'd and
Canonicalized.
2021-03-29 16:26:08 -07:00
Chris Lattner 4fdba7023e [circt-opt] register the sccp pass to make it available for command line users. 2021-03-26 16:57:19 -07:00
Chris Lattner 06adb4f96d [FIRRTL] Create the scaffolding for an intermodule const prop pass.
This is currently a noop.  This is part of Issue #803/804
2021-03-26 10:53:20 -07:00
Chris Lattner f9e71027ca [firtool] Disable the RTL-level CSE pass since it crashes in some cases.
This should be reverted when Issue #813 is fixed.
2021-03-26 09:50:36 -07:00
Fabian Schuiki 9f02e9c27c
[ExportVerilog] Use LegalNamesAnalysis to determine module names (#807)
* Refactor the MLIR module level emission in ExportVerilog such that it
  has a separate but symmetrical `UnifiedEmitter` and `SplitEmitter`.
  These either emit Verilog into one large file, or one separate file
  per module and interface. This will also provide a way to inject the
  results of LegalNamesAnalysis into the emission process.

* Add `isNameValid` to SV dialect to check if a string contains only
  characters that are legal for SV identifiers.

* Verify that module names contain only allowed characters when emitting
  them in ExportVerilog. Do no longer sanitize the module names but rely
  on a separate pass on the IR to do so.

* Run the RTLLegalizeNamesPass when emitting Verilog with firtool.

* Check for name consistency in split-verilog test case.

* Run `circt-opt --rtl-legalize-names` before `circt-translate
  --export-verilog` to ensure names are legal for emission.

* Update the expected output in the rtl-dialect.mlir test, since the
  separate renaming pass now ensures that the two `arrZero` ports do no
  longer conflict in the output. Also the index on `reg_2` has shifted
  by one due to an intentional conflict caused through `inout_0` to
  check for proper renaming.

* Add explicit check for sanitization of an instance with unsavoury
  name.

* Rename the `rtl.module.extern @reg` in the sv-interfaces.mlir test,
  since the renaming pass cannot just go rename external modules. This
  should probably become an error check at a later stage.

* Emit a diagnostic in the `RTLLegalizeNamesPass` if an extern module
  has an invalid name.

* Add test cases that check for these diagnostics.
2021-03-25 21:21:17 +01:00
Schuyler Eldridge 38f58d3a06
[FIRRTL] Parse CircuitTarget and ModuleTarget Annotations (#616)
* [FIRRTL] Parse local Circuit, Module Annotations

Adds the ability to parse and store CircuitTarget or ModuleTarget local
Annotations as MLIR Attributes.  Annotations are stringly-typed and stored
in an ArrayAttr.  The "target" field is removed as part of this process as
this is now implicit based on the operation to which the Attribute is
applied.

Other types of Annotations (e.g., ComponentTarget or non-local) produce a
runtime error.

The utility firtool is updated to take an --annotation-file argument which
can be used to import annotations from an annotation file.  Additionally,
annotations can be specified using a new "inline" syntax on a FIRRTL
circuit using `%[annotations]`.  Any --annotation-file annotations are
appeneded to inline annotations if they exist.

Add tests of CircuitTarget, ModuleTarget, CircuitName, ModuleName, and
erroneous/unsupported annotations or JSON.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-03-24 15:57:50 -04:00
Chris Lattner 0dff5b1d7a [firtool] Run canonicalize on the firrtl dialect *after* lower types, not before it.
This resolves Issue #794, where we were getting extraneous clock wires.
2021-03-23 17:39:54 -07:00
Andrew Lenharth 01fb343e41
A Utility pass to convert external modules to empty modules (#777)
Grey boxing of external modules.  Turns external modules into modules with 'x on outputs.
2021-03-22 10:03:06 -07:00
Fabian Schuiki 72162617f6
[ExportVerilog] Parallelize split Verilog output and print file list (#793)
* Make the `reservedWordCache` thread-safe by using a constructor class
  for the underlying `llvm::ManagedStatic`. Also simplify the whole
  thing by dropping the `getReservedWords()` function and renaming the
  static to `reservedWords`.

* Parallelize split Verilog emission

* Print file list for split Verilog output
2021-03-22 14:42:19 +01:00
John Demme 5418fdeb9a
[MSFT] New dialect for Microsoft internal design support (#800)
Umbrella dialect for everything needed to support Microsoft development but not
thoroughly discussed.
2021-03-19 21:40:18 -07:00
Andrew Young cb73655cbe
Update LLVM (#792)
This is needed to fix a crash in DCE for graph regions. [0]

- alloc and store operations have been moved to a new MemRef dialect
- custom dialect types now need to be registered in the same compilation
  unit as the type's storage.  Any dialect that registers types have had
  the logic moved to DialectTypes.cpp.
- Small change to the ResetTypeAttr default value declaration.

[0] https://reviews.llvm.org/D98919
2021-03-19 11:33:33 -07:00
mikeurbach cce113ea55
[LLHD] Add option to specify shared libs to load in llhd-sim (#789)
This adds a -shared-libs option to llhd-sim that is analogous to the
same option for mlir-cpu-runner. If specified, those libraries are
passed to the ExecutionEngine to dynamically load and link.
2021-03-19 08:10:36 -06:00
Fabian Schuiki 35c0fc7d38
[firtool] Add option to emit one file per Verilog module (#756)
* Separate the `processBuffer` function into two parts: one that
  processes the input buffer into a module, and one to emit that module
  to an output stream.

* Make processBuffer take callback to process module

* Add another output format which emits a separate verilog file for each
  module in the IR.

* Add a `SplitModuleEmitter` to `ExportVerilog` which creates files as
  it walks over the module body and uses the existing `ModuleEmitter` to
  spit out operations.

* `sv.verbatim` and `sv.ifdef.procedural` are currently treated as
  having file-scope (rather than compilation-unit-scope) and are emitted
  into every file. Since this is currently mostly preprocessor business,
  it does this by gobbling up operations, and thus only perviously seen
  ops are actually emitted. This can go horribly wrong.

* Add test
2021-03-15 13:50:46 +01:00
Chris Lattner fcb1c7ea7d [firtool] register asmprinter command line flags to provide access to --mlir-print-debuginfo 2021-03-14 21:36:28 -07:00
Chris Lattner 12c6b93efb [LowerToRTL] Merge the LowerToRTL and LowerToRTLModule passes.
Now that the module bodies are processed in parallel, we can eliminate this
split.  This will open the door to significantly simplify the implementation,
but tries to take on the bulk of the testcase updates without permuting the
pass implementation too much.
2021-03-13 11:02:40 -08:00
mikeurbach ed6c6421a4
Update LLVM to c68b560be381e831fd72c6b8b8909427e4e2ff36. (#749)
Some changes in this bump:

* OpBuilderDag -> OpBuilder: github.com/llvm/llvm-project/commit/32c49c7
* Changes to Type getChecked and verification: github.com/llvm/llvm-project/commit/06e25d5
* Changes to Value internals, with minor public breakage: github.com/llvm/llvm-project/commit/3dfa861
* Changes to LLVM translation: github.com/llvm/llvm-project/commit/19db802
* .getAttrs() -> ->getAttrs(): 
* Adding llvm_unreachable after covered switch statements with returns
* Separating diagnostics tests from FileCheck tests
2021-03-11 12:05:16 -07:00
Andrew Young a9f66f842e
[FIRRTL LowerTypes] Add FExtModule type lowering (#743)
[FIRRTL LowerTypes] Add FExtModule type lowering

This adds FExtModule lowering support to the lower types pass. This
flattens all types in the parameter list and gives each new operand a
new name.

To process ExtModules in this pass, it had to change from a FModuleOp
pass to a CircuitOp pass. In order to maintain performance, this pass is
now parallelized internally using `parallelFor`.
2021-03-09 21:17:05 -08:00
Chris Lattner 95191dd8e4 [FIRRTL] remove the old FIRRTL2Verilog path, the lower2rtl path is now mature enough to replace it. 2021-03-04 10:01:25 -08:00
mikeurbach 015ea05523
Update LLVM to c68d2895a1f4019b387c69d1e5eec31b0eb5e7b0 (#685)
* Need to include a new header in LLHD sim for LLVM translations
* Need to explicitly register the LLVM translations
2021-02-26 10:31:28 -07:00
Andrew Young 01bb650fab [FIRRTL] Add firrtl pass to blackbox memories
This is the start of some work to add a pass to automatically create
black boxes for FIRRTL memory operations. This works by replacing a
firrtl.mem op with an equivalent instance of an external module. This
work aims to add a feature to replace the --repl-seq-mem option in the
SFC.

This new blackboxing pass is storing the memory configuration data as
parameters on the generated external module. The hope is that we
can write a pass or tool which can launch a (command line) registered
generator to produce whatever artifacts we need. A larger discussion
about how this should work will probably be necessary.

Module name collisions are avoided by manually inserting new modules in
to the symbol table.  This uses the built in symbol collision handling
in MLIR.

The generated modules are deduplicated by specialized hash and equality
functions which compare the memory attributes and return types, ignoring
the naming. This lets us deduplicate black box modules which (I think)
cannot be deduplicated by other passes.

This pass can optionally inline the generated wrapper module directly,
skipping the need to generate it.
2021-02-23 02:38:28 -08:00
Chris Lattner 6355ad1e04 [firtool] Make sure to register the comb dialect in firtool so the parser
knows about operations in it.
2021-02-21 17:43:30 -08:00
Chris Lattner cd06a92194 Rename AlwaysFusion.cpp -> RTLCleanup.cpp. NFC. 2021-02-20 22:36:03 -08:00
Chris Lattner 286e2de23f Rename the AlwaysFusion pass to RTLCleanup, NFC. 2021-02-20 22:32:35 -08:00
Andrew Young 0cc519f85b [firtool] Add verify-each option to disable the verifier
It can be really helpful to disable the verifier in order to dump all of
the IR at a later point.  This option is already supported by circt-opt,
but it can be useful here as well.
2021-02-16 22:22:26 -08:00
Andrew Young e1ca6eaaf9 Remove `using namespace mlir` from header files
This change aims to remove all instances of `using namespace mlir` from
our header files.  Many types have been manually imported into the
`circt` namespace in `circt/Support/LLVM.h`.  These types include all
core MLIR functionality types (IR, Diagnostic), utility types, rewrite
patterns and conversions, builtin IR types and attrs, and the module op.

Not imported were any operations (other than ModuleOp), matchers (e.g.
m_Zero), anything in the `impl` namespace, and interfaces.  There are
some problems with interface code generation from ODS, so some
interfaces were imported.

Some further cleanup would be useful to remove the `mlir::` namespace
qualifier where we no longer need it.
2021-02-16 02:25:06 -08:00
John Demme c17eff5891 [RTL Sim] Add '--assert' to verilator compile
Previously, verilator was ignoring asserts in SystemVerilog. As a result, some
tests were passing when they should have failed.
2021-02-15 18:19:06 -08:00
John Demme 71ce0eb3b4 [Simulations] Add '-cpppath' to questa if DPI is being used.
Also, add another info output in the ESI cosim runner.
2021-02-15 15:41:29 -08:00
John Demme a80fd6ef52
[ESI] [Cosim] Improvements to gasket utility classes (#565)
These changes support the next PR -- list encoding support. Breaking them out
to reduce review load.
2021-02-05 21:47:34 -08:00
Andrew Young 3ffcacc89a Use global pass generation for all conversion passes
This combines all conversion passes into a single Passes.td similar to
MLIR.  For some conversions, the passes were not specified using ODS.
These passes have been converted to use ODS which means they will show
up in generated documentation.  Conversion passes have also been moved
out of dialect namespaces, it is normal for them to live under the CIRCT
namespace.
2021-02-05 13:51:25 -08:00
John Demme d72d6107d3 [Python tools] [NFC] Fix formatting to comply with PEP8 2021-02-04 17:20:26 -08:00
Andrew Young da80538e9f [SV] Add pass to merge AlwaysFF operations
This adds a pass to merge `sv.alwaysff` operations with identical
conditions.  Due to the design of this operation it is trivial to check
if we meet the conditions for merging this operation.  This pass is
structured to not depend on the RTL dialect, and does not assume that
the `sv.alwaysff` operations are in an RTL module.  They do, however,
need to be in a graph region to work.

Although `sv.alwaysff` regions are not graph regions, they are limited
to having a single block.  This pass takes advantage of this to quickly
splice blocks together when merging operations.
2021-02-03 12:17:46 -08:00
Andrew Young 8ef555d7ae Add helpers to register all dialects, and simplify circt-opt
This change cargo-cult imports InitAllDialects.h and InitAllPasses.h
from MLIR.

`circt-opt` has been greatly simplified by using the more powerful
version of `MlirOptMain`, which supersedes all our current
command line options.

Now we're not preloading all dialects, we need to make sure that target
dialects are properly registered in all conversion passes. Source
dialects do not need to be manually loaded.

One thing which is not clear is if `circt::registerAllDialects` should
register any standard MLIR dialects which are used heavily throughout
CIRCT.  This change only registers CIRCT dialects.
2021-01-21 12:22:00 -08:00
John Demme 897d8b98ec
[ESI] [Cosim DPI] Allow the RPC server to select the port (#483)
Selecting the port to use in `esi-cosim-runner.py` and then starting the
simulation to open it created a race condition. There's a brief period
of time between port select and simulator DPI execution in which another
process could open that port. Turns out this happens more often than I
originally anticipated.
2021-01-18 16:52:04 -08:00
John Demme 98c8a8b619 [ESI] Integration test fix
PyCapnp complains when CWD != env:PWD. For some reason this is true on
the runner.
2021-01-17 21:13:40 -08:00
John Demme f3f17e0469
[ESI] Full system test (#473)
Adds a test of the full ESI system:

- Lowers ESI channel ports to SV interfaces for externmodules.
- Adds pipeline stages via ESI buffer ops.
- Uses cosim to get data in/out.
2021-01-17 20:45:14 -08:00
John Demme 5b9abe4088
[ESI] [Cosim] Pull everything together into one simple test (#468)
Adds a simple loopback test and changes/fixes to enable it.

- Uses all the lowering passes to get everything in the RTL dialect.
- Uses circt-translate --emit-verilog to emit verilog.
- Uses circt-translate -emit-esi-capnp to get RPC schema.
- Runs it via esi-cosim-runner.py.
2021-01-17 19:42:52 -08:00
Hanchen Ye 6360381531 [Handshake] fix warnings about getAttrOfType 2021-01-14 13:22:23 -06:00
Jianyi Cheng c969d8e10b
Fixed license header for Simulation.cpp and Simulation.h (#455) 2021-01-14 11:00:48 +00:00