Commit Graph

2504 Commits

Author SHA1 Message Date
Anurudh Peduri 34832f42df
[LLHD] Replace llhd.neg with comb.sub (#1654) (#1678)
* [LLHD] Replace llhd.neg with comb.sub (#1654)

* [LLHD][test] remove repeated test for `comb.sub`
2021-08-31 18:21:10 +02: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
Schuyler Eldridge 8ae1b2857e
[FIRRTL] Fix Subfield/Subindex DontTouch Parsing
Fix a bug in the parser where a DontTouchAnnotation on a subfield would
not cause names to be preserved.  Use the simplest solution here of
using the hasDontTouch method of AnnotationSet as opposed to the older
version of the method of the same name in the parser.  Remove the old
hasDontTouch method in the parser (since this is now unused).

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-08-31 00:34:24 -04:00
Chris Gyurgyik f99cd12c72
[Calyx] Add more operations for emission to native compiler. (#1662)
Adds emitters for: RegisterOp, MemoryOp, GroupGoOp, GroupDoneOp, SeqOp, 
WhileOp, IfOp, EnableOp, combinational guards. Remove HasParent trait from 
MemoryOp since this is checked by the Cell trait (inherited by CalyxCell). Move 
base class for CalyxPrimitive to CalyxPrimitives.td. Add helper functions for string
literals. Add simple emitter for imports.
2021-08-30 19:34:37 -07:00
Schuyler Eldridge 7e06c705c1
[FIRRTL] Don't fold regreset away if don't touch'd
Add a check that the foldResetMux rewrite pattern isn't used for
firrtl.regreset if the reset has a DontTouchAnnotation.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-08-30 19:58:57 -04: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 e9763ffc08
[FIRRT] use a cached symbol table for resolution of modules (#1673)
Let passes use a prepopulated symbol table to resolve modules for instances.
2021-08-30 15:30:34 -05:00
Andrew Lenharth e29ecdae62 [FIRRTL] Only resolve symbol once per instance 2021-08-30 15:01:17 -05:00
Chris Gyurgyik 216e07fdc4
[Calyx] Add verifier for AssignOp. (#1661)
Add verifier for AssignOp. This does NOT address drive-ability of `Cell`s.
2021-08-30 11:17:00 -07:00
Morten Borup Petersen 1c180c2485
[Calyx] Add helper functions to access MemoryOp ports (#1635) (#1663)
* [Calyx] Add helper functions to access MemoryOp ports #1635

* Review nits
2021-08-30 16:35:42 +01:00
Fabian Schuiki 1a81fae165
[FIRRTL] Add data taps integration test, fix issues (#1664)
Add the `DataTapTests` from the Scala implementation of FIRRTL as an
integration test for the FIRRTL dialect. This uncovers a few subtle
breakages in the `GrandCentralTaps` introduced by changes to the
annotation scattering code that happened a while back. This fixes those
issues and the test ensures we don't have any regressions of this in the
future.
2021-08-30 17:34:15 +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
Andrew Lenharth 693a2e2480 [FIRRTL] Add some more aggregate type manipulation utils 2021-08-30 10:14:37 -05:00
Martin Erhart 9146f17b83
[LLHD] Replace standard dialect arithmetic ops with comb ops (#1660)
* [LLHD] Replace standard dialect arithmetic ops with comb ops

* Small fixes

* comb.icmp support

* Support remaining operations

* Small fix
2021-08-30 16:00:56 +02:00
Morten Borup Petersen e371b23583 [Calyx] Fix typo in MemoryOp builder
An "instanceName" attribute is expected for a Cell, not a "name".
2021-08-30 13:36:01 +01:00
Chris Lattner 8197ffd2ec [SV/BindOp] Give sv.bind a symbol for the module enclosing the referenced instance.
This makes lookup much faster, even though it still requires IR scanning.
This speeds up `firtool -extract-test-code -verilog` on a large design from
550s to 120s.  There is still more to go though, as a -verify-each=false
run completes in 60s - we're still spending more time verifying than doing
work.

This resolves issue #1647.
2021-08-29 09:01:32 -07:00
Chris Lattner a0274e48ee [ExportVerilog] Add the test that was intended to go with 3c8b4b47. NFC. 2021-08-28 21:43:19 -07:00
Chris Lattner 3c8b4b47b6 [ExportVerilog] Introduce a new "disallowLocalVariables" lowering option.
This is the first step to supporting verilog implementations like Yosys
and Icarus Verilog that don't support SystemVerilog "automatic logic"
variables in procedural scopes.

For this step we handle side effecting operations (like the RANDOM
macros in FIRRTL lowering) by spilling them to a local reg with a
blocking assignment, the same way SFC does.

This is one step towards resolving Issue #1633
2021-08-28 21:40:22 -07:00
Chris Lattner 5cdf159eea [ExportVerilog] Make isVerilogExpression available to the Prepare pass, NFC. 2021-08-28 21:18:58 -07:00
Chris Lattner 519561658a [PrettifyVerilog] Don't sink side-effecting expressions.
We don't want to change where the effects happen.  This was noticed
by inspection.
2021-08-28 21:01:26 -07:00
Chris Lattner ea883673b4 [ExportVerilog] Emit a loc comment on modules with location info.
FIRRTL files coming out of chisel don't seem to preserve module
locations typically even though they could, but other clients can
produce location info for them, and we should print it.
2021-08-28 17:42:12 -07:00
Chris Lattner 6821299c90 [LowerToHW] Move FIRRTLMem modules and give them a location.
Use of UnknownLoc is not encouraged.  Moving their insertion point
ensures the that file header boilerplate comes out on top.
2021-08-28 17:19:30 -07:00
Chris Lattner 7027a826ac [VerilogEmitter] Fix a race with sv.binds inside of hw.modules.
It turns out that sv.bind can exist inside of a hw.module as well
as at the top level.  These cause non-local references so we need
to make sure not to emit such modules concurrently with the modules
being emitted.

There is no good test for this, I noticed it due to a transient
failure of the existing ExportVerilog/sv-dialect.mlir test.
2021-08-28 12:32:06 -07:00
Andrew Young cf28c165da
[FIRParser] Support parsing larger vector sizes (#1651)
Using an `int32_t` to parse vector types limits our maximum vector
length to 2147483647. We have memory length 1 higher than that maximum,
and we need to use the `int64_t` parser to support it.
2021-08-28 12:20:48 -07:00
Chris Lattner 6a09c52db9 [IMConstProp] Use InstanceGraph more instead of calling "getReferencedModule".
getReferencedModule is a performance tarpit because it has to scan the top
level of the circuit to find the right module.   We already have the
instance graph, we should use it for all lookups.

This speeds up IMConstProp on a large testcase from 24s to 6.3s.
2021-08-28 12:01:34 -07:00
John Demme c397bff68d
[PyCDE] Setup.py to compile Python wheel (#1659) 2021-08-28 01:45:42 -07: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 62e02ac1f8 [ExportVerilog] Parallelize printing in the single-file case. NFC.
This parallelizes emission of operations when they are all emitted
to the same file by emitting to string buffers, then concatenating
them all at the end in series (simple map+reduce).

This speeds up emission of a large testcase on my laptop from 17s
to 5.2s, a 3.2x speedup.
2021-08-27 23:35:29 -07:00
Chris Lattner 90418d581c [ExportVerilog] Refactor file emission logic even more. NFC.
This splits the decision of "how to emit ops" from the "mechanics
of emitting them" logic by introducing a new StringOrOpToEmit
struct.
2021-08-27 23:04:18 -07:00
Chris Lattner 3508495800 [ExportVerilog] Print extern modules to only one file in split files mode.
This emits them all to a single extern_modules.sv file, instead of
replicating them in every .sv file.  This resolves Issue #1646.
2021-08-27 22:16:05 -07:00
Chris Lattner a08794cd1c [ExportVerilog] Further narrow the interface used by SharedEmitterState::emitOperation. NFC. 2021-08-27 21:36:35 -07:00
Chris Lattner 3a85c9aa03 [ExportVerilog] Further refactor interface to emitHWModule. NFC.
This pulls "prepare" pass invocation into it, reducing coupling.
2021-08-27 21:31:25 -07:00
Chris Lattner fdca31f460 [ExportVerilog] Refactor the "prepareHWModule" invocation, NFC.
This makes it part of the parallel emission when emitting split files,
and avoids having to keep the `ModuleNameManager` in memory for every
module in the circuit before emitting each file.  This speeds up
split-verilog emission on a large design from 8.3s to 5.8s (~30%).
2021-08-27 21:26:18 -07:00
Chris Lattner 18d7cf2050 [SVExtractTestCode] Put generated modules next to the thing we extracted from.
Previously all the extracted assert/assume modules were put at the top of the
file.  This is a problem because the #ifdef boilerplate needs to come first.
2021-08-27 18:09:47 -07:00
Chris Lattner e5f29613d3 [ExportVerilog] Use SymbolCache in the prepare pass to speed up lookups.
These aren't common, but might as use this since it is available.
2021-08-27 17:55:28 -07:00
Chris Lattner e58d682422 [HW] Make SymbolCache references const correct. NFC. 2021-08-27 17:54:56 -07:00
Chris Lattner 143acdf04b [ExportVerilog] Adopt hw::SymbolCache to speed things up, NFC.
This builds a SymbolCache at setup time, when the verilog exporter
is scanning the ops to see what files they go into.  This cache is
then used when emitting each of the chunks, speeding up the
"getReferencedFoo" calls by turning them into O(1) lookups.

This speeds up export verilog on a large testcase that includes a
bunch of binds from 126s to 17s.  It should also help speedup
other normal cases as well, since each instance has to resolve the
module it refers to.
2021-08-27 17:42:29 -07:00
Chris Lattner 8348c2144c [HW] Introduce a new hw::SymbolCache class to accelerate symbol lookups.
The HW/SV dialects have a bunch of symbols used to map instances, modules,
interfaces etc, and corresponding "getReferencedXXX" methods to resolve
them.  Each of these resolutions is really slow - scanning huge amounts of
the IR to resolve them, so we should have a way to shortcut that when a
client has done a prepass.  The SymbolCache class allows making these faster.

This patch introduces the new functionality, but no clients of it.
2021-08-27 17:41:36 -07:00
Andrew Young 496d54347a
[FIRRTL] Fix crashing regreset canonicalizer
This crashes if `reg.resetValue()` is a block argument and return
`getDefiningOp()` returns nullptr.
2021-08-27 17:36:51 -07:00
Chris Lattner e5b74d2806 Make use of a helper function to simplify some code, NFC. 2021-08-27 17:15:04 -07:00
Chris Lattner 78986e364c [ExportVerilog] Split all the PrepareForEmission stuff out to its own file.
ExportVerilog.cpp is too monolithic, and the logic for this was scattered
around the file.  Pull it together into its own thing.
2021-08-27 14:41:15 -07:00
Morten Borup Petersen 92a47a7f0d Fix typo in add_circt_interface CMake function 2021-08-27 21:03:18 +01:00
Fabian Schuiki 8b3aa8c61b
[FIRRTL] Resolve portAnnotations/arg_attrs ambiguity (#1645)
Most of the FIRRTL code base expects port annotations to live in the
`portAnnotations` attribute on `FModuleOp` and `FExtModuleOp`. But the
parser, printer, and some operation builders accidentally store these in
`arg_attrs` through the standard argument attribute mechanism of MLIR.

This commit removes redundant/conflicting uses of `arg_attrs` and
`portAnnotations` in the code base. To keep things ergonomic for the
custom syntax of FIRRTL operations, we still parse and print port
annotations as part of the regular argument attributes (under the
`firrtl.annotations` key), but then immediately separate them out into
the `portAnnotations` attribute where all of our code expects this to
live.
2021-08-27 21:55:22 +02:00
Chris Lattner 49e5cdd668 [ExportVerilog] Refactor RootEmitterBase and subclasses, NFC.
This renames RootEmitterBase -> SharedEmitterState and eliminates
the subclasses.  The code is shorter and easier to understand without
them.
2021-08-27 12:37:01 -07: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
Andrew Lenharth 972b4fb316 [NFC][FIRRTL] Don't name unneeded fields in canonicalization patterns. 2021-08-27 11:21:22 -05:00