Commit Graph

4514 Commits

Author SHA1 Message Date
Will Dietz 0cff5d90dd
[FIRRTL] Add generic intrinsic op. (#6874)
Add generic intrinsic operation to FIRRTL. Not used anywhere, just adding to the IR to build on.
Re-use module parameter printing/parsing for use as custom printer on the op.

See PR for more context.
2024-03-27 09:17:38 -05:00
Mike Urbach c6325d287c [FIRRTL] Use cached circuit symbol table for option group lookup.
Now that we've added a cached symbol table at the circuit level, we
can use that to look up option groups as well. This didn't have a
major performance improvement on some large designs, but in the
presence of more instance choices, this could help. Regardless, this
is one minor piece to clean up for #6772.
2024-03-26 09:20:03 -07:00
Andrew Lenharth 8b9e87dc7f
[FIRRTL] Cache a symbol table instead of doing linear lookups every instance. (#6871)
roughly triples modules parsing performance on large designs. This is about a 2x speedup for overall parsing stage.  Mostly solves #6772 for now.
2024-03-25 16:58:29 -05:00
Andrew Lenharth 056d519468 [NFC] Reserve memory to save reallocations. Noted in performance profiling 2024-03-25 11:03:15 -05:00
Schuyler Eldridge 2b482b219d
[SV] Add namespace comment, nfc
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-03-24 00:54:47 -04:00
Schuyler Eldridge 08fb99b930
[SV][Verif] Extract verif ops in SVExtractTestCode (#6865)
Fix a bug where SVExtractTestCode was not extracting asserts, assumes, and
covers from the verif dialect.  This resulted in unexpected end-to-end
"failures" from Chisel where Chisel asserts, assumes, and covers were not
extracted and left in the design.

Fixes #6864.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2024-03-24 00:54:24 -04:00
Martin Erhart f8c7faec1e
[SMT] Add function application operation, function and uninterpreted sort types (#6847) 2024-03-22 17:13:18 +01:00
Martin Erhart 6f0fc3de79
[SMT] Add quantifier operations (#6842) 2024-03-22 16:56:50 +01:00
Andrew Lenharth 7a01c493b6 [NFC] silence unused warnings 2024-03-21 13:57:44 -07:00
Nandor Licker 92886e106e
[Seq] Erase memories with no read ports (#6861) 2024-03-21 17:44:24 +02:00
Will Dietz d5327de174
[FIRRTL] Make "intrinsic" name of intmodule mandatory. (#6858)
It's mandatory in the FIRRTL spec and only an error if it's missing,
so directly require this.

Add test for this and invalid intrinsic name.
2024-03-20 16:35:34 -05:00
Will Dietz e4b78d771a
[FIRRTL] Remove support for circt.Intrinsic annotation. (#6857)
Documentation indicates this was intended to be removed once
FIRRTL language supports intrinsics, and we have intmodule's now.
2024-03-20 14:46:06 -05:00
Will Dietz feb974d493
[HW][IST] Verify simple inner-ref-user ops sequentially, perf fix. (#6850)
When an IRN has a huge number of top-level operations that need inner
ref verification, the current code scaled poorly as the amount of
per-op verification work is tiny (handful of hashtable lookups)
compared to the overhead and atomic access of failableParallelForEach.

Scan through the operations sequentially as a pre-pass and directly
verify operations with no regions, only using parallelization for
verifying recursive walks of modules.
2024-03-19 15:43:28 -05:00
Nandor Licker fef273b308 [NFC][Emit] Add a method to get the attribute name 2024-03-19 11:13:22 -07:00
fzi-hielscher c8c6648b69
Move 'using namespace' out of headers. (#6844) 2024-03-18 16:57:03 +01:00
Nandor Licker 6d40b286c2
[Emit] Copy fragments into modules created by ExtractTestCode (#6843) 2024-03-18 16:32:24 +02:00
Martin Erhart 4b075de691
[SMT] Add integer constant and arithmetic operations (#6838) 2024-03-18 10:12:39 +01:00
Martin Erhart 7a5635825a
[Verif] Add LEC operation (#6832) 2024-03-17 18:33:09 +01:00
Martin Erhart c406400196
[SMT] Add constant boolean operation (#6825) 2024-03-17 18:28:00 +01:00
Martin Erhart d331d81742
[SMT] Add concat, extract, repeat operations (#6813) 2024-03-17 17:03:12 +01:00
Martin Erhart 21ee35b936
[SMT] Add comparison operations (#6807) 2024-03-17 16:20:18 +01:00
Martin Erhart 4fadae60a9
[SMT] Add declare_const, assert, solver, and check operations (#6806) 2024-03-17 15:48:15 +01:00
Mike Urbach afaf4da94e [FIRRTL] Handle either kind of path attribute in LowerClasses.
Sometimes the start of a hierarchical path is an InnerRefAttr, and
sometimes the path is just a single FlatSymbolRefAttr. Either way, we
just need the StringAttr refering to the module name. There is a
helper called `root` for this on HierPathOp. But at this point we are
constructing the path to build a HierPathOp, we don't already have
one. So, I've implemented this the same as how `root` is implemented.
2024-03-16 16:57:49 -07:00
Prithayan Barua 52a53ca819
[InferReadWrite] Set builder insertion point to ensure dominance (#6836)
This fixes a bug in InferReadWrite, the builder was not respecting dominance when updating the IR.
Ensure that the builder creates the constant at the start of the module.
The bug was introduced in #6818
2024-03-15 23:55:19 -07:00
Mike Urbach 0db5224b76 [OM] Update printer for OMDeleted targets.
All targets require the colon after the target kind, even OMDeleted.
2024-03-15 12:38:45 -07:00
Mike Urbach f1d478b71f [FIRRTL] Update parser for OMDeleted targets.
All targets require the colon after the target kind, even OMDeleted.
2024-03-15 12:24:18 -07:00
Nandor Licker c84846442d
[FIRParser] Do not swallow stop ops when parsing FIR (#6834) 2024-03-15 20:08:03 +02:00
Martin Erhart 6914bc6e0d
[SMT] Add basic array operations (#6827) 2024-03-15 00:29:29 +01:00
Mike Urbach bea85107e8 Revert "[FIRRTL] Dedup memory wrapper modules in LowerMemory (#6719)"
This reverts commit 2e23cda6c2.

This change caused memories that were previously deduping to no
longer dedupe, so we're reverting this while we investigate. An
issue will be created to include a small reproducer and track
re-landing this change.
2024-03-14 13:25:50 -07:00
Prithayan Barua a25a583e9f
[InferReadWrite] Add heuristic to infer unmasked memory (#6790)
This PR updates the heuristic to infer an unmasked memory.
If all the bits of the mask signal are driven by the same value, then it can
 be replaced with an unmasked memory. 
(Example:  `mem_RW0_wmask = {6{baseWrEn_F1}}`)
This is an attempt to fix a use case, in which firtool introduces masked memory
 for an aggregate data type when the user expected an unmasked one.
2024-03-14 13:14:49 -07:00
Prithayan Barua 315892fffa
[InferRW] Remove dependence of write-mode on enable for memory (#6818)
The read-write port of a memory has an input enable `en` signal and a
 write-mode `wmode` signal. The `en` signal enables the port for either
 read/write mode. The `wmode` is enabled to set the memory in the write mode
 and disabled to read from the memory.
This PR removes the dependency of `wmode` on the `en` signal of a read-write
 port of a memory.
The `wmode` signal matters only if the `en` is enabled, hence traverse the
 expression tree for the `wmode` and replace `en` with a constant `1`.
2024-03-14 11:50:49 -07:00
Will Dietz b6f50d69e5
[FIRRTL][LowerAnnotations] Fix non-probe type compat check. (#6822)
Compatibility dest/source operands were backwards,
introduced in #4656 .

Add test as "legacy wiring" as non-ref-type-port path is a hidden option.

Fixes #6819.
2024-03-14 09:48:58 -05:00
Nandor Licker 9c4f72147f
[Emit] Group file header ops into `emit.fragment` (#6789)
Instead of using the replicated op mechanism, fragments of SV code
which must precede certain modules are grouped into fragment ops.
Modules which rely on them reference them through a `emit.fragment`
attribute. The fragments are printed through ExportVerilog.

Subsequent PRs will fully replace replaced ops using fragments.
2024-03-14 09:16:04 +02:00
John Demme 1080acbc22 [ESI][Runtime] Bumping JSON library to avoid CVEs
v3.11.2 had a requirements.txt file which had some python libs which
have the following security alerts:

CVE-2022-21797, joblib 1.1.0, Critical
CVE-2023-40267, gitpython 3.1.27, Critical
2024-03-14 03:22:12 +00:00
Fabian Schuiki c970974165
[ImportVerilog] Add basic expressions (#6788)
Extend the `ImportVerilog` conversion to support most of the basic
expressions that commonly appear in SystemVerilog input files. Also add
the correpsonding expression ops to the Moore dialect, and finally get
rid of the old MIR expressions file which is now obsolete.

Thanks @hailongSun2000 and @albertethon for doing a lot of the leg work
to get expression support in!

Co-authored-by: Hailong Sun <hailong.sun@terapines.com>
Co-authored-by: ShiZuoye <albertethon@163.com>
Co-authored-by: Martin Erhart <maerhart@outlook.com>
2024-03-13 16:57:53 -07:00
Mike Urbach fed17ee2cb
[FIRRTL] Support alternative base paths in LowerClasses. (#6817)
* [FIRRTL] Support alternative base paths in LowerClasses.

We previously had a constraint that paths are targeting entities in
the same owning module as the path. This allowed us to assume that a
single base path can be created for each owning module, and used in
all paths. However, we have transforms that extract entities targeted
by paths outside the paths' owning module.

To support this, we can instead plumb through base paths created
higher up in the instance graph down to the paths that need them. When
a path is detected outside the owning module, we find the module in
which the entity is instantiated and pass through its base path to the
paths that reference the entity.

Most of the work here is just plumbing, and the PathInfoTable has been
extended with new data structures and functions to support this.
2024-03-13 16:05:02 -06:00
Will Dietz fea328a1c0
[FIRRTL][CheckCombLoops] don't crash on force+rwprobeop, workaround. (#6821)
Unbreak this, at cost of missing loops through force, while
the better fix is being worked out.

cc #6820.
2024-03-13 13:58:18 -05:00
Mike Urbach 13b9456efc [FIRRTL] Memoize calls to shouldCreateClass in LowerClasses, NFC.
This is already called in multiple places, and we will soon use it in
another situation. This can be expensive, so it is worth memoizing to
avoid repeatedly traversing the module bodies in the slow case.
2024-03-12 20:16:45 -07:00
Mike Urbach e438ac0907 [FIRRTL] Make PathInfoTable a struct in LowerClasses, NFC.
To handle more complex situations, we will soon need to track some
more information related to paths. This carves out PathInfoTable as a
struct so we can add more fields for use in the same places as the
existing map.
2024-03-12 20:16:33 -07:00
Mike Urbach 52f4828260 Revert "[FIRRTL] Don't enforce owning module for local ref in LowerClasses. (#6811)"
This reverts commit c12c68d3a2.

This was a quick workaround, but a better solution is being developed.
2024-03-12 20:15:23 -07:00
Martin Erhart 7e0ae45817
[SMT] Add bitvector type, attribute, and constant operation (#6804)
To clearly separate semantics, define a bit-vector type and attribute instead of reusing the built-in integer attribute. The built-in integer is usually encoded using two SMT bit-vectors to model poison and the regular bit values.
2024-03-12 08:27:58 +01:00
Martin Erhart 8b4e95de1e [SMT] Add Dialect rationale and boilerplate 2024-03-12 08:12:50 +01:00
Mike Urbach c12c68d3a2
[FIRRTL] Don't enforce owning module for local ref in LowerClasses. (#6811)
We have an existing check that paths are in the same owning module as
the entity they target. This is absolutely required for hierarchical
references to compose with basepaths. However, we have legacy flows
that extract entities out of their owning module, and we want to be
able to target those things. This works around these conflicting
requirements by skipping the owning module check for local targets
only. This is safe because we still check such local targets are only
instantiated once, so there is no ambiguity even though they are not
instantiated within the owning module.
2024-03-11 19:25:07 -06:00
Nandor Licker 4d5dab52e2 [NFC][Emit] Replace body with bodyRegion 2024-03-11 06:29:21 -07:00
Tynan McAuley 2e23cda6c2
[FIRRTL] Dedup memory wrapper modules in LowerMemory (#6719)
Instead of just dedup-ing the external memory module, include the
memory wrapper module in the dedup calculation.

Resolves #6445.
2024-03-10 19:08:34 -07:00
Andrew Lenharth eb5900a6e7 [NFC] Checking the number of input and output locations for modules was dead code. Producing those lists was driven by the number of such ports, so testing that you got the right number was just checking the loop bounds that produced it. the get(In|Out)put* functions are inefficient and need to go away, but this saves 11.5 minutes in large designs. We also save a minute and a half pre-sizing a small vector. 2024-03-10 13:06:59 -05:00
Andrew Lenharth c8ad1d6376 [NFC] Save 60% of the time spent creating integer types 2024-03-09 20:08:23 -06:00
Fabian Schuiki 99968ff076
[FIRRTL] Fix sign bit truncation in constant parser (#6794)
Fix an issue in the parser of the `firrtl.constant` op, which would
truncate the sign bit of negative constants without reporting an error.
This would for example accept -2 as a valid 1-bit constant, truncating
the `...11111110` bit pattern to `0`.
2024-03-08 12:10:45 -08:00
Nandor Licker 95a2f948b7 [NFC][Seq] Improve the naming of clock inverters from intrinsics 2024-03-07 22:49:22 -08:00
Mike Urbach 993e491f4b
[OM] Extend APSInts as necessary before performing arithmetic. (#6786)
Most interesting arithmetic on APSInt asserts that both operands are
the same bitwidth, but the IntegerAttrs that we are working with may
have used the smallest necessary bitwidth to represent the number they
hold, and won't necessarily match.

This extends the smaller operand if necessary. This is safe to do,
even for operands like the RHS of a shift right, because it will zero
or sign extend without adding "significant bits" in the APSInt
representation. So if we had a shift right amount that previously fit
in 64 bits, and we had to extend it beyond 64 bits, we are still able
to truncate to 64 bits when performing the shift.
2024-03-07 18:06:50 -07:00