Commit Graph

686 Commits

Author SHA1 Message Date
Amelia Dobis 69fccebb31
[firtool] btor2 integration (#6947)
* added btor2 as a target in firtool

* removed duplicated pass pipeline check

* registered conversion pass

* added small test for firtool
2024-04-29 14:20:53 -07:00
Amelia Dobis 6ce4438878
[HW] Moved and renamed arc/inlineModules to hw/flattenModules (#6964)
* Moved and renamed arc/inlineModules to hw/flattenModules

* removed unused code and reformulated pass description
2024-04-29 13:41:50 -07:00
Martin Erhart cfaf3d79ae [Handshake] Use free variants of isa/cast/dyn_cast
Refer to https://mlir.llvm.org/deprecation/
2024-04-28 15:57:40 +02:00
Martin Erhart 7598a8e067
[circt-lec] Port to SMT dialect based compiler pipeline (#6908) 2024-04-21 08:06:39 +02:00
Martin Erhart 5cf1ff57f4
[SMT] Add lowering to LLVM IR (#6902) 2024-04-20 10:11:47 +02:00
Andrew Lenharth a25118c067
[FIRRTL] Use a flag to implement scalarization of internal modules. This is precursor to making lower-types a module-pass and optional. This will deprecate the flags to lower-types and make aggregate preservation a function of NOT running lower-types, rather than having to control it to ensure ports are correct. (#6901) 2024-04-08 10:04:31 -05:00
John Demme 83dd12ec37
[Ibis] Introduce 'ibis.design' (#6835)
* Revert "[Ibis] Split ContainerOp in two (#6739)"

This reverts commit d17f2f1a1b.

* [Ibis] Introduce 'ibis.design'

Encapsulate everything into a new op. It's an InnerSymbolTable so that
we can identify _everything_ with inner symbols.

Partial progress.

* Hopefully avoid some msvc warnings

* add topLevel attr to containerop

* bug fixes

* Nest createContainerizePass inside of <ibis::DesignOp>

* Work

* Work

* Working

* Self review

---------

Co-authored-by: Blake Pelton <blakep@microsoft.com>
Co-authored-by: Morten Borup Petersen <morten_bp@live.dk>
2024-04-04 11:55:02 +02:00
Felix Yan aee76c6e2a
[Docs] Correct a typo in circt-lec/README.md (#6849) 2024-03-29 12:16:18 -04:00
Martin Erhart 4674e6746a
[circt-lec] Add ConstructLEC pass (#6833) 2024-03-20 08:54:08 +01:00
Théo Degioanni 83a8292085
[arcilator] Introduce integrated JIT for simulation execution (#6783)
This PR adds a JIT runtime for arcilator, backed by MLIR's ExecutionEngine. This JIT allows executing `arc.sim` operations directly from the arcilator binary.
2024-03-18 10:27:08 +00:00
Martin Erhart 7a5635825a
[Verif] Add LEC operation (#6832) 2024-03-17 18:33:09 +01:00
Martin Erhart cfb9792f48
[SMT] Add HWToSMT and CombToSMT conversion passes (#6815) 2024-03-17 18:19:48 +01:00
fzi-hielscher 466f6cc108
[NFC][arcilator] Reenable instrumentation for ArcToLLVM passes. (#6809)
Add VerbosePassInstrumentation to the second pass manager of the arcilator tool to include its statistics in the --verbose-pass-executions output.
2024-03-12 11:00:22 +01:00
Martin Erhart 8b4e95de1e [SMT] Add Dialect rationale and boilerplate 2024-03-12 08:12:50 +01:00
fzi-hielscher d6a6a025a7
[arcilator] Strip Emit dialect operations (#6797) 2024-03-07 19:38:24 +01:00
Schuyler Eldridge 6de364aaf5
[om-linker] Load Emit dialect
Fix a bug in the om-linker tool where the Emit dialect was not loaded.
This dialect needs to be loaded as Emit is already being used by
end-to-end compilation and by tools that facilitate this, e.g., firtool.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-03-01 16:38:34 -05:00
John Demme 113fad9b25
[ESI] Move entirely over to the runtime for testing (#6764)
Removes:
- esi-cosim-runner.py
- all of the raw capnp based tests
- the system test (subsumed by other tests)
- cmake target esi-collateral
- runtime distribution from PyCDE
2024-02-28 22:29:29 -08:00
John Demme 6395b54d40 [hlstool] Limit includes do dependences are accurate 2024-02-29 04:13:33 +00:00
Nandor Licker cf931e1704
[ExportVerilog][Emit] Export emitted files (#6728) 2024-02-24 16:50:01 +02:00
Nandor Licker 84a7c8b1b0
[Emit] Organize output files using the `emit` dialect (#6727) 2024-02-24 10:09:00 +02:00
Fabian Schuiki b525c6e1a7
[circt-translate] Make ImportVerilog registration conditional
Move the call to `registerFromVerilogTranslation()` from the
`InitAllTranslations.h` header, where it is executed unconditionally,
into the `circt-translate.cpp` file, where it can more easily be guarded
behind an ifdef. This fixes builds with the Slang frontend disabled.

In the future we may want to generated a header with macros that reflect
which optional parts are enabled or disabled. `InitAllTranslations.h`
could then use those macros to conditionally register the ImportVerilog
translation.
2024-02-21 12:12:23 -08:00
Fabian Schuiki cef850f858
[NFC] Sort tools alphabetically 2024-02-16 09:23:20 -08:00
Théo Degioanni c60ddb2491
[arcilator] Remove PrintStateInfo pass (#6529)
* PrintStateInfo refactoring

* remove printinfopass

* fix failing tests

* extract arcilator logic to tools lib

* add CIRCTArc dependency to Arcilator tool

* match argument names

* make state collection non-recursive

* move modelinfo to the arc dialect

* fix formatting

* address comments

* fix formatting

* revert llvm bump

* update old variable name

* rename file + lib

* fix formatting
2024-02-12 11:31:18 +00:00
Fabian Schuiki e2f2c39735
[ImportVerilog] Add import options and Verilog preprocessing (#6632)
Add the `ImportVerilogOptions` struct to capture various options that
can be passed to the Slang Verilog frontend. This covers things like
include search directories, macro definitions, top modules, time scales,
and other settings commonly found in Verilog tools. The struct is
inspired by `slang::driver::Driver::Options`, but we intentionally
create our own struct such that no Slang headers leak through into CIRCT
space.

Add corresponding command line options to `circt-verilog`, and use them
to populate an `ImportVerilogOptions` struct that can be passed to
`ImportVerilog`.

Add `importVerilog` and `preprocessVerilog` functions to `ImportVerilog`
and add corresponding options to `circt-verilog` that call the
respective import function. This commit only implements preprocessing.

This commit also adds a mechanism to bridge between the diagnostic world
of Slang and MLIR (`MlirDiagnosticClient`). This allows us to emit any
Slang-generated diagnostics as regular MLIR diagnostics, alongside any
other errors or warnings the Verilog import might generate.

Add tests for the preprocessor (with include paths and macros) and the
diagnostic bridge.

Co-authored-by: Will Dietz <will.dietz@sifive.com>
Co-authored-by: ShiZuoye <albertethon@163.com>
Co-authored-by: hunterzju <hunter_ht@zju.edu.cn>
Co-authored-by: 孙海龙 <hailong.sun@terapines.com>
Co-authored-by: Will Dietz <will.dietz@sifive.com>
2024-02-08 11:08:03 -08:00
Nandor Licker afff815c55
[HW] Lower hw.instance_choice to SV (#6624) 2024-02-05 17:57:08 +02:00
Fabian Schuiki 3d8b7d08d9
[ImportVerilog] Add Slang frontend dependency (#6620)
This is the first PR in a longer chain that adds basic SV support to
CIRCT.

Add the Slang Verilog frontend as a CIRCT dependency. This will be the
foundation for CIRCT's Verilog parsing, elaboration, type checking, and
lowering to the core dialects. By default, Slang is built as a static
library from scratch, which is then linked into the new `ImportVerilog`
conversion. Alternatively, CIRCT can also be linked against a local
Slang installation provided by the system.

Add the `ImportVerilog` conversion library. This library statically
links in the Slang dependency and wraps it in an exception-safe,
LLVM-style API. Currently this only consists of the `getSlangVersion`
function and the necessary linking flags to get it to link statically
against Slang.

Add the `circt-verilog` tool, which will provide a fully-flegded
interface to the new `ImportVerilog` library. Later on we'll also add an
MLIR translation library for single-file SV import. But in general, SV
builds take a lot of command line options (macros, search paths, etc.)
and multiple input files, which is why we have a dedicated tool. All the
tool does at the moment is print the linked Slang version. More to come.

Note that this intentionally links against **version 3** of Slang. Newer
versions are available -- 4 and 5 as of this commit -- but they rely on
fairly new C++ compiler features that didn't work out of the box in our
CI images. We'll eventually want to upgrade, but for now Slang 3 is
sufficient to get the ball rolling.

See https://github.com/MikePopoloski/slang for details on Slang.

Co-authored-by: ShiZuoye <albertethon@163.com>
Co-authored-by: hunterzju <hunter_ht@zju.edu.cn>
Co-authored-by: 孙海龙 <hailong.sun@terapines.com>
2024-01-30 13:22:00 -08:00
John Demme 26cf76c591 [Ibistool] Replace wide include with something more targetted
Avoids introducing implicit dependencies on header files which may or
may not be generated. (GPU dialect was the specific issue.)
2024-01-21 00:07:30 +00:00
Andrew Lenharth f28128c955
Bump LLVM (#6566) 2024-01-11 11:04:57 -06:00
Nandor Licker cc8fabb16d
[Sim] Initial implementation of the `sim` dialect (#6561) 2024-01-10 18:02:39 +02:00
Andrew Lenharth ccdef1740c
[NFC] Bump LLVM over mnemonic change (#6563) 2024-01-09 16:01:06 -06:00
Amelia 3707c382fb
[HW to BTOR2] btor2 conversion pass (#6378)
* Added missing tool in integration test

* Fixed formatting

* Fixed whitespace issue

* Fixed typo in VerilogGeneration.md

* Added skeleton for btor2 lowering pass

* added pattern match skeleton to lowering pass

* Added initial emission of inputs and hw::constant ops

* added constant emission

* added emission for most operations and final assertion

* Added support for muxes, assumptions and wire aliases

* Added support for inputs in btor2

* fixed bug in input generation

* added support for missing comb operations

* Changed input registration to allow for booleans

* Made input type check more robust

* WIP register state transition system generation

* Added support for registers

* refactored hardcoded string

* added names to btor2 states

* Added state initialization support

* Removed state initializer, it should be a firrtl construct and not a btor one

* Removed temporary file emission

* Added back accidentally removed btor2 string printing

* Ran clang-format

* Ran clang-format

* WIP refactored typeswitch

* refactored giant type switch

* Made all string litterals constexpr

* attempting to fix sanity check

* fixed variable name typo

* Attempting to satisfy clang-tidy

* renamed things to make clang happy

* inlined useless helper methods

* Clarified the necessity of important data structures in comments

* fixed formatting

* Changed pass into a Conversion pass

* refactored helper methods

* Checked for case where next is a port when emitted transitions

* Added newline at EOF

* Inherited visitors instead of using a big typeswitch

* Throw an error for unsupported ops and explicitly ignore the rest

* Removed unnecessary functions and refactored runOnOperation

* Fixed formatting

* Attempted to add some test

* Added in ops that weren't covered by visitors

* Added in missing declaration in header

* Included pass in CAPI CmakeLists

* Added infrastructure for btor integration tests

* Revert "Added infrastructure for btor integration tests"

This reverts commit a5ec3da4ec.

* various nitpicking comments accounted for

* used generalized ids for btor2 testcase

* fixed typo in test

* updated test and found small bug

* clang-format

* added support for arbitrary resets

* Updated test to reflect new handling of reset

* Switched to a DFS strategy for emission

* Updated test to align with preemission of register declarations

* Removed gratuitous lookups.

* inlined a bunch of string constatns

* removed certain silent fails and added out of order test
2023-12-15 20:30:07 +01:00
John Demme 223d4ccc30 [RTL sim] Add option to run verilator with valgrind 2023-12-11 23:59:16 +00:00
Fabian Schuiki 08665a1b16
[Arc] Partially enable reset/enable detection (#6506)
Enable the `InferStateProperties` pass in the arcilator pipeline and
make its enable and reset signal detection individually controllable.
The enable portion is already supported by the rest of the arcilator
pipeline and can produce 20%-35% speedup on the cores in arc-tests.
Turn on enable detection by default.

The reset portion is not fully supported yet and causes the simulation
to misbehave. It is disabled by default.

As a minor refactoring this removes the `constructor` field from the
pass definition, such that the constructor and plumbing for options gets
generated automatically. As a side effect, the constructor is now called
`arc::createInferStateProperties` instead of the previous
`arc::createInferStatePropertiesPass`. (Thanks @uenoku for the pointer.)

Shoutout to @maerhart and @TaoBi22 for this fantastic pass!
2023-12-08 15:21:34 -08:00
Fabian Schuiki f3e5bc9b3b
[Arc] Add option to observe registers and memories (#6477)
Instead of always making registers and memories observable for the user,
add dedicated `--observe-registers` and `--observe-memories` options to
`arcilator`. These allow the user to indicate whether they are
interested in observing or register and memory state. If these options
are set to false, don't attach "name" or "names" attributes to states
and memories, such that other parts of the pipeline have a chance to
delete unnecessary state.
2023-12-02 09:22:23 -08:00
Fabian Schuiki 6281f978e7 [Arc] Make pass constructors accept options struct; NFC
Instead of passing pass options as separate constructor function
arguments, use the `*Options` struct produced by TableGen.
2023-11-30 10:49:50 -08:00
Fabian Schuiki 0bc8055655
[Debug] Add option to only mention existing files in HGLDD (#6452)
Add an option to HGLDD file emission to only consider location
information in the IR if the corresponding file exists on disk. This can
help filter out placeholder filenames such as `<stdin>` or `<unknown>`.
Also add a corresponding `--hgldd-only-existing-file-locs` option to
firtool.
2023-11-30 07:36:58 -08:00
Schuyler Eldridge 80b3edbcde
[firtool] Change scalarize-top-module option
Remove the -scalarize-top-module option to firtool (and the parser).
Replace this with -scalarize-public-modules.  This is done in preparation
for FIRRTL 4.0.0.  This is also largely unnecessary once FIRRTL 4.0.0
figures out how to attach the ABI to each public module.

Co-authored-by: Will Dietz <will.dietz@sifive.com>
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2023-11-28 15:10:55 -05:00
Andrew Lenharth 57aff18faf
[FIRTOOL] Make firtool options behave like the rest of llvm. (#6435)
Move firtool pipeline configuration over to the same mechanism the rest of llvm and mlir use. Export this via the CAPI. Add a couple examples of methods to change options to the CAPI. Interested parties are encouraged to finish out the set of functions.

Since the CAPI has no tests, this breaks nothing.

As an aside, the configuration space of the firrtl pipeline is WAY too big.
2023-11-27 10:57:18 -06:00
John Demme 341cdc3b72
[ESI][Runtime] Add cosimulation support to new runtime (#6428) 2023-11-18 18:58:41 -08:00
John Demme 19be7e55fd
[ESI] Cosim: punt endpoint naming to users (#6427)
Rather than identifying cosim endpoints by "%m", have them specified entirely upstream. The easiest way to ensure uniqueness then is to only allow cosim endpoints at the top level. This solves a number of issues, and also makes cosim look a lot more like other ESI services.
2023-11-17 17:51:55 -08:00
Nandor Licker 53cf75911a
[Seq] Move the HWMemSimImpl pass to seq (#6409)
The pass relies on `seq` items, creating a circular dependency between SV and Seq.
It better belongs to the seq dialect, alongside options and ops it related to.
Moving forward, this should be merged into FIR memory lowerings.
2023-11-13 11:19:21 +02:00
John Demme 3fea5dfca3 [ESI][cosim runner] Add 'cosim' to test exec arg list
Necessary to enable script re-use for non-cosim connections.
2023-11-08 23:19:48 +00:00
John Demme aca2fc57d0
[ESI] Major cosim fixup/cleanup/update (#6365)
- Changes terminology: send -> fromHost, recv -> toHost.
- Makes ops and SV unidirectional.
- Declares external modules using parameters.
- Updates Capnp schema to use string type IDs.
- Ditch the typed Capnp endpoint interface.
2023-11-01 17:59:14 -07:00
John Demme 0787f67003
[ESI][Cosim] DPI support for manifests (#6357)
Add RPC call and corresponding DPI/RTL for getting the compressed accelerator manifest.
2023-10-31 15:02:41 -07:00
John Demme dfc63c1bce [ESI] esi-cosim-runner.py: add option to use different simulator
Now accepts --sim which merely gets passed through to circt-rtl-sim.py.
2023-10-31 03:52:18 +00:00
John Demme 1927491cff
[ESI] Move Cap'nProto into ESI runtime (#6354)
Simplifies the CIRCT proper build. Also mitigates a runtime binary distribution problem by requiring users to compile the runtime themselves.
2023-10-30 13:45:17 -07:00
Fabian Schuiki 3136ae5ecd
[firtool] Move -g option into firtool library (#6332)
Move the `-g` option from `firtool` the tool to `Firtool` the library.
See discussion in #6309.
2023-10-24 11:44:18 -07:00
Fabian Schuiki 097e0a60b4
[FIRRTL] Add debug info materialization pass (#6309)
Add the `MaterializeDebugInfo` pass, which creates debug ops to track
FIRRTL-level ports, nodes, wires, registers, and instances throughout
the pipeline. This is a fairly simple first attempt at tracking
higher-level source language information through the compilation using
the debug dialect.

Also add the `-g` option to firtool, which causes this pass to run very
early on in the pipeline where all the high-level information is still
available. Enabling this option will currently cause `ExportVerilog` to
fail because of the additional operations in the IR -- to be rectified
by a later PR.
2023-10-24 09:52:33 -07:00
Fabian Schuiki a9a07b70d2
[Debug] Add debug dialect (#6308)
Add the `dbg` dialect, alongside a rationale document, basic types, and
the three essential `dbg.variable`, `dbg.struct`, and `dbg.array`
operations.

The goal is for this dialect to be a home for all the machinery needed
to track debug information in the IR. After discussions with a few
people in the LLVM/MLIR space, I chose to create dedicated operations to
track debug info in the IR, as opposed to an attribute/metadata based
approach. The details are outlined in the rationale document.

Subsequent PRs add simple debug info tracking to FIRRTL and firtool, and
extend debug info emission to consider these operations.
2023-10-20 09:51:37 -07:00
George Lyon 55505ebcb9
firtoolPopulateCHIRRTLToLowFIRRTL doesn't need a module (#6304) 2023-10-19 12:38:03 -07:00