Commit Graph

20 Commits

Author SHA1 Message Date
Andrew Young 75a4f73e1b
[FIRRTL][CHIRRTL] Add `memoryport.access` operations (#1539)
The two CHIRRTL memory operations have been renamed from `smem` to
`seqmem` and `cmem` to `combmem`. In addition, instead of returning
`!firrtl.vector<>` types, they return a new type  `!firrtl.cmemory`.
This new type can only be used with CHIRRTL memories and ports, and
prevents some shenanigans where it could be used like a normal vector.

Memory ports in SFC are allowed to be used outside of the scope which they are
defined in. To work around this issue, the memory port declaration was split
into two operations:

1. `firrtl.memoryport`: This operation is the declaration of the memory port,
   and it should be emitted into the body of the module.

2. `firrtl.memoryport.acccess`: This operations is emitted to the location of
   the original memory port declaration, and is used for enable inference.

For more information about these new operations, and why we added them, see the
changes to FIRRTLRational.md.

This include changes to the FIR parser to emit these new operations.
2021-08-17 23:06:27 -07:00
Schuyler Eldridge f739c60260
[FIRRTL] Correct, Document Invalid Behavior (#1499)
Change FIRRTL dialect folders to use the Scala FIRRTL Compiler (SFC)
interpretation of invalid.  An invalid involving a non-mux primitive
operation is treated as a constant zero.  An invalid involving the true
or false paths of a multiplexer is treated as a conditionally valid
expression which always evaluates to the non-invalid path.

This intentionally deviates from the FIRRTL spec interpretation of
invalid as undefined behavior.  Invalidations are frequently generated
by Chisel (as a means of telling the SFC that an uninitialized component
is okay) and by a legacy version of Chisel ("Chisel 2 Compatibility
Mode") which defaults all connections to invalid to permanently disable
uninitialized checking.

Concretely, this adds the following boolean folds:

  - or(a, invalid) -> a
  - or(invalid, a) -> a
  - xor(a, invalid) -> a
  - xor(invalid, a) -> a

The following boolean folds already existed, but are documented with
information about the SFC interpretation of invalid:

  - and(a, invalid) -> 0
  - and(invalid, a) -> 0

Invalid value folders are also added for the following arithmetic
operations:

  - add(x, invalid) -> bits(x, width)
  - sub(x, invalid) -> bits(x, width)
  - mul(x, invalid) -> 0
  - div(invalid, x) -> 0
  - rem(invalid, x) -> 0

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-08-02 16:45:54 -04:00
Andrew Young 8bce7ffdc7
Add some more FIRRTL annotation documentation (#1330)
This moves the annotation documentation out of the FIRRTL rational and in to its own document. It expands the target section a little bit with some details from a Google Docs document. At the end of the document is reference style material for each annotation. This works pretty well for the simple annotations, but for GrandCentral each annotation had to have several tables to describe the format. Details were collected from the Scala source code and our tests.

The Scala format specifier was previously used to get decent highlighting for FIRRTL code, but this does not render well on the CIRCT website.
2021-06-30 18:48:22 -07:00
Abdelhakim Qbaich e5dd5eede6
[FIRParser] Parse RawString ExtModule Parameters (#1340) 2021-06-30 09:24:37 -07:00
Fabian Schuiki c4f6e59679
[FIRRTL] Add verbatim.expr operation (#1182)
* Add a `verbatim.expr` operation to the FIRRTL dialect which lowers to
  the corresponding operation in the SV dialect. This allows
  construction of FIRRTL-typed expressions from a string representation.

* Based on a suggestion by @lattner in #1178.
2021-06-03 19:48:42 +02:00
Chris Lattner 4d43103122 [RTL->HW] Rename the string "RTL" to "HW"
This makes sure not to rename FIRRTL to HWRTL :-), and I spot checked a
many things to avoid changing general references to RTL (e.g. when referring
to external tools) but I suspect that I missed some.  Please let me know (or
directly correct) any mistakes in this mechanical patch.
2021-05-15 12:44:05 -07:00
Schuyler Eldridge 71ad33e153
[FIRRTL] Update FIRRTL Rationale, NFC
Update the FIRRTL Rationale document with information regarding the
change of direction to align closely with FIRRTL IR and the Scala FIRRTL
Compiler, i.e., type canonicalization was removed and input/output are
no longer encoded using flip type.

Add a new section on Annotations, Targets, and the status/plan with
respect to Annotation migration.

Cleanup miscelaneous things:

- 80 character columns
- Use scala code fence modifier for FIRRTL IR code (this works pretty
  well for syntax highlighting)
- Add more info on how invalid is blown out during parsing
- Use "ANTLR" instead of "Antlr"

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-05-11 20:40:04 -04:00
Andrew Young 7f26748db2
[FIRRTL] Add section about names to the rationale (#966) 2021-04-27 14:29:54 -07:00
Fabian Schuiki 47fd15207d
[FIRRTL] Remove validif operation (#890)
* Remove the `validif` operation from the IR and replace any occurrences
  during parsing with an equivalent `invalidvalue` and `mux` operation.
  Fixes #886.

* Adjust a few of the test cases, especially around memories, which do
  not run canonicalization and thus no longer see the removal of validif
  happen automatically.
2021-04-06 19:38:54 +02:00
Andrew Young a728bb758d
[FIRRTL LowerTypes] Lower bundle wire connects in lower-types (#688)
Since wires have a duplex type, they can appear on the RHS or LHS of a
connect statement, regardless of whether or not they are a passive type.
When lowering a bulk connect statement involving a wire (i.e.
connecting a bundle type), we need to make sure that the non-duplex type
is used to set the direction of the flow. When doing a bulk connect of
two wires, it is considered an ambiguous flow and an error. To connect
two wires, each field must be connected individually, which is
considered a mono-connection with explicit flow from the RHS to the LHS.

This change adds a function to determine if a value comes from an
expression with duplex flow. This property is transitive through
subfield accesses.
2021-03-19 02:05:59 -07:00
Chris Lattner d1a3e105d4 [FIRRTL] Strip Portless Memories during Parsing, and make them invalid.
This fixes Issue #531
2021-01-30 14:14:09 -08:00
Chris Lattner bf56ef11e2 [FIRRTL] Change the FIRRTL dialect to require def-before-use in modules.
This matches the expectation of the SFC compiler, and LowerTypes/LowerToRTL
require this.

This patch xfails the HandshakeToFIRRTL/test_load.mlir test, which is tracked
in Issue #534.
2021-01-30 09:32:24 -08:00
Chris Lattner ded5bd2e39 [FIRRTL] Change the firrtl.instance operation to return multiple results.
Previously we followed the same representation as the Scala FIRRTL
implementation, but it is much easier to work with and result in less
IR for us to use multiple-result values.
2021-01-17 14:24:46 -08:00
Shivam Gupta 3c75cfb25b
use # for headers instead of ====
ref: see Markdown documentation- https://guides.github.com/features/mastering-markdown/
2021-01-12 21:11:49 +05:30
Schuyler Eldridge 1a71cf02d8 [FIRRTL] Update rationale doc, NFC
Add information related to: (1) type canonicalization resulting in
CIRCT accepting more circuits than the SFC, (2) representing kind and
flow information about ports and instances in the types, and (3) minor
cleanup.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-01-06 14:15:57 -05:00
Chris Lattner 17354225c8 [FIRRTL] Canonicalize away flip of analog types.
This implements the approach described in Issue #324, whereby we turn
flip(analog) into analog.  Analog types in FIRRTL are implicitly
bidirectional already, so an "output port of analog type" doesn't
actually make sense.  This canonicalization defines away certain
defensive code and eliminates the need for "AsPassive" to apply to
values of analog type.

The FIRRTL version of the verilog printer now prints analog ports as
inputs, if someone cared we could make it properly print inout for
them.
2021-01-02 23:13:29 -08:00
Chris Lattner 052de6df6f [FIRRTL] Replace the firrtl.invalid stmt with a firrtl.invalidvalue expression.
This makes the FIRRTL dialect easier to work with (e.g. the "merge" inference
algorithm in LowerToRTLModule works with invalid now), allows more wire
promotion, opportunities and doesn't affect expressive potential.

This is a deviance from the design explained in the FIRRTL spec so I added a
new section to the rationale to describe it.
2021-01-02 22:38:09 -08:00
Chris Lattner c8c78ca5e5 FIRRTLRationale: add a missing flip canonicalization seldridge pointed out. 2020-12-28 18:35:39 -08:00
Chris Lattner f32d46cdd8 Just some wording changes, NFC. 2020-12-27 10:28:10 -08:00
Chris Lattner a42bb3ddc1 [FIRRTL] add an initial FIRRTL dialect rationale doc. 2020-12-27 10:23:06 -08:00