Commit Graph

2504 Commits

Author SHA1 Message Date
Chris Lattner bb3ff9b97b [Comb] Adopt some new nice APInt things to simplify code. NFC. 2021-09-16 12:49:29 -07:00
John Demme 3f738e2017
[MSFT] Add `MSFTModuleOp` (#1801)
Adds a moduleop to the MSFT dialect. For now, it's mostly like hw.module but adds parameters to represent the specific parameterization of a parameterized module. Also necessarily adds a msft.output since hw.output expects to be in a hw.module.

Step 3 of #1755.
2021-09-16 12:48:39 -07:00
Andrew Young 50904ee377
[FIRRTL] Add PrefixModules pass (#1183)
This adds the prefix-modules pass to FIRRTL.  This pass looks for
modules annotated with the `NestedPrefixModulesAnnotation` and prefixes
the names of all modules instantiated underneath it. This pass will
duplicate modules as necessary to give submodules unique names. The
annotation can be attached to module definitions, as well as specific
instances.

The supported annotation is:
```json
{
  class = "sifive.enterprise.firrtl.NestedPrefixModulesAnnotation",
  prefix = "MyPrefix_",
  inclusive = true
}
```

If `inclusive` is false, it will not attach the prefix to target module,
only to modules instantiated underneath it.
2021-09-16 10:55:17 -07:00
Chris Lattner 072abc36c9 [APInt] use new cleaner APInt methods, NFC. 2021-09-16 09:37:41 -07:00
Morten Borup Petersen 2361367350 [Calyx] Add missing sorting of port attributes in ComponentOp::build 2021-09-16 14:44:47 +01:00
John Demme cdf21a8e7c [HW] [NFC] Finish move of `printModuleSignature` into shared header. 2021-09-16 01:12:36 -07:00
Chris Lattner 4222e3a1a1 [ExportVerilog] getAllModulePortInfos works on instances now. NFC. 2021-09-15 10:16:17 -07:00
Schuyler Eldridge b6fdfa66e9
[HW] Remove Unneeded getReferencedModule call
Fixes #1797.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-09-15 12:50:53 -04:00
Andrew Lenharth 7391d4090b
[FIRRTL] Mark don't touch module ports as overdefined (#1796)
There was nothing forcing these ports to be overdefined before, so constants could leak through.
The undefined flag gets propagated to the instance port moments later.

One could remove the don't touch check in visitConnect now, but it's not clear if checking the attributes is cheaper than merging some lattice values.
2021-09-15 11:50:27 -05:00
Hideto Ueno 45dd44b23d
[FIRRTL] Replace some lowerings with UnrealizedConversionCastOp (#1784)
* [FIRRTL] Replace StdIntCastOp/AnalogInOutCastOp/AsPassivePrimOp/AsNonPassivePrimOp with UnrealizedConversionCastOp

* refactor

* fix lower type

* fix

* fix lowerToHw
2021-09-15 13:59:32 +09:00
John Demme af8b1f500e
[HW] [NFC] Extract out printing/parsing functions for modules (#1773) 2021-09-14 19:50:41 -07:00
John Demme 4730fe8361 [Seq] Eliminate '_compreg' autogenerate when lowering
To address remaining concern in https://github.com/llvm/circt/pull/1772#discussion_r707908878
2021-09-14 19:23:40 -07:00
John Demme cd8d55a66f [Python] Fixing `InstanceOp` binding and ditching module decorator
Fixes the integration tests. Closes #1788.
2021-09-14 19:02:23 -07:00
Chris Gyurgyik ddf3b84fba
[HW] [MSFT] Remove unnecessary assertions in `getReferencedModule` and add SymbolOpUserInterface to MSFT InstanceOp. (#1787)
Remove a lot of assertions and checks that are validated by the ODS and `verifyInstanceOp` function. Secondly,
use SymbolOpUserInterface in MSFT dialect to avoid O(n) lookup when verifying the InstanceOp.
2021-09-14 17:30:02 -07:00
cgyurgyik d3164681db [obvious] [Calyx] Use SymbolUserOpInterface. 2021-09-14 16:14:18 -07:00
Prithayan Barua db3909a1c6
[LowerToHW] Update attribute DesignUnderTest to firrtl.DesignUnderTest [NFC] (#1789)
Prefix the attribute `DesignUnderTest` with `firrtl` since it defines a `FIRRTL` specific property. 
Update the docs and tests accordingly.
Followup to commit #805d7e8be89524f53bf30895469ee78408ea1f6b
2021-09-14 15:24:49 -07:00
Chris Gyurgyik 3287496640
[Calyx] [obvious] Update documentation for ComponentOp. 2021-09-14 15:08:05 -07:00
Chris Lattner 8b08c41e6c [ExportVerilog] Remove some now-unnecessary uses of getReferencedModule. NFC. 2021-09-14 12:42:57 -07:00
Chris Lattner 3d19aa7854 [HW] Enhance hw.instance to carry input/result port names.
This makes both hw.module* and hw.instance carry an argNames/resultNames
array attribute for the port names, and the verifier checks that they
line up.

This makes various queries on the instances much much faster (because
you don't need to resolve the module being referenced) and makes the
code more obviously correct in multithreaded situations.
2021-09-14 11:06:34 -07:00
Chris Lattner cfbf4accf9 [tests] Fix tests where the instance/module label names don't line up.
This is about to be diagnosed properly.
2021-09-14 11:05:54 -07:00
Chris Lattner 64f16a2f50 [Calyx] Fix a clang warning identifying a bug.
warning: object backing the pointer will be destroyed at the end of the full-expression [-Wdangling-gsl]
  StringRef portName = valueName(group->getParentOfType<ComponentOp>(), value);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-09-14 11:03:08 -07:00
Prithayan Barua 805d7e8be8
[LowerToHW] Add attribute to mark the Design Under Test module [NFC] (#1785)
The annotation `sifive.enterprise.firrtl.MarkDUTAnnotation` , marks what is the DUT (and not the testbench). 
Lower the annotation, to the attribute "DesignUnderTest", during `LowerToHW`.
Adds attribute `{DesignUnderTest }` to the module which has this annotation.
Other `sv/hw` passes can use this attribute to identify the DUT.
2021-09-14 08:37:22 -07:00
Prithayan Barua bc8708e4ba
[Docs] Fix typo in Doc [NFC] (#1786)
Fix typo in Doc
2021-09-14 08:02:54 -07:00
Chris Gyurgyik d599e6cf4f
[Calyx] Add combinational trait. (#1781)
This adds a combinational trait to Calyx operations. We can throw this on all non-memory operations for now, 
since they are all combinational. Eventually we'll need to split this off. Closes #1739. Also fixes a bug where it 
was considering a memory load as a store, since the address ports are used when both storing and loading to 
a MemoryOp. A test is added to verify this no longer occurs.
2021-09-14 07:26:04 -07:00
Martin Erhart db042fedff [LLHD] Replace remaining standardops with comb ops in tests
This should have been part of an earlier commit where we switched from using standard ops for arithmetic operations to comb ops in LLHD
2021-09-14 10:17:40 +02:00
Chris Lattner b57c68a370 [ESI] Switch updateInstance(HWModuleExternOp..) to use convenience builder NFC.
This automatically propagates port labels (with a future patch).
2021-09-13 22:46:31 -07:00
Chris Gyurgyik 0465fa3780
[Calyx] Verify that sources of group ports and assignments are not logically complex. (#1774)
As discussed in #1769, some verifiers should be added to avoid giving the sources of group ports / assignments 
logically complex expressions. Also adds a verifier to ensure that GroupOp isn't being used as a CombGroupOp, and 
makes the necessary refactoring. This will be removed when native Calyx supports complex arguments for sources.
2021-09-13 22:32:24 -07:00
John Demme 3e4ed51bb5
[ESI] Make instances match module declarations (#1780)
* [ESI] Create one extern module per module parameterization
* hw.instance verifier no longer has to ignore extern modules
2021-09-13 21:52:17 -07:00
John Demme cf2433a6c6
[Seq] [CompRegOp] Make 'name' non-optional but allow it to be empty (#1772)
Make `seq.compreg`'s name follow the same semantics of `sv.reg`.
2021-09-13 21:13:47 -07:00
Chris Gyurgyik 8f8a156041
[Calyx] Verify CombGroupOp is combinational and certain primitive ports are driven together. (#1764)
This PR focuses on (2) objectives. First, verifying that combinational groups are indeed combinational. 
Combinational components are not supported yet, so component instances are always assumed to be 
combinational for now. Second, we also verify that certain ports are written or read together. For example, 
it does not make sense to write to a register without write_en being high. To aid in this, I added helper 
functions to access certain ports on primitive operations.
2021-09-13 17:12:06 -07:00
Mike Urbach de0bd5a69b [ESI][PyCDE] Fix tests, integration tests, NFC.
Follow up to 5e74206. Fix more ESI as well as PyCDE tests and
integration tests to use the new HW dialect module/instance format.
2021-09-13 17:27:08 -06:00
Schuyler Eldridge 21f713689b
[FIRRTL] GCT Views: Verilator Integration Test, NFC (#1778)
Add an integration test of Grand Central Views that uses Verilator to
lint and type-check the produced SystemVerilog output.  This is
primarily done to test the following features:

  - All necessary interfaces are generated
  - All XMRs are valid (XMRs use the correct instance names)

Both single file ("firtool -verilog") and multi-file output ("firtool
-split-verilog" with an annotation file doing extraction) are tested.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-09-13 18:11:15 -04:00
Chris Lattner c6b93aa292 [ESI] Switch another callsite to the convenience builder for instances, NFC.
This makes it easier to roll out instance port labels.
2021-09-13 13:08:48 -07:00
Richard Xia 00a3c0d723 [Comb] OrOp: Only check second early exit condition if first is true. NFC. 2021-09-13 12:03:07 -07:00
Andrew Lenharth 08c19bb7fc [NFC] Save 5% of stack frame size in key recursive function in FIRParser.
Mux is the only normal operation that even has 3 operands, so narrow these small vectors.
Save a few bytes not having a local mutable array of strings.
2021-09-13 12:59:51 -05:00
Schuyler Eldridge 5e74206d94
[ESI] Fix tests, integration tests, NFC
Fix more ESI tests and integration tests to use the new HW dialect
module/instance foramt.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-09-13 13:36:24 -04:00
Schuyler Eldridge eee7ab7723
[FIRRTL] GCT Views: 1D IFace Integration Test, NFC
Switch from a two-dimensional interface in the Grand Central View
interface integration test to a one-dimensional interface.  Do this so
that Verilator can type-check and lint the output Verilog.  (Verilator
does not support multi-dimensional interfaces.)

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-09-13 12:20:50 -04:00
Schuyler Eldridge d91ccd294b
[HW] Fix Integration Tests, NFC
Update integration tests to use new hw.module and hw.instance textual
formats.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
2021-09-13 11:41:41 -04:00
Andrew Lenharth 9351492fc3 [NFC] Add check for correct hw.module.generated in LowerToHW
Add a check that the 3 memory tests generate generator modules.
2021-09-13 09:57:44 -05:00
Andrew Young a3ed3e60c2
Update LLVM to 704a395 (#1765)
This updates LLVM to 704a395.  We are pulling the new version of LLVM for the top commit which allows 0-bit APInts.  This will help us model 0 bit constants in FIRRTL, and we will be able to properly use IntegerAttr as a (possibly 0-length) bitvector for FIRRTL port directions.

Included in this update is a change to the way `unrealized_conversion_casts` are handled by the LLVM converter infrastructure.  We needed to update `LLHDToLLVM` to apply the new conversion casts.  For more information see the public PSA on the LLVM discourse[^0].

This revealed a problem in the `LLHDToLLVM` where there was a failed to legalize operations in the lowering of `llhd.proc` and `llhd.entity`.  These operation's lowering logic needed to ensure that operations from the (old) body of `llhd.proc` and `llhd.entity` were type converted before inserting new LLVM operations which used their results.

[0] https://llvm.discourse.group/t/psa-run-reconcile-unrealized-casts-after-all-convert-to-llvm-from-now-on/4266
Co-authored-by: Martin Erhart <maerhart@outlook.com>
2021-09-13 00:27:02 -07:00
Chris Lattner e37c8833f7 [HW] Introduce a new ModulePortInfo which more cleanly delineates between input/outputs ports. NFC. 2021-09-12 21:54:25 -07:00
Chris Lattner b6988dd725 [HW/FIRRTL] Rename ModulePortInfo to just "PortInfo" NFC.
This applies to both instances and modules, and the more verbose name
doesn't help anyway.
2021-09-12 21:18:41 -07:00
Chris Lattner 5591a3be43 [HW] Tighten up module verification a bit.
It is imperative that instance and modules line up w.r.t. types and
port declarations.  ESI is (ab)using flexibility in extern modules,
so this doesn't tighten it up all the way, I will file an issue.
2021-09-12 20:54:54 -07:00
Chris Lattner c7b2ec671e [tests] remove some redundant parens, NFC. 2021-09-12 18:56:06 -07:00
Chris Lattner 8e7693eee5 [HW] Eliminate support for explicit argNames/resultNames attributes on modules.
There is no reason to support this anymore, just eliminate it.
2021-09-12 18:53:27 -07:00
Chris Lattner ef83881d0b [HW] Change module result port names to not have a %
They aren't SSA values like input ports, so eliminate the %.  This
makes them more consistent with instances and eliminates some syntactic
noise.
2021-09-12 18:46:26 -07:00
Chris Lattner c0e554c424 [HW] Move instance attributes after result port list in .mlir syntax. 2021-09-12 18:06:50 -07:00
Chris Lattner 18df843aa3 [HW] Change hw.instance syntax to include port names.
This pulls the port names and port types inline into the argument list,
and adds result port names to the output signature.  This increases readability
and is a stepping stone to hw.instance maintaining its own port names.
2021-09-12 17:54:53 -07:00
John Demme 8a41c3f326 [ESI] Fix build and test broken by 5d759dd
Build break since inline {} doesn't work when multiple builders are present.
Test break since new convenience builders don't work for external parameterized
modules.
2021-09-12 17:05:11 -07:00
Chris Lattner f7ff083296 [HW] Generalize methods like getModulePortInfo to work on instances.
This is NFC other than changing a verification error due to an earlier
check.  This is plumbing to make way for port names being stored on
instances.
2021-09-12 15:24:49 -07:00