Commit Graph

291 Commits

Author SHA1 Message Date
Martin Erhart 6f20eee285
[RTG] Add operation and types to represent labels (#7964) 2024-12-17 23:10:56 +01:00
Andrew Young 0276e17b2e
[firtool] Add option to disable layer sink (#7981)
The layer sink pass is showing some performance problems, and we want
the ability to turn it off to work around the issue, until we can
properly fix it.
2024-12-13 10:45:26 -08:00
Asuna 7a98d67692 [FIRRTL][CAPI] Add more functions for discriminating and querying type 2024-12-13 09:16:21 +08:00
Schuyler Eldridge d53c2d09ff
Revert "[FIRRTL][CAPI] Add more functions for discriminating and querying type"
This reverts commit 14622691f3.

This caused failures in both the Windows build [[1]] and nightly valgrind
[[2]].  I opened issue #7970 to track re-landing this.

[1]: https://github.com/llvm/circt/actions/runs/12270667089
[2]: https://github.com/llvm/circt/actions/runs/12275922843/job/34252017293

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-12-11 11:05:27 -05:00
Asuna 14622691f3 [FIRRTL][CAPI] Add more functions for discriminating and querying type 2024-12-11 14:06:32 +08:00
Prithayan Barua b5141b7f1d
[InstanceChoice] Add a default override for unspecified options (#7955)
Add an override that, instead of emitting an error, selects the default target
 to specialize an instance choice when the option is unspecified. By default a
 partially specified instance choice is not allowed. But we can override the
 error and select the default target, by using
 `--select-default-for-unspecified-instance-choice` with `firtool`.
This enables a user to specialize the instance choice for a particular build
 flow, and fall-back to the default for all others.
2024-12-05 14:40:24 -08:00
Asuna ca2d9c7d07 [FIRRTL][CAPI] Add documentation 2024-12-05 22:11:30 +08:00
Martin Erhart fb8421d5c0
[RTG] Add BagType CAPI and Python Bindings (#7888) 2024-12-04 22:13:15 +00:00
Martin Erhart bb16f8968b
[RTG][RTGTest] Add CAPI and a basic lowering pipeline (#7882) 2024-12-04 21:39:10 +00:00
Prithayan Barua fd08d90333
[firtool] Add an option to disable CSE in classes (#7931)
This PR adds the option to run CSE only on `firrtl.module`, and ignore
 other operations. There are some tools, that are not able to handle CSE of
 `firrtl.object` in `firrtl.class`. Specifically, the reuse of `firrtl.object`
 is not modeled properly.
This is a temporary workaround to disable the CSE of operations inside
 `firrtl.class`, which can be removed once the actual issue is fixed.
2024-12-02 14:31:41 -08:00
John Demme e5842649d2
[DC] Add CAPI bindings for DC (#7906)
Registers the DC passes.
2024-11-26 19:47:52 -08:00
Mike Urbach af4b15a59c
[FIRRTL] Remove all traces of OMIR JSON support. (#7907)
This legacy system for representing an object model has been replaced
by FIRRTL classes, objects, and properties. This removes the old
system completely.

The main change is removing the EmitOMIR pass completely, but there
are several other things related to OMIR JSON to clean up. This
includes command line options and annotations for specifying input and
output OMIR JSON, as well as support for parsing the JSON and
scattering OMIR tracker annotations. Any tests related to the above
were also removed.

The only remaining legacy OMIR feature is the OMIRTracker annotation,
which is currently used in some canBeDeleted logic on annotations in
folders, IMDCE, etc. This is being separated, and removed in this PR:
https://github.com/llvm/circt/pull/7908.
2024-11-26 16:42:55 -07:00
yassinz 3f6cbf6bde
[CAPI][Python][Arc, HW] Register Arc and HW passes (#7790)
Expose Arc and HW passes to CAPI and Python bindings.
2024-11-19 15:50:23 -08:00
Hideto Ueno c301a0f15c
[AIGToComb] [circt-synth] Add a AIG to Comb conversion pass (#7742)
This adds a conversion pass from AIG dialect to Comb dialect. AndInverterOp can be easily converted into comb.and + comb.xor + hw.constant.

This enables us to utilize core dialects tools for synthesis results without any addition. Primarly use case is running LEC on IR before and after synthesis.
2024-10-29 14:15:41 +09:00
Hideto Ueno 5b8b18e9e4
[CombToAIG] Add CombToAIG conversion pass (#7740)
This adds a conversion pass from Comb to AIG. Currently conversion patterns for variadic `comb.or/and` 
and binary xor are supported. There will be a follow up to implement conversion patterns for arithmetic ops.
2024-10-26 20:57:00 +09:00
Hideto Ueno b937bcfab0
[Seq] Add initial value to compreg (#7553)
This PR extends compreg's powerOnValue operand to be able to capture more complicated initialization such as firreg's randomized initialization or DPI calls. This change should make register initialization more modular and a step forward towards https://github.com/llvm/circt/issues/7213. 

While ASICs might not have explicit initial values, they are crucial for simulation
and FPGA implementation. FPGA designs often require constant initial values, while
simulation allows for more complex initialization using expressions like function calls
`$random`, `$readmem`, and `$fopen`.

seq.compreg has a (optional) powerOn operand that is lowered into inlined assignment in SV which allows users to initialize registers with user-specified values. However this representation is not sufficient for initialization with function calls. 

In order to represent various kinds of initialization, `seq.initial` op and `!seq.immutable` type
are introduced. The `seq.initial` operation produces values with types wrapped in `!seq.immutable`.
The `!seq.immutable` type wrapper prevents initial values from depending on time-variant values.
Stateful operations typically require corresponding initial values with the `!seq.immutable` type.
This ensures that the initial state of the operation is well-defined and independent of time-variant factors.

Example Input:
```mlir
%r_init, %u_init = seq.initial {
  %rand = sv.macro.ref.se @RANDOM() : () -> i32
  %c0_i32 = hw.constant 0 : i32
  seq.yield %rand, %c0_i32 : i32, i32
} : !seq.immutable<i32>, !seq.immutable<i32>
%r = seq.compreg %i, %clk initial %r_init : i32
%u = seq.compreg %i, %clk initial %u_init : i32
```

Output Verilog:
```verilog
reg [31:0] r;
initial
  r = `RANDOM;
reg [31:0] u = 32'h0;
```
2024-08-30 14:08:34 +09:00
Asuna 6a0ba529b8 [HW][CAPI] Add a function to get an empty `InnerSymAttr` 2024-08-13 13:02:32 +08:00
Mike Urbach 36a3a424fc
[OM] Add ListType C API and Python bindings. (#7490)
We want to expose this type through the Python bindings for isinstance
queries, etc., so add the necessary boilerplate.
2024-08-09 13:53:25 -06:00
Mike Urbach 61d2719269
[OM] Add AnyType C API and Python bindings. (#7488)
We want to expose this type through the Python bindings for isinstance
queries, etc., so add the necessary boilerplate.
2024-08-09 11:56:40 -06:00
John Demme 10180d3ca2
[ESI] Separate data delay from signaling standard (#7354)
The control signaling is (for valid/ready and FIFO) orthogonal to the
number of cycles data is delayed. Separate it out.
2024-07-23 16:37:25 -07:00
Martin Erhart c012ab88a9
[LLHD] Use hw.inout instead of llhd.sig (#7353) 2024-07-19 20:51:33 +01:00
Martin Erhart 2345382e67
[LLHD] Remove llhd-sim (#7351) 2024-07-19 17:54:14 +01:00
Will Dietz 1dfdadaf28 [HW][CAPI][NFC] Fix cast warning.
Casting from interface to operation generates these warnings,
as with other instances resolve by casting from Operation* instead.

> llvm/llvm/include/llvm/Support/Casting.h:490:69: warning: returning reference to local temporary object [-Wreturn-stack-address]
2024-07-10 15:58:03 -05:00
John Demme 98e8265a7c
[PyCDE][ESI] Manifest: add record about client (#7299)
Call to add a record to the manifest about a particular client. Required
plumbing through the record op to python.
2024-07-10 06:59:43 -07:00
Will Dietz 0806944a52
[FIRRTL] Drop Hoistpassthroughs pass. (#7097)
This has only been used for probes, but without input probes
this is no longer useful or necessary.

The HW-signal hoisting works well (if limited) and has no
known issues[1] but has yet to be used in practice due
primarily to passthroughs being intentional occasionally
and lacking a mechanism to capture or distill this intent
properly (it must be ""optimized"" yet not).

Since this is unused, and lacking traction on the above,
remove from pipeline and delete this for now instead of
having it bitrot and be a maintenance burden while
adding/completing new features.

Lives on in version control history!

[1] FWIW, see https://github.com/llvm/circt/pull/6115 for
both small example and before/after on chipyard, as well
as testing internally back when this was introduced.
2024-05-28 13:38:51 -05:00
Fabian Schuiki a778922171
[Moore] Move array types into ODS (#7088)
Move the definitions of all array types from C++ land into
`MooreTypes.td`. This removes a significant amount of redundant code and
simplifies the dialect's type system.

Replace packed and unpacked ranges (`T [4:3]` or `T [2:4]`) with a new
type that discards the directionality and offset of the range. This
information is no longer needed at the IR level. Any meaning that the
offsets have can be encoded in the corresponding ops. Both ranges are
now represented as `array<2 x T>` and `array<3 x T>`, respectively.

Combine unpacked ranges (`T foo [6:2]`) and unpacked arrays
(`T foo [42]`) into a single `uarray<N x T>` type.
2024-05-26 09:25:55 -07:00
Fabian Schuiki 397e854300
[Moore] Simplify and move RealType definition into ODS (#7036)
Coalesce SystemVerilog's `shortreal`, `real`, and `realtime` types into
a single `!moore.real` type understood to be 64 bits wide, and move the
definition from C++ land into `MooreTypes.td`. Once ImportVerilog
actually supports expressions on real values we may want to revisit this
type and either replace it with the standard `f32` and `f64` types, or
create dedicated types for `shortreal`, `real`, and `realtime`.
2024-05-16 14:39:24 -07:00
Fabian Schuiki 6a2b628129
[Moore] Make simple bit vectors a proper MLIR type (#7011)
The core type most SystemVerilog expressions are interested in and
operate on is a "simple bit vector type". These are individual integer
atoms like `bit` or `logic`, integral types like `int`, or packed arrays
with a single dimension and an integer atom inner type, like
`bit [42:0]`. So in a nutshell, simple bit vector types are MLIR's `i42`
in the two-valued (`bit`) case, or the four-valued equivalent (`logic`).

Up until this point, the Moore dialect reflected this pattern by
providing and `IntType` for the integer atoms like `bit` and `int`, and
using the `PackedRangeDim` for single dimension vectors of `bit`. A
`SimpleBitVectorType` helper struct would then summarize the _actual_
bit vector that was expressed by the packed range and integer atom. This
makes working with the types in TableGen files very annoying, since the
thing you are actually interested in -- the simple bit vector -- is not
a propery MLIR type, but more like a helper struct on the side.

This commit rips out the existing `IntType` and its composition with a
packed array dimension, and replaces it with a proper simple bit vector
type that is actually an MLIR type. As a result, SystemVerilog types
like `int unsigned`, `bit [42:0]`, `reg`, `logic signed [31:0]`, or
`integer` are all translated into the same MLIR type. This new simple
bit vector MLIR type retains the `IntType` name, and prints as
`!moore.i42` or `!moore.l42`, depending on whether it is a two-valued or
four-valued integer. Single `bit` and `logic` atoms become `i1` and `l1`
respectively.

This makes the Moore type system a lot easier to work with and removes
a lot of unnecessary noise. Operations can now simply use
`llvm::isa<IntType>` to check if a value is a simple bit vector.
2024-05-09 15:52:20 -07:00
devins2518 5ac765214c
[ARC][CAPI] Add basic C API for initializing ARC (#6997) 2024-05-09 15:48:12 -07:00
Fabian Schuiki 719bbfde79
[CAPI] Add circt-capi target and build it in CI (#7017)
Add a `circt-capi` target that depends on all C API libraries. Introduce
a new `add_circt_public_c_api_library` CMake function that wraps around
the MLIR equivalent, but also adds a dependency from `circt-capi`. Make
at least the short integration tests CI job build the `circt-capi`
target to ensure it has a bit of CI coverage.
2024-05-09 11:21:33 -07:00
Fabian Schuiki 1a311bbc32
[CAPI][Moore] Remove signedness
Update the Moore C API to match changes made to the type system. CI
doesn't build the C API currently, which means these breakages often go
unnoticed.
2024-05-09 10:35:14 -07:00
Martin Erhart 282bdb85b2 [Moore] Remove remaining usages of EnumType 2024-05-07 11:10:13 +02:00
Amelia Dobis d090c6689d
[LTL to Core] Add lowering for AssertProperty operations (#6974)
* Add lowering for AssertProperty operations

* removed nl at start of file

* sorted cmake and removed unreachable branches

* Removed useless wire in test + removed symbol from hbr compreg
2024-05-02 12:57:52 -07:00
Will Dietz b2ae5cf526
[FIRRTL] Error if asked to add a port to a public module. (#6936)
Add option to allow this for compatibility.

Add statistic to count ports added to public modules,
as an interesting bit of information but particularly
to track how many are still being added when updating
a code base to avoid this.
2024-04-30 16:15:56 -05:00
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
Martin Erhart 5955eff5e3 [FIRRTL] Use free variants of isa/cast/dyn_cast
Refer to https://mlir.llvm.org/deprecation/
2024-04-28 17:05:52 +02:00
Martin Erhart 594e3fb83f [Calyx][OM][Pipeline] Use free variants of isa/cast/dyn_cast
Refer to https://mlir.llvm.org/deprecation/
2024-04-28 16:53:58 +02:00
Martin Erhart ad148fb46c [HW] Use free variants of isa/cast/dyn_cast
Refer to https://mlir.llvm.org/deprecation/
2024-04-28 16:41:57 +02:00
Martin Erhart f14114c4e2 [SV] Use free variants of isa/cast/dyn_cast
Refer to https://mlir.llvm.org/deprecation/
2024-04-28 16:35:44 +02:00
Martin Erhart 0135db8709 [Seq] Use free variants of isa/cast/dyn_cast
Refer to https://mlir.llvm.org/deprecation/
2024-04-28 16:12:57 +02:00
Martin Erhart a3e86791a1 [ESI][MSFT] Use free variants of isa/cast/dyn_cast
Refer to https://mlir.llvm.org/deprecation/
2024-04-28 16:11:30 +02:00
Martin Erhart 8867f7b867 [LLHD] Use free variants of isa/cast/dyn_cast
Refer to https://mlir.llvm.org/deprecation/
2024-04-28 15:48:54 +02:00
Martin Erhart 93e2cb71a2 [Moore] Use free variants of isa/cast/dyn_cast
Refer to https://mlir.llvm.org/deprecation/
2024-04-28 15:42:37 +02:00
Asuna 172b5eabb5 [FIRRTL][CAPI] Add function for getting mask type 2024-04-23 06:43:27 +08:00
Martin Erhart 5cf1ff57f4
[SMT] Add lowering to LLVM IR (#6902) 2024-04-20 10:11:47 +02:00
Asuna 8868394e32 [FIRRTL][CAPI] Allow constructing integers larger than 64 bits 2024-04-07 05:04:23 +08:00
Andrew Lenharth f77c00222c
[NFC] Cache common lookups in ModuleType (#6892)
Use custom storage for ModuleType to cache input/output <-> index mappings.  Speeds up many things in small ways.
2024-04-02 14:26:05 -05:00
Hideto Ueno de58c5f911
[LowerToHW] Emission Option for verification flavors (#6885)
This commits replaces `--emit-chisel-asserts-as-sva` with an option with more fine grained control.
Specifically an option `--verification-flavor={none, if-else-fatal, immediate, sva}` is added. `none` is the option for the current behaviour that uses per-op configuration (which must be deprecated once after `has_been_reset` is properly used for assertions that are expected to be disabled while pre-resets). 

Close https://github.com/llvm/circt/issues/6543
2024-04-02 14:09:38 +09: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
Mike Urbach 1cc1069969
[OM] Add C API and Python bindings for IntegerAttr to string. (#6787)
Both the upstream MLIR IntegerAttr and OM IntegerAttr are backed by an
arbitrary precision integer. However, the upstream Python bindings
don't have any mechanism to return an integer larger than 64 bits back
to Python, even though Python ints are also arbitrary precision
integers.

To support this, we can handle this where we explicitly convert OM
IntegerAttrs to Python values. The simplest thing is to print a string
representation of the arbitrary precision integer, and parse that to a
Python int. This adds the necessary C API and Python binding for a "to
string" method, and uses it in the attribute_to_var function.

There are smarter ways we can handle the conversion, but the "to
string" API seems generally useful, so I'm using that in the
conversion for now.
2024-03-07 18:46:37 -07:00
Mike Urbach 675716b168
[OM] Add C API and Python bindings for EvaluatorValue::Reference. (#6785)
In some OM dialect constructs, it is possible to receive
EvaluatorValue::Reference values. In the Python bindings, where we are
converting an EvaluatorValue to a Python value, we need to dereference
the Reference, to get at the underlying EvaluatorValue that was set
during evaluation.

This adds the necessary C APIs, and updates the Python bindings to use
them. If we encounter a Reference, we dereference it and recursively
call the converter function.

A Python test was added using an example IR from the Evaluator unit
tests, which delays evaluation and introduces references.
2024-03-05 15:49:35 -07:00
Schuyler Eldridge 077826e06c
[capi][python] Add Emit Dialect
Add the emit dialect to the C-API and to Python.  This is both missing and
is necessary for downstream Python tooling to not break.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-03-02 17:14:23 -05:00
Asuna d010dd4423 [FIRRTL] Make function `importAnnotationsFromJSONRaw` public 2024-02-24 02:32:24 +08:00
Asuna dd0f4905aa [FIRRTL][CAPI] Add function for importing annotations 2024-02-24 02:32:24 +08:00
Mike Urbach 69b456df34 [CAPI] Try again to fix dependency leading to Python wheel failures.
The previous fix in https://github.com/llvm/circt/pull/6572 did not
get to the root of the issue. In fact, it didn't even work around the
issue correctly, because the added DEPENDS was on the wrong
target. This attempts to remedy that by changing the DEPENDS to the
actual target that was missing before.

The real issue to this problem is in the CFToHandshake.h header, and
tracked here: https://github.com/llvm/circt/issues/6693.
2024-02-13 23:05:49 -07:00
John Demme 5cdff6351f [Python] Register the comb dialect lowerings 2024-01-31 21:20:11 +00:00
Asuna 9ce35f8839 [HW][CAPI] Add instance graph C-API for iterating modules 2024-01-31 06:47:51 +08:00
Sprite 7b7134c4fd [FIRRTL][CAPI] Expose `foldFlow` function 2024-01-18 08:35:52 +08:00
Mike Urbach f02e5ea64c
[FSM] Add CAPI dependency on conversion pass header generation. (#6572)
When the conversion from FSM to SV was added to the CAPI, an include
of the circt/Conversion/Passes.h header was included for the pass
registration function. But nothing guarantees the generated header
that is included by Passes.h actually exists.

We have seen intermittent failures from it not existing, for example:
https://github.com/llvm/circt/actions/runs/7474242994/job/20339994666

This adds a DEPENDS on the target that generates the missing header,
so it will be available.
2024-01-11 12:06:53 -07:00
Nandor Licker cc8fabb16d
[Sim] Initial implementation of the `sim` dialect (#6561) 2024-01-10 18:02:39 +02: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
Will Dietz 2bc975079d [CAPI][Firtool] Don't use default in covered switches over enums.
https://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations
2023-12-07 10:26:40 -06:00
Sprite d6b83cc174 [FIRRTL][CAPI] Build open bundle for fields containing non-base types 2023-12-07 02:46:42 +08:00
Sprite 3b7d738056 [FIRRTL][CAPI] Add the rest of setters for options 2023-11-30 16:26:55 +08:00
Fabian Schuiki 878303a1fe
[Python] Add debug dialect bindings (#6471)
Add basic Python bindings for the debug dialect.
2023-11-29 15:02:59 -08:00
Fabian Schuiki 1d7ee186c1
[NFC] Homogenize file headers in CAPI/Python bindings
Adjust the header comments in the CAPI and Python bindings files such
that they are more in-line with the rest of CIRCT.
2023-11-29 13:19:38 -08:00
John Demme 2310234eb8
[ESI][Manifest] Make service records required (#6461)
Build them before calling the generator then let the generator modify
it. Ensures that it is always present even if the generator ignores it.
2023-11-28 19:58:22 -08:00
Andrew Lenharth 12c35d96b4 [NFC] clean up a few attributes which should be symbols attributes 2023-11-28 14:21:46 -06:00
John Demme 0ca237ae7d [ESI][Python] Allow AppIDAttr to have null idx 2023-11-28 07:21:20 +00:00
Andrew Lenharth ae62ffdbc5 [CAPI] Fix broken build 2023-11-27 12:48:51 -06: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
fzi-hielscher f37fe720e6
[Firtool][CAPI] Remove dedup option (#6423) 2023-11-17 00:14:53 +01:00
Sprite e118358778 [FIRRTL][CAPI] Add functions for property types 2023-11-14 22:50:26 +08:00
fzi-hielscher b8d69d5cc0
[HW] Reference struct/union fields by index (#6266)
This PR changes the HW StructExtract, StructInject, UnionCreate and UnionExtract ops to reference their accessed field by the respective aggregate type's field index instead of the field name. This allows us to access the field's FieldInfo struct directly instead of having to traverse the array to find the matching name.
2023-11-01 22:29:22 +01:00
Mike Urbach 6e1ae3c390
[OM] Add Python bindings for path types. (#6361)
In order to use the types in Python with isinstance, etc., we need to
provide the mlir_type_subclass bindings. This adds the C API
boilerplate and binds the types.
2023-10-31 15:43:37 -06:00
John Demme 03e1d94d5c
[ESI] Rip out Cap'nProto schema generation (#6349)
This turned out to be a bad idea. We're still using Cap'nProto for Cosim, just with the message being a blob which is already encoded by the client. This is nearly identical to what happens in hardware, just Cap'nProto/DPI as the transport layer.

Goodbye old frenemy.
2023-10-26 19:58:24 -07:00
John Demme d89f7d825b
[ESI] Service requests now track AppIDs rather than instance hierarchy (#6328)
This makes for far more sensible hierarchies. Also makes the index field of AppIDs optional.
2023-10-23 14:00:08 -07:00
Andrew Young 4ec8cb388d
[OM] Add evaluator support for paths (#6320)
This change adds evaluator support for frozen paths.

Two new EvaluatorValues have been added, one for BasePaths, which
represent fragments of paths through the instance hiearchy, and one for
Paths, which represent a full path to a hardware component.

When the evaluator instantiates an OM class, it is expected that it will
usually have to pass in an empty basepath, which signifies that the
class is at the top of the hierarchy. To facilitate this, we exposed the
ability to create an empty basepath value in the python API.

Path values can be transformed in to strings, where in they are printed
as FIRRTL style target paths. In the future, we may want a richer API.
Deleted paths are represented as Path values with the targetKind
attribute nulled out, which is handled specially in the string
serializer.
2023-10-20 09:56:39 -07:00
George Lyon 55505ebcb9
firtoolPopulateCHIRRTLToLowFIRRTL doesn't need a module (#6304) 2023-10-19 12:38:03 -07:00
Andrew Young 8e4992be35
[OM] Overhaul of path operations (#6253)
This PR does an overhaul of how path related operations work in the OM dialect.

When OM classes are created from FIRRTL, a base path is now fed through the
class hieararchy.  All paths to hardware objects are now created relative to
the base path.  The `path` op has been renamed to `path_create`, and now takes
a basepath SSA parameter, which means that it is impossible to create a path
which is not relative to some base.

A second set of operations to create "frozen paths" have been added.  In
FreezePaths, we lower all path operations to hard-coded strings, which allows
us to remove the hardware from the OM IR and still be valid.  These operations
have been changed to return `FrozenPathType`, which is to make sure that people
don't try to inter-mix the two kinds of path types.  The intention is that the
evaluator will only understand frozen paths.

The PathAttr in OM no longer represents the entire target path, but just the
list of instances which lead up to it.

This also adds an OM utility for parsing FIRRTL style target strings, which is
used in the `frozenpath_create` MLIR assembly format.  The existing APIs
contained in FIRRTL were not suitable since these new strings do not include
the circuit name, and we need some restrictions for parsing base paths, which
can not target components. The new parser is a bit more resilient to badly
formed path strings. In the future it may be possible to reunite these two
bodies of code.

The existing python support for paths had to be removed.
2023-10-11 12:33:10 -07:00
Nandor Licker dadf87b742 [NFC][firtool] Fix CAPI 2023-10-11 04:24:33 -07:00
Prithayan Barua cbc8c39613
[OM] Add location info to EvaluatorValue (#6240)
Add the debug locations to the evaluator value, which will be used to generate info fields
 of the object model output json.
2023-10-10 10:06:38 -07:00
Hideto Ueno 5508c1e42a
[OM] Evaluator: Support graph regions (#6249)
This commit adds support for graph regions for evaluator.

`ReferenceValue`, a new subclass of `EvaluatorValue`, is added to behave as pointers. `ReferenceValue` can be used as alias to different values and is created for `class.object.field` operation because `class.object.field` can access fields across class hierarchies and the fields might not be initilized yet. `RefenceValue` is not exposed to outside of evaluator implemenation. `EvaluatorValue::finalize` shrinks intermidiate `RefenceValue` in the evaluator value.

Evaluation algorithm is changed to worklist-based iteration. `instantiae` method first traverses the whole IR including sub-class, and create partially evaluaed values for all values and add these values to the worklist. After that we evaluate values until there is no partially evaluaed value.

Fix https://github.com/llvm/circt/issues/5834
2023-10-06 03:24:38 +09:00
John Demme 77dfbd01c5
[ESI][Python] Expose BundleType to Python (#6248) 2023-10-03 20:55:42 -07:00
Andrew Lenharth f14cbe3b25 [NFC] LLVM bump 2023-10-03 09:24:06 -05:00
Hideto Ueno e05d172607
[OM] Implement PathAttr CAPI and Python binding (#6229)
This commit implements PathAttr CAPI and Python bindings.
2023-10-02 22:10:02 +09:00
Sprite b636edaef1 [Firtool][CAPI] Add options setters and getters 2023-09-30 21:53:23 +08:00
Sprite a01f3db3cc [Firtool][CAPI] Add C-API for Firtool lib 2023-09-30 21:53:23 +08:00
Schuyler Eldridge 48a2c30c67
[FIRRTL] latestFIRVersion -> exportFIRVersion, NFC
Change the name of the constexpr `latestFIRVersion` to `exportFIRVersion`
as this is not the "latest" version, but the version that is used when
exporting FIRRTL.  This will avoid confusion about what this is.

Make the `exportFIRVersion` the same as the `nextFIRVersion`.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2023-09-28 13:54:45 -04:00
Prithayan Barua 6607338e34
[OM][Bindings] Make Python Evaluator Object hashable (#6204)
Implement the proper `__hash__` and `__eq__` methods for Object, such that it
 can be used in dictionaries. This is required to ensure we use mlir object
 reference for equality and hashing, rather than the default methods provided
 by python.
 Hashable::
 "In Python, a "hashable" object is an object that has a hash value that remains
 constant throughout its lifetime and can be compared to other objects.
 User-defined classes need to implement the `__hash__()` and `__eq__()` methods
 to be hashable."
 In the OM dialect, we want there to be "reference semantics". In other words,
 two objects with identical classes and fields should not be "the same" if they
 are created from separate instances in the elaborated object graph that the
 Evaluator sees. In addition, due to presence of cyclic dependencies, value
 equivalence cannot be determined and reference semantics is required.
2023-09-27 08:35:32 -07:00
Schuyler Eldridge 993732aa1c
Remove GlobalRefOp, GlobalRefAttr
Remove the now unused global reference operations and attributes.  These
have been fully migrated to HierPathOp.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2023-09-22 11:11:50 -04:00
John Demme 1b901c33b8
[NFC][ESI][MSFT] Move AppIDs over to ESI (#6177)
Since AppIDs serve as system identifiers, they classify as a system
construction feature. So they should be in the ESI dialect, which will
be using them shortly.
2023-09-21 18:11:30 -07:00
John Demme 0510ad8caa [MSFT] AppIDIndex add methods for querying paths
- `getChildAppIDsOf` to inquire about all of the AppIDs contained by a
module.
- `getAppIDPathAttr` to get the path to an AppID from a moduled.
2023-09-21 02:29:20 +00:00
John Demme a9f55cab80
[MSFT] Make AppID discovery an index rather than a pass (#6152)
Discovering AppIDs used to be a pass and only worked on `msft.module`s. Since we're removing them, make AppID discovery an API which creates dynamic instances from AppIDs. Since it'll primarily be used from PyCDE, expose to Python. Test through Python.

Will remove the discover appid pass in a subsequent PR. Progress on #6109.
2023-09-20 13:17:43 -07:00
Prithayan Barua 10da65bf1d
[OM] Python bindings for om integer (#6042)
Implement the python bindings for the `om.integer` attribute. Add support to
 create `om::IntegerAttr` from `mlir::IntegerAttr`. Also ensure all tests use
 `om::IntegerAttr` instead of `mlir::IntegerAttr`.
2023-09-19 13:41:46 -07:00
Hideto Ueno 8129d5de50
[HW][Python] Add name getters for ModuleType (#6149)
`argNames` and `resultNames` attributes were removed from HWModule (https://github.com/llvm/circt/pull/6095) in the presence of ModuleType but downstream python tools are relying these attributes for name look up. However currently there is no CAPI/Python API for ModuleType to query names of ports so this PR adds CAPI and bindings respectively in the same way to port types.
2023-09-20 00:45:01 +09:00
Nandor Licker 0fc8656168
[Seq] Switch all seq ops to use seq.clock (#6139) 2023-09-18 16:38:32 +03:00
John Demme e23e94542f [MSFT] Introduce AppIDPathAttr
Represents a full appid path. Just a list of AppIDAttrs components and a
root module. Expose to Python.
2023-09-14 22:43:49 +00:00
John Demme fec17895c8 [Python] Expose OutputFileAttr to Python 2023-09-14 02:51:41 +00:00