Commit Graph

144 Commits

Author SHA1 Message Date
John Demme 67fd0f8e6d [MSFT] Python bindings for ops and changes to make them work
- Adds python bindings for MSFTModuleOp and InstanceOp.
- Re-use as much as possible from `circt.hw._hw_ops_ext`. Required changes to
  ODS definitions.
- Found and fixed some bugs.
2021-09-17 00:16:49 -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
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
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 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
John Demme 17ba90d780
[Seq] Make `CompRegOp` name optional (#1754)
- Allow `seq.compreg` to be unnamed.
- Fixed the python integration test
2021-09-08 20:54:06 -07:00
John Demme 730b157be5
[MSFT] DeviceDB C API and Python bindings (#1717) 2021-09-03 20:12:16 -07:00
John Demme 0066f6dc79
[MSFT] Introduce `RootedInstancePath` and re-factor based on it (#1689)
A RootedInstancePath is just an instance path prepended with the root (aka top) module which the instance path is relative to. If we structure the placements based on this, we no longer have to walk the instance hierarchy while exporting TCL! This patch also removes support for locations not inside of instance switches. That use case required the design be fully elaborated which isn't really done.
2021-09-01 17:41:06 -07:00
John Demme 542fd31c99
[PyCDE] Instance placement API (#1615) 2021-08-20 19:08:51 -07:00
John Demme 3ad8be3d88
[MSFT] [Python] Add a function to get an instance (#1613)
Given a root module and an instance path, find the corresponding instance from
the instance hierarchy. Return 'None' if the path wasn't found.
2021-08-20 13:57:35 -07:00
John Demme 43ccc6584e
[MSFT] [Py] Add physical location and switch instance attributes to python module (#1606) 2021-08-18 20:03:07 -07:00
Chris Lattner f0fa80b451 [comb] Remove the comb.merge operation and supporting logic.
Schuyler points out in Issue #1600 that it isn't correctly implemented,
and there is only one place in the compiler that forms it ... in a
theoretical case.  I added this a long time ago on a theoretical basis.
It is best to remove this until there is a real need for it.

This fixes Issue #1600.
2021-08-17 22:31:51 -07:00
Chris Lattner 96d2c55530 Make this test print out the problem to the build log if there is one. 2021-08-15 16:08:58 -07:00
Laura Gallo 0649d308d8
Added Tcl bindings for loading an MLIR file. (#1529)
* Added Tcl bindings for loading an MLIR file.

* Ran clang-format

* Updated Tcl library path

* Update simple.tcl

* Implemented Lenharth's suggestions

* Ran clang-format

* Fixed integration test

* Added checks to integration test

* Implemented some of Mike's suggestions

* Added another argument

* Added paths to Tcl debug output in CMAKE
2021-08-10 09:36:46 -04:00
mikeurbach 9684762674
[CMake] Ensure the build directory for generated Python exists. (#1495)
- Adds explicit mkdir
- Removes some unnecessary deps
2021-07-30 16:26:07 -07:00
mikeurbach 8a792f8b59
[Python] Re-work Python bindings using upstream improvements. (#1484)
This is mostly mechanical for us. Some notable changes:

* Require a unified build for Python in CMake, docs, and CI
* New CMake defaults for some variables in CMakeLists.txt
* Use the new CMake functions for Python bindings and PyCDE
* Update imports for generated Python and Python extension libraries
* Update PYTHONPATH to reflect the new location under unified builds
2021-07-29 09:49:58 -06:00
Hideto Ueno d284a97c4e
[NFC] Eliminate simple canonicalizer (#1454)
* eliminate simple canonicalizer

* small fix

* fix cmake

* remove circt/Transforms

* clang-format
2021-07-22 12:23:01 +09:00
Mike Urbach 6de54965fe [ExportVerilog] Remove sv-structs.mlir integration test.
This test is probably too narrow to be part of the integration test
suite. It ensures the tool does what we expect, with the constructs we
emit from ExportVerilog. Closes
https://github.com/llvm/circt/issues/1368.
2021-07-05 11:34:20 -06:00
mikeurbach 8325991fbe
[CAPI][Python] Add support for TypeAliasType in CAPI and Bindings. (#1362)
This adds straightforward support for the TypeAliasType, as it stands
today, in the CAPI, then layers the Bindings directly on top of that.

Later improvements to the TypeAliasType's builder will of course
require refactoring part of this, but for now, this opens it up for
use in PyCDE.
2021-07-01 17:36:22 -06:00
mikeurbach dbf83459c1
[ExportVerilog] Special case register of struct or array of struct. (#1361)
Don't print `reg` if the reg holds a struct or array of struct. See
the spec, section 6.8 for the syntax of variable declarations.
2021-07-01 15:25:53 -06:00
Andrew Young a29f82d02c
[Python][Seq] Fix integration test (#1315)
Verilog emission is now defaulting to print `always` instead of
`always_ff`.  These tests don't run in a PR and were missed during
the change.
2021-06-23 10:45:45 -07:00
John Demme 8b525e879b
[Py] Create syntactic sugar for some Array and Struct ops (#1234)
Recreating the C++ logic for ArrayCreateOp, ArrayGetOp, StructCreateOp, and StructExtractOp.
2021-06-10 11:46:09 -07:00
Mike Urbach 0eb3af159e [Python] Reformat all Python sources, NFC.
The format PR gate was previously broken, so some format issues
slipped in. This runs `yapf -i -r .` over the whole repo.
2021-06-03 12:00:44 -06:00
mikeurbach 7e04c47a31
[Python] Add uniform `create` methods to the rest of the Comb ops. (#1192)
This adds a create classmethod to the variadic and other Comb ops,
rounding out the Python bindings sugar for the Comb dialect.

Additionally, this removes the kwargs from the non-variadic Comb ops'
create classmethods. This presents the same API as the variadic ops
for the common case where all the operands are known at the time the
op is constructed.

Under the hood, non-variadic ops still use the NamedValueOpView to
continue supporting the less common case of constructing the operands
incrementally. Incremental construction is simply not possible for the
variadic ops, since we need to know how many operands to build at
construction time.
2021-06-03 11:58:45 -06:00
John Demme 51639cad29
[PyCDE] Moving the most opinionated python out of bindings (#1179) (#1195)
- Creating new frontends top level directory which contains frontends which are optionally included.
- Moving @module and @Generator into PyCDE frontend.
- Keeping connect in the bindings since it's used in the bindings tests.
- Fixing the integration tests.

Closes #1179.
2021-06-03 09:43:02 -07:00
John Demme 2ab667c592 [ESI] Fixing two integration tests 2021-06-02 18:31:21 -07:00
Chris Lattner 0f5bda6f72 [integration-test] Revert d7cca9529f 2021-06-02 17:01:54 -07:00
Mike Urbach 35f1aac33c [Python] Fix collection type hint syntax.
The previous syntax is only available on Python 3.9.
2021-06-02 14:58:57 -06:00
Chris Lattner d7cca9529f [integration-test] Properly init a reg, fixing Issue #1188. 2021-06-02 12:19:54 -07:00
John Demme cc3d74cf69
[Py] Design entry language: generators (#1169)
Prototype of "generators". This version runs the generator for each and every op to lower and each time it is called, a new HWModuleOp is created at the top level. To fix this, I plan on unique'ing on the operation's attributes, result types, and operand types. This'll involve some refactoring since as of this PR the HWModuleOp creation and instantiation are both in the same callback.
2021-06-01 15:21:26 -07:00
mikeurbach d26bb8c893
[Python] Infer or elide result type from create when unnecessary. (#1168)
The comparators all return an i1, so we simply don't need a result
type there. The binary ops all have the SameOperandsAndResultType
trait, so we can check the operand types and infer the result type.
2021-05-27 18:21:21 -06:00
mikeurbach 7a2fa8d6da
[Python] Update all create methods to accept keyword arguments. (#1167)
This makes the API more natural compared to an explicit dictionary of
input ports to set by name.
2021-05-27 17:57:40 -06:00
mikeurbach 5ccb892b26
[Python] Add NamedValueOpView builders for the Comb dialect. (#1163)
This refactors the NamedValueOpView to push all the complexity into a
shared constructor that works for a variety of ops like InstanceOp,
CompRegOp, and the non-variadic Comb ops.

To support this, subclasses must now define two hooks to retrieve the
list of operand names and result names. There is also a third hook to
create a backedge of an appropriate type for a given operand that was
left uninitialized. The default implementation works for ops that have
the same type for all operands.
2021-05-27 16:39:56 -06:00
mikeurbach 6de40d2b87
[Python] Add a helper to create constants given a type and value. (#1165)
This still requires an explicit type from the end user, but it hides
the fact that an Attribute must be constructed under the hood.
2021-05-27 15:44:39 -06:00
mikeurbach 89e30f46c4
[Handshake] Update integration test driver and examples. (#1144)
The driver would previously hold the top level input valid signal high
until the result valid signal was asserted. This updates the behavior
to match handshake-runner, which only schedules the input arguments
once.

This also replaces the piecemeal examples with two proper integration
tests: a dot product and a 1-d matrix multiplication. These tests
cover the old ones, and too many simulations slow down the test
suite.
2021-05-26 14:44:11 -06:00
John Demme 213b2f2ffc
[Py] Clean up and merge some code (#1141)
Also make the 'connect.py' test work since it tests the 'connect' function
which I've changed.
2021-05-24 18:22:06 -07:00
John Demme ea49031dc5
[Py] Adding named input/output args/results to body_builder (#1124)
Create an `OutputOp` out of the return value from `body_builder`. Eliminate input ports as `construct` args. Move all of the `module.entry_block.arguments[1]` ugliness to the new `module.foo` syntax.
2021-05-24 17:08:16 -07:00
John Demme 318a05f6ac
[Py] Make @module annotations create MLIR Operations (#1123)
Make the @module annotation create a subclass which also inherits from OpView. When OpView is initialized, an unregistered MLIR operation gets created. Use the Input and Output classes as classmembers or instancemembers to create operands and results.

This breaks the construct based building. That'll be added back once we have a lowering API in python.
2021-05-24 16:18:37 -07:00
mikeurbach 77766af3fa
[Python] Add NamedValueBuilder for CompRegOp. (#1133)
This adds support for incrementally building a CompRegOp.
2021-05-24 17:10:41 -06:00
John Demme bf42334dd7 [Integration Test] Adding requirement to fix tests 2021-05-22 22:21:44 -07:00
John Demme fefdabc28f [Py] Fixing integration tests
`circt` no longer imports `design_entry` into its namespace.
2021-05-21 18:27:07 -07:00
mikeurbach 04e9699ab3
[Python] Add generic connect API that works with builders. (#1106)
This adds `circt.connect` to "connect" two values. It sets the
destination OpOperand to the new value.

To integrate with the builder approach, this updates the
InstanceBuilder to return a wrapper BuilderValue around any Values
accessed through `__getattr__`. This works with the connect API to
pass around the needed index to ultimately set the Value and erase any
temporary backedges the builder created.

As the builder approach is generalized to other ops, the connect API
should work in exactly the same manner.
2021-05-21 17:09:48 -06:00
John Demme 3d34c42164
[Python] Set a default context (and location) upon import (#1107)
The most common use case for the `circt.design_entry` API is that a single
context is used throughout the lifetime of the application. This creates a
default context and default location and installs them into the defaults stack.

Since we don't want this behavior whenever someone imports circt, don't import
`design_entry` into the `circt` namespace.
2021-05-21 16:05:02 -07:00
Mike Urbach 80a08ac9e8 [Python][NFC] Remove unused module parameter to create call.
This is no longer needed now that the BackedgeBuilder is implicit.

This change also includes some whitespace updates to line things up
after the RTL->HW name change.
2021-05-21 16:29:08 -06:00
John Demme 0610503b38 [Py] Fixing integration tests 2021-05-21 14:44:52 -07:00
Mike Urbach 8399e311a6 Fix integration tests, NFC.
The Handshake end-to-end tests were failing with assertions in
IMConstProp, so just disable that new pass for now.

The `set[BackedgeBuilder.Edge]()` type hint raises the following:

TypeError: Type Set cannot be instantiated; use set() instead
2021-05-21 11:00:18 -06:00
John Demme 83116dc2e1
[Py] Make BackedgeBuilder more general and keep a stack (#1119)
Divorces the support BackedgeBuilder from InstanceBuilder (so it can be used
elsewhere). Stores some extra information in the edge instead of digging it up
later in an InstanceBuilder-specific way.

Keep a stack of BackedgeBuilders in a contextvar. Provide a static method to
get the top.
2021-05-21 09:37:19 -07:00
Mike Urbach 79bf8521fd [Python] Use typing module to declare List types.
Using the list[type] syntax fails for me with this error:

```TypeError: 'type' object is not subscriptable```

Using the typing.List for the same task resolves that.
2021-05-20 16:53:22 -06:00
John Demme 128bf8ea78
[Py] Prototype @module annotation for design entry (#1080)
Fastest thing I could think of: uses HWModuleOp and calls construct immediately. Lots of ugliness in construct. A starting point for iteration.
2021-05-20 14:43:27 -07:00