Commit Graph

1040 Commits

Author SHA1 Message Date
Chris Lattner 623e7ed584 [RTLCleanup] Merge consequtive procedural if's with the same condition.
This also fixes ifdef merging to only merge ifdefs with the same condition :-)
2021-02-21 11:23:06 -08:00
Chris Lattner ee01f0817b [RTLCleanup] Add support for merging procedural ifdefs.
This refactors the code a bit to split between procedural and graph
regions (which are semantically very different).  This also changes
the merging code to merge "down" instead of "up" which doesn't matter
for graph regions but is required for procedural regions.
2021-02-21 10:37:12 -08:00
Chris Lattner 93db31b6f7 [SV] Change ifdef ops to have a canonical way to represent ifndef.
Before we'd use "!FOO" as an identifier to get an inverted conditional.
Such a representation gives us two different ways to represent the same
thing and unnecessarily makes transformations on ifdefs (like merging
of them) more complicated.

Instead just put inverted logic into the else block, and have the verilog
exporter print a ifdef with no "then" as ifndef.

This patch also merges the code I duplicated in the verilog emitter for
the two ifdef cases.
2021-02-20 22:59:38 -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
Chris Lattner 9c62dc7102 [AlwaysFusion] Implement fusion of equivalent sv.ifdef nodes. 2021-02-20 22:26:14 -08:00
Chris Lattner 906690bf30 [SV] Split sv.ifdef into sv.ifdef and sv.ifdef.procedural.
The former can be used in graph regions, the later in procedural regions.
The later is marked with ProceduralRegion trait, and will eventually have
different requirements about its parent region.
2021-02-20 22:02:14 -08:00
Chris Lattner 5c0c1dba77 Fix a clang format issue I introduced (caught by the builder). NFC. 2021-02-20 21:45:31 -08:00
Chris Lattner 20b04d2369 [AlwaysFusion] Fix merging in the presence of top-level #ifdefs.
This changes the pass to do a post-order walk of the region tree, in
preparation for other changes.
2021-02-20 21:40:36 -08:00
Chris Lattner 334798e4a2 [AlwaysFusion] Make this pass be specific to RTLModuleOp instead of
being invoked on arbitrary ops.
2021-02-20 21:30:23 -08:00
John Demme 5ad5992b67 [ExportVerilog] Merging `MLIRModuleEmitter` and `ModuleEmitter` 2021-02-20 16:37:23 -08:00
Chris Lattner 49a3f99355 [FIRRTL] Fix Issue 606, problems handling flipped subindex operations. 2021-02-20 15:52:22 -08:00
Prithayan Barua d8f6a8a5cc
Fix gcc build issue with namespace (#613)
Co-authored-by: Prithayan Barua <prithayan@gatech.edu>
2021-02-18 09:58:17 -08:00
John Demme 764ffe317d
[Comb] Ditch InOut check and copy integer check into comb (#603) 2021-02-17 18:37:04 -08:00
John Demme 8296ba33a2
[ESI] [Cosim] Capnp schema struct output support (#612)
Output ESI structs to Capnp schemas.
2021-02-17 16:01:28 -08:00
mikeurbach 9fe29b465c
[HandshakeToFIRRTL] Add control buffering to BufferOp lowering. (#601)
Previously, the lowering would only buffer the data/valid
network. This adds buffering on the ready network.
2021-02-17 16:14:43 -07:00
mikeurbach f8b78d3dcf
[HandshakeToFIRRTL] Fix decoder one-hot vector width. (#600)
The previous calculation was done using the width of the entire 64-bit
index to dynamically shift a bit into a one-hot vector. This adds a
tail operation to only select the bits needed from the index. This
updates the decoder implementation to just compute the correct result
width of the dshl operation, and drops the unneeded pad.
2021-02-17 14:11:00 -07: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
John Demme da2260b6d3
[ESI] Add a named struct type (#611)
Just an RTL struct wrapped with a name.
2021-02-16 21:18:06 -08:00
John Demme 84f013aac6
[RTL/Comb] Remove the Comb namespace import in RTL (#605)
NFC
2021-02-16 20:00:46 -08:00
John Demme 6bd0b93ab9
[RTL] Create new 'comb' dialect and move all the RTL combinational ops into it (#599) 2021-02-16 16:04:52 -08:00
Andrew Young 624969af74 [ESI] Fix integration test issues
- Don't forward declare thread.  Does not work on OSX, and in general
  you can't forward declare classes from the `std` namespace.
- Fix namespace issues caused by e1ca6eaaf9.
- Fix cosim test: fix constants
2021-02-16 13:42:42 -08:00
John Demme 7d0c22d2c9
[ExportVerilog] Use 'wire' if in an RTL module, `logic' elsewhere (#594) 2021-02-16 10:05:28 -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 3a347bcc8e [ESI] [Cosim] Fixing decode assertions
Verilator wasn't catching these since it wasn't evaluating asserts.
2021-02-15 18:20:55 -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
Chris Lattner e63c15aa66 [AlwaysFusion] Minor tidying up. NFC
Shrink anonymous namespace, use "insert" in set instead of "find + insert"
to avoid double lookup, move a method out of line to reduce indentation.
2021-02-14 18:27:00 -08:00
Chris Lattner a72fb7757e [FIRRTL] Remove a const qualifier from method on FIRRTLType, NFC.
It is true that C++'s type system is barely usable, and is annoying
in this case in particular, but we follow MLIRs precedent here.
https://mlir.llvm.org/docs/Rationale/UsageOfConst/
2021-02-14 18:13:13 -08:00
Chris Lattner 0b8b8a9a4c Minor optimization to use a SmallDenseSet instead of StringSet, NFC.
This is a bit faster because we're just doing pointer hashing, instead
of comparing the strings themselves.  Attributes are already uniqued.
2021-02-14 17:59:41 -08:00
Chris Lattner 37fea952b3 [FIRParser] Fix Issue #563, handling "instance is invalid".
This broke with the change to move instances to return multiple results.
This change also fixes the parser to handle "is invalid" on passive types
correctly.
2021-02-14 17:50:24 -08:00
John Demme 8cebdd197c [RTL] [Integration Test] Add integration test for #439 2021-02-14 17:09:45 -08:00
Chris Lattner 20eefdeef5 [ExportVerilog] Fix Issue #438, supporting cyclic references correctly.
This emits out of line declations in the narrow case where we need
to avoid verilog use-before-def issues.
2021-02-14 15:06:23 -08:00
Chris Lattner 9bb4c5746e Remove the explicit std.module from this testcase to reduce a level of nesting, NFC. 2021-02-14 14:24:55 -08:00
Chris Lattner e043814d2c [ExportVerilog] Emit intermediate wires as 'logic' instead of 'wire'.
This allows them to compose more nicely into always blocks etc.

This should finish Issue #439
2021-02-14 14:21:33 -08:00
Chris Lattner e2b106ca2d [ExportVerilog] Emit multi-use SSA values as "logic" declarations instead of wire.
It turns out these are completely different forms in the SV spec (wire is a net,
logic is a var decl).  logic corresponds to what we actually need (single assignment
semantics) and can be used in nested blocks like an always, so we use it instead of
wire generally.

Explicit rtl.wire declarations and rtl.merge are still emitted as a wire of course.

This is progress towards issue #439.
2021-02-14 14:09:15 -08:00
Chris Lattner 26cf45600a [SV] Teach wire that it must be at the top level of an rtl.module.
Most of this is updating old testcases that uses the 'func' keyword
because module didn't yet have the nice syntax sugar it does now.
2021-02-14 14:03:31 -08:00
Shivam Gupta dc2cae4d48
Fix Windows warning about -fno-exceptions -fno-rtti (#592) 2021-02-14 08:26:01 +05:30
George Lyon 4133eb9082
Disable C API tests on Windows (#590) 2021-02-13 13:14:27 -08:00
John Demme 5cc86aaf0d
[RTL] Documenting endianness (#574) 2021-02-12 20:03:11 -08:00
John Demme 731f4574c5 [ESI] [Cosim] Fixing cosim test 'externmodule' -> 'module.extern' 2021-02-12 19:54:42 -08:00
Chris Lattner 132dfb8cc7 [ExportVerilog] Issue#439: Collect names recursively under scopes.
This makes sure we emit wire declarations for expressions that have
multiple uses correctly, avoiding an exponential blowup of verilog
in some cases, and emitting expressions that have to go through an
intermediate wire declaration.

This is currently emitting wire declarations within always blocks,
which I'm not sure is valid.  If not, I'll do a second follow up.
2021-02-12 17:45:15 -08:00
Chris Lattner fa5aade249 [FIRParser] fix Issue #559, ambiguity parsing port list.
We need a token of lookahead to tell the difference between an expression
using the 'output' identifier and the output specifier in a port list.  This
is a bit annoying to implement in the portlist parsing logic, so just add full
support for backtracking in the parser.
2021-02-12 16:25:21 -08:00
Schuyler Eldridge 4940394f38
[FIRRTL] Use "<=" (not "=") in mem write lowering
Switch from blocking assign to non-blocking assign in the always block
generated for a memory write port. This should fix one of the warnings
that Verilator generates as identified in issue #543.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-02-12 11:12:36 -05:00
Schuyler Eldridge 1bca4774dc
[FIRRTL] Fix warning/incorrect use of createOrFold
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-02-12 11:05:46 -05:00
Andrew Lenharth e36f779062 Missed a few module renames [NFC] 2021-02-12 09:33:58 -06:00
mikeurbach 807e77ae71
Fix StandardToHandshake dropping the LogicalResult return value from rewriteAffineFor. (#584)
This adds an explicit check for failure and errors
out the entire pass when rewriteAffineFor fails.
Add a test for this behavior.
2021-02-12 00:09:01 -07:00
Chris Lattner c883578c04 [LowerToRTL] Fix issue #572, lowering of analog types shouldn't assign a zero. 2021-02-11 21:04:05 -08:00
Chris Lattner 3a41df5f02 Silence some warnings and remove some dead code. 2021-02-11 18:27:43 -08:00
Andrew Young 68f746d7ab Do not construct unnecessary intermediate object
The brace initializer is not needed.  Keeping it here trips up the
function deduction in older version of GCC.  This was missed in the
first cleanup.
2021-02-11 15:41:01 -08:00