Commit Graph

2481 Commits

Author SHA1 Message Date
Morten Borup Petersen 5fc5b1d372
[Pipeline][NFC] Rename `pipeline.stage` -> `pipeline.while.stage` (#3758) 2022-08-22 10:20:00 +02:00
John Demme cbca58fc99
[ESI][Services] Output a JSON description of the service hierarchy (#3720)
Start of support for building specialized software APIs!

- Create an op to hold metadata about services being implemented.
- Create them when we create the implementation request.
- Copy them up the instance hierarchy modifying the 'path' as they get moved up.
- Rename the capnp schema pass to the more generic "emit collateral" pass.
- Emit the service hierarchy information for the top levels in said pass.
2022-08-19 20:19:58 -07:00
Prithayan Barua e54ddf48a0
[FIRRTL][RefOps] Remove downward-only constraint from RefType (#3753)
This PR relaxes the downward only constraint on the RefType flow.
 After this change, 
- Modules can have input ports of `RefType`
- Instance ops can connect RefType input/output ports to module input/output
ports according to connect semantics.
- There is no constraint to where a `ref.resolve` can occur relative to `ref.send`
 in the instance hierarchy

There are no additional verifiers currently added to constraint the `RefType`
 flow, but the LowerXMR pass must error out, if multiply instantiated modules
 with `RefType` ports are encountered.
2022-08-18 20:09:59 -07:00
Christian Ulmann d77732e8b9
[StandardToHandshake] Fix mux input order (#3750)
This commit fixes a faulty guard mux input order in the feed-forward task pipelining transformation.
Instead of wrongly assuming a given relation between the mux input order and the cmerge inputs, it has to be checked for each case separately.

The provided test was affected by this faulty ordering and thus didn't terminate.
2022-08-18 16:31:20 +02:00
Martin Erhart 6a25904fc1
[ExportSystemC] Add emission patterns for the remaining systemc ops and constant op (#3735) 2022-08-18 11:42:38 +02:00
Martin Erhart a2cfc4818b
[SystemC] Don't hardcode includes (#3734)
Use the emitc.include operation to add includes during lowering or transformations instead of hardcoding them in the printer. Add basic support in HWToSystemC and ExportSystemC.
2022-08-18 10:57:58 +02:00
Martin Erhart e6c0f862fc
[ExportSystemC] Integer and port type emission (#3733) 2022-08-18 10:08:45 +02:00
Mike Urbach 342a1edf26
[FIRRTL] Extend register randomization to split up large registers. (#3748)
This now tracks when randomized registers exceed a threshold, and
splits them up into multiple registers. This is intended to work
around register size limits in simulators that may be exceeded by
using a single large register to hold all of the random bits for each
module.
2022-08-17 22:04:20 -06:00
Will Dietz 7e12fe084d
[FIRRTL][InferResets] Handle RefType, send, resolve. (#3729) 2022-08-17 14:57:59 -05:00
Schuyler Eldridge 3d68b644db
[firrtl] Copy reg init info in canonicalizer
Fix a bug in FIRRTL register randomization where a canonicalizer was not
copying over register randomization information.  This plugs a hole
where registers that fit a certain pattern could escape stable
randomization.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2022-08-17 15:05:35 -04:00
Martin Erhart dd2e9120c1
[ExportSystemC] Basic infrastructure for emission (#3726)
This commit introduces the base classes and utilities to implement
emission patterns and an emission printer which takes the role of a
driver that can be called in a circt-translate pass. Also includes
emission patterns for the builtin module and SCModule operations to
(1) allow to implement some basic unit and integration tests
(2) show the reviewer how emission patterns look like using this
infrastructure.
2022-08-17 00:55:08 +02:00
Zachary Yedidia d323a775bf
[HWToLLVM] Lower constant HW arrays to static global LLVM arrays (#3694) 2022-08-16 18:38:16 +02:00
Will Dietz 2ca7109b4f
[FIRRTL][IMDCE] Test deleting code w/ref's. Avoid temp ref wire. (#3716)
Note: when deleting dead ports, IMDCE introduces temporary wires
for the ports (inside the module) and at points of instantiation.
These are invalid for ref type, which isn't ideal, but they will be erased.

In one case this is not temporary, which this checks for,
the case where an output ref port is alive but not used by instantiators.
2022-08-16 08:25:05 -05:00
Prithayan Barua 6a7e74db85
[FIRRTL][LowerXMR] Handle xmr to ports correctly (#3730)
Fix a bug in LowerXMR to handle ports correctly.
2022-08-15 20:41:49 -07:00
Prithayan Barua 1b77ee9800
[FIRRTL][RefOps] Add a pass to lower RefType operations to xmr (#3719)
This commit adds a new pass LowerXMRPass.
The LowerXMRPass replaces every RefResolveOp with a verbatim expr op encoding
the corresponding XMR. The pass also removes every value of RefType and its
uses from the circuit.
This is a dataflow analysis over a very constrained RefType. Domain of the
 dataflow analysis is the set of all RefSendOp. Essentially every RefType
 value must be mapped to one and only one RefSendOp. The analysis propagates
 the reachable RefSendOp to every value of RefType across modules. The
 RefResolveOp is the final leaf into which the dataflow must flow into.
Due to the downward only reference constraint on XMRs, the post order traversal
 ensures that the RefSendOp will be encountered before any user of the
RefType value. The pass fails and errors out if every "live" RefType value is
not mapped to a unique RefSendOp.
2022-08-15 15:33:57 -07:00
Will Dietz 570ad7c7b8
[FIRRTL][InferWidths] infer through send/resolve, test. (#3712) 2022-08-15 13:30:57 -05:00
Mike Urbach 261c5439af
[FIRRTL] Set the parameters for register randomization early. (#3714)
This adds a pass that collects all registers in each module, computes
how many bits of random data should be used to initialize them, and
saves this information for each module and register. In FirRegLower,
this is used to create one large random register per module, and
select out the appropriate bits for each register in the initial
block. This ensures the same large random register is created, and the
same bits are always selected for the same register, regardless of
optimizations that may remove registers.
2022-08-15 12:22:54 -06:00
Will Dietz a3536cb8ed
[FIRRTL][IMCP] Add support for ref send/resolve. (#3711) 2022-08-15 12:43:36 -05:00
Mike Urbach 3c8949a8cb
[ESI] Fixes for handling none-typed channels in ports. (#3722)
There is basic support for none-typed channels, and a simple test. But
upon using none-typed channels for a more complex Handshake circuit,
it became apparent that the ESI lowering for none-typed ports was
missing a couple special cases. This includes a reduced test case and
the fixes I found necessary.
2022-08-15 10:08:30 -06:00
Morten Borup Petersen 515ea3d005 [HandshakeToHW] Use `none` instead of `i0`
ESI supports `none`-typed channels and not `i0`-typed.
2022-08-15 09:01:11 +02:00
Nandor Licker 5e50beca79
LLVM Bump (#3708)
* [D131537](https://reviews.llvm.org/D131537) modernized LLVM ops
* [D131702](https://reviews.llvm.org/D131702) changed segment size attributes
* [D131822](https://reviews.llvm.org/D131822) renamed Confined
2022-08-13 17:28:28 +03:00
Hideto Ueno 676be0990e
[ExportVerilog] Enable new emission mode by default (#3695)
This comit switches ExportVerilog emission mode to new simplified version by default. `useOldEmissionMode` flag is added to use the old emission mode. If there is no problem for a few weeks, I'd like to entirely deprecate old emission implementation.  Original proposal of ExportVerilog simplification is here: https://discourse.llvm.org/t/exportverilog-simplification-for-pretty-printing-output-verilog/63363

There should be differences in output verilog, specifically:
* Some whitespace changes in wire and reg declarations. 
*  There is no forward declaration anymore. 
* Automatic logic variables get less inlined to declarations compared to the old mode. This is because of the current limitation of the analysis of inlinability.
* More assignments are inlined into declarations.    

If there is an issue with new emission mode, you can use `--lowering-options=useOldEmissionMode`.
2022-08-13 21:26:59 +09:00
Prithayan Barua a80633af2c
[FIRRTL] Add the FIRRTL RefType Ops (#3700)
This PR introduces two operations to handle `RefType`.
The `RefType` is used to represent dataflow and the following operations
 are added to make the dataflow relations explicit.

- RefSendOp
  - Takes as input a `BaseType` and returns a `RefType`
  - Used to send a read-only Reference handle of a local value.
  - Represents the source of a dataflow by getting it's reference.
- RefResolveOp
  - Takes as input a `RefType` and returns a `BaseType`
  - Represents the sink of a dataflow from the reference handle
  - The `RefType` is constrained to express a "single source to
	one-or-more sink" dataflow 
  - Hence, multiple `RefResolveOp`s can be remotely connected to a single
	`RefSendOp`.
  - If the Reference ops are lowered to cross-module-reference, then it
	represents the location of the XMR. 


This commit also adds few lit tests to verify proper errors for the constraints
 on the Reference ops and the `ref.mlir` to demonstrate the usage of
Reference ops, it does not check for any output, just that there are no errors.
 `ref.mlir` can possibly be removed later when other passes handling the
 Reference ops are introduced.

Co-authored-by: Will Dietz <will.dietz@sifive.com>
2022-08-12 11:43:09 -07:00
Martin Erhart f31d6250d1
[SystemC] Introduce special types for ports and signals (#3681)
Remove the current port direction attribute and enum and use types to
represent the port direction. Reuse the PortInfo struct and enum of the
HW dialect to represent the port direction in CPP code when MLIR types
aren't that well suited. The rational is that these constructs are the
same across multiple dialects and should be part of the ModuleLike
interface to be reused by all module ops implementing the HWModuleLike
interface. Providing getters and builders that accept these port
direction/port info struct makes conversion between module ops that
implement HWModuleLike very convenient. This PR also implements that
interface for SystemC modules.
Also switch over to use the module_like and function_like parser and
printer utilities and add support for module visibility and argument
attributes.
2022-08-12 20:06:36 +02:00
Andrew Lenharth 8e13da3f2d
[FIRRTL] Support optional version in fir files (#3709)
Firrtl spec 1.1.0 added version identifiers to the fir file. Update the parse to parse these. Currently nothing is done with the version after parsing.
2022-08-12 11:51:59 -05:00
Hideto Ueno c5beba5f58
[ExportVerilog] Inline logic assignments into decl in new emission mode (#3692)
This implements a mechanism to inline blocking assignments into automatic logic 
declarations in the new emission mode. 
We can inline blocking assignment into automatic logic declrations if:
1. There exists a single blocking assignment which dominates all users of logic reads.
2. The source value of the assign can be inlined into the declaration. This is checked by  `isExpressionEmittedInlineIntoProceduralDeclaration`.
2022-08-12 23:51:09 +09:00
John Demme dbbc205849
[ESI] Bidirectional channel requests and Cosim support (#3705)
Allow users to request bidirectional channels (InOut). Decomposes into
one `to_server` and one `to_client` request. Cosim will detect that and
wire them up to the same endpoint.
2022-08-11 18:25:55 -07:00
Hideto Ueno ad3e9a1748
[ExportVerilog] Fix incorrect inlining of automatic logic (#3691)
This commit first fixes incorrect inlining issue( https://github.com/llvm/circt/issues/3603) of automatic logic by restricting `isExpressionEmittedInlineIntoProceduralDeclaration` for read_inout op. More specifically, a read from wire is fine but we have to be more careful about reads from reg and logic because they can be modified with blocking assignments. This commit changes   `isExpressionEmittedInlineIntoProceduralDeclaration` to check users of reg or logic and ensure that there is no blocking assignment.
2022-08-11 21:30:32 +09:00
Morten Borup Petersen 375018a90c
[MSFT] Introduce `LinearOp` (#3680)
The `msft.hlc.linear` operation defines a linear datapath. It serves as a container for `hw`, `comb` and `msft` operations, with the following restrictions:
- Not graph-like - only SSA def-use chains are allowed.
- `seq` ops are not allowed.
2022-08-11 12:40:56 +02:00
Will Dietz d4504cb7ea
[FIRRTL] Add RefType, first non-base type. (#3653)
Adds the reference type, such as `firrtl.ref<uint<1>>`.

Used for remote reads and writes of the wrapped base type.

Parameterized over the referenced base type,
which must be passive and for now must also be ground.

Not a base type.

Values of this type are used to capture dataflow paths,
and do not represent a circuit element or entity.

Co-authored-by: Prithayan Barua <prithayan@gmail.com>
2022-08-10 12:45:48 -05:00
Andrew Young 20e373dcca
[FIRRTL][Dedup] Simplify printing of dedup failure of instances (#3689)
When printing the error message for deduplication failure, the error
printed for a stack of error messages is quite large and hard to read.
This makes an incremental improvement to the stack of error messages.
The most important improvement is that it prints as a single diagnostic
with a single `error:` emitted.

Before:
```
design.fir:1:1: error: module "Top0" not deduplicated with "Top1"
circuit Top :
^
design.scala:135:24: note: first instance targets module "Mid0"
design.scala:135:24: note: second instance targets module "Mid1"
design.fir:4395809:10: error: module "Mid0" not deduplicated with "MId1"
  module Mid0:
         ^
design.scala:64:9: note: first operation has attribute 'message' with value "Assertion failed: 0"
design.scala:64:9: note: second operation has value "Assertion failed: 1"
```

After:
```
design.fir:1:1: error: module "Top0" not deduplicated with "Top1"
circuit Top :
^
design.fir:1:1: note: in instance "mid0" of "Mid0", and instance "mid1" of "Mid1"
design.scala:64:9: note: first operation has attribute 'message' with value "Assertion failed: 0"
design.scala:64:9: note: second operation has value "Assertion failed: 1"
```
2022-08-10 09:43:16 -07:00
Hideto Ueno 82cc9db2f2
[IMDCE] Forward constant output ports to caller sides (#3688)
This PR makes IMDCE propagate constant output ports to caller sides before
actually performing dataflow analysis so that we can eliminate constant output ports.
2022-08-10 14:10:09 +09:00
Mike Urbach b706f4d78d
[Pipeline] Remove original PipelineOp and conversion. (#3685)
This representation and conversion aren't being used, and never
connected to Verilog output. The newer PipelineWhileOp could subsume
this use-case, and further evolution is coming to this dialect, so it
seems like a good time to clean out the older parts that aren't used.
2022-08-08 11:26:20 -07:00
Andrew Young 47a55b722d
[FIRRTL][SFCCompat] Add support for aggregates (#3670)
This adds support for aggregate typed registers to the SFC compat pass.
SFC Compat looks at the values which are connected to registers; if they
are all invalid the reset can be removed, and resets for async registers
require a constant reset value.

Previously, this used the function `getModuleScopedDriver` which only
handles ground types.  This creates a function `walkDrivers` which
performs a similar operation, but applies a call back when it finds
which fields of the aggregate is driven by some other value. Since the 
source value and the the destination value might both be aggregates, the 
callback uses FieldRefs to indicate the field.
2022-08-08 10:16:04 -07:00
Nandor Licker ce9eef2c1d
[HW] Added canonicalizers for aggregate operations (#3671)
- Simplified chains of inject ops into struct creates if all fields set
- Eliminated injects which are overwritten by other injects
- Canonicalized concatenation of array creates into a single array create
- Converted slices of concatenations into concatenations of slices
- Pushed array gets into slices and concatenations
- Merged a slice of a slice into a single slice
- Converted single-element slices to an array creation with a single element
- Simplified slices of array creates
2022-08-08 16:55:30 +03:00
Christian Ulmann 5cf7ea97f7
[StandardToHandshake] Fix feed-forward task pipelining merge order (#3682)
This commit fixes a bug in the feed forward task pipelining transformation. A mux does not select its results with the same indexing as a control branch does, thus the boolean value requires negation.
2022-08-08 15:37:08 +02:00
Nandor Licker 7bcbc482db
[ExportVerilog] Inline array element accesses (#3675) 2022-08-08 10:21:09 +03:00
Fabian Schuiki 93112d40df
Bump LLVM (#3649)
* Bump LLVM

Bump LLVM to the current top-of-tree.

This requires changing a few `Attribute`s to the new `TypedAttr`
interface, since attributes no longer carry a type by default. We rely
on this type in quite a few places in the CIRCT codebase, which required
a switch over to `TypedAttr`.

See: https://reviews.llvm.org/D130092

Co-authored-by: John Demme <john.demme@microsoft.com>
2022-08-07 09:21:55 +02:00
Nandor Licker 5fa3a0d934 [FIRRTLToHW][NFC] Fixed ordering of concat operands 2022-08-05 17:20:24 +03:00
Christian Ulmann 3d063e55ad
[StandardToHandshake] Prototypical feedforward guard implementation (#3652)
This commit adds a transformation to ensure correct task pipelining. 

For each split and merge block pair, it inserts a mechanism that ensures that the order of the threads is preserved.
2022-08-05 14:24:46 +02:00
Morten Borup Petersen fdd709447b [HWArith] Add missing test check 2022-08-05 09:41:47 +02:00
Morten Borup Petersen f683954bf5 [HWArith] Also lower MSFTModuleLike operations 2022-08-05 09:38:51 +02:00
Prithayan Barua e27a75471f
[FIRRTL] Update port symbols to InnerSymAttr (#3582)
Update the port symbol from StringAttr to InnerSymAttr.
This commit replaces empty string with Null attribute to denote
 ports with no symbol and then use an empty InnerSymAttr when setting
 the portSym attribute, because array attribute elements cannot be null.

FModuleLike interface now returns a null Attribute if the corresponding port
 symbol does not exist. So, all the users of getPortSymbolAttr must check for
 null instead of empty string.
The fixupPortSymsArray is used to replace any null entry in the port symbols
 array with an empty InnerSymAttr, because its illegal to store Null attribute

Also added an error in LowerToHW, if there is any field sensitive symbol,
 because HW dialect cannot handle them yet.
2022-08-04 11:22:16 -07:00
Andrew Butt 1cc5eeec4b
[Calyx] Add calyx primitive operation using hw.module.extern (#3565) 2022-08-04 10:31:42 -04:00
Hideto Ueno dab2a8f7a7
[ExportVerilog] Fix wire name collision (#3661)
This fixes a name collision issue https://github.com/llvm/circt/issues/3607 when hw.verilogName 
is pre-defined before ExportVerilog. If verilogName attr is attached to a declaration already, 
it's necessary to force the name to the op.  This PR changes `GlobalNameResolver::legalizeModuleNames` 
to register used names first, and then legalize the declaration names.  

Related PR: https://github.com/llvm/circt/pull/2104

Close #3607.
2022-08-04 22:01:26 +09:00
Julian Oppermann 392e27342d
[SSP] Add SSP <-> circt::scheduling conversion utilities. (#3636) 2022-08-04 12:30:09 +02:00
Morten Borup Petersen b3359685c7
[StaticLogic] Rename dialect to 'Pipeline' (#3648)
It is probably fair to conclude that naming this dialect `StaticLogic` has been a pain point for a while. This commit proposes a dialect renaming to `Pipeline`, for a couple of reaons:

1. So far, we've only been working with pipeline abstractions within this dialect.
2. Pipeline representations aren't necessarily statically scheduled - we plan on adding switches to select between latency sensitive and latency insensitive lowerings of pipelines.

This name change does not preclude renamings in the future if we want to fit more stuff into this dialect. Personally, i think it is prudent to maintain a dialect name which reflects what's actually being done within the dialect, as well as the (near/mid/"someone actually intends to work on this"-term) future plans for the dialect.
2022-08-04 10:58:40 +02:00
Morten Borup Petersen c2aaec3c38 [HWArith] Revert chained cast canonicalization #3651 2022-08-03 15:59:09 +02:00
Morten Borup Petersen 83583bd7b9
[HWArith] Add canonicalization patterns for CastOp (#3647) 2022-08-03 11:35:03 +02:00
Morten Borup Petersen b003931deb
[HWArithToHW] Add type conversions for 'other' ops (#3643)
Fixes #3635. Adds signature conversion for `hw::HWModuleOp,hw:HWExternalModuleOp` (`mlir::populateFunctionOpInterfaceTypeConversionPattern` unfortunately can't be provided an interface, i.e. `HWModuleLike`) as well as conversions for 'other' operations which we expect to be mixed in with `hwarith` operations.
2022-08-03 11:10:45 +02:00