Commit Graph

121 Commits

Author SHA1 Message Date
John Demme a949a76841
[PyCDE] Improving the PyCDE type system (#2452)
No longer inherit the specific type, which involved some black magic.
Move to a more sane class hierarchy and base everything around the new
PyCDE type class hierarchy. Eventually, we'd like to have `Type` be the
root of the hierarchy, but inheriting from `mlir.ir.Type` makes the
transition less painful.

Enables using the standard python function overrides to both print more
reasonable type strings and avoid some of the `isinstance` switch-like
structures elsewhere. More of the latter to come.
2022-01-13 11:18:16 -08:00
Mike Urbach ef3d36261e [PyCDE] Update "pycde" tag prefix for setuptools_scm.
The quotes around the match pattern are not needed in the TOML file.
2022-01-12 16:50:02 -07:00
Mike Urbach 2a989e89dd [PyCDE] Search for "pycde" tag prefix with setuptools_scm.
The default git describe command will simply return the most recent
tag. We want the most recent tag prefixed with "pycde", otherwise we
might try to parse the version from the wrong tag.
2022-01-12 16:09:06 -07:00
John Demme 59f00457e4 [PyCDE] Fixing tests broken by wirecleanup pass 2022-01-11 03:02:14 +00:00
John Demme 24429a512e [MSFT] [Partitioning] Small fixes / cleanups 2022-01-11 02:51:45 +00:00
mikeurbach c9c50d2889
[MSFT] Add optional sub-path to PhysLocationAttr. (#2421)
Previously, a sub-path could be specified by encoding it in the name
of the attribute using a certain scheme. This is brittle and
non-standard. To make this more natural and robust, the sub-path is
added as a field of the attribute definition as a StringRef. It is not
required, in which case an empty StringRef can be used. The attribute
name for placement attributes is no longer used in any logic.
2022-01-05 18:39:54 -07:00
Mike Urbach a2a058b70e [MSFT] Refactor placement export to use hw::GlobalRefs.
This refactors ExportQuartusTcl to use the hw::GlobalRefs and arrays
of hw::InnerRefAttrs directly. This greatly simplifies the
implementation, and removes the need for SwitchInstanceAttr. That
attribute will be fully removed in a follow up.
2021-12-27 13:51:57 -07:00
Mike Urbach 737d474872 [MSFT] Refactor placement entry to use hw::GlobalRefs.
This replaces the use of msft::SwitchInstanceAttr on leaf entities
with a hw::GlobalRefOp. The global ref specifies the same path, using
an array of hw::InnerRefAttrs. It also has an attribute containing the
same placement information as the msft::SwitchInstanceAttr had.

This will simplify ExportQuartusTcl by letting it simply generate Tcl
referring to the hw::GlobalRefs. It will also make the placements
robust to changes in the instance hierarchy via the guarantees
provided by hw::GlobalRef's verifier and utilities for rebuilding
hw::GlobalRefs.
2021-12-27 13:51:32 -07:00
John Demme 0e5e797edf
[MSFT] Design partition support, part 3 (#2376)
One more step towards #2365. This PR adds the "bubble up" entities pass.
2021-12-22 15:11:32 -08:00
John Demme 87081b9896
[MSFT] Design partition support, part 1 (#2366)
The "design partition" feature supports scenarios wherein the designer needs the RTL output module hierarchy to be different than the logical hierarchy they are designing. With this feature, they just create a design partition then "tag" various entities with it. Upon compilation, CIRCT will refactor the hierarchy to move the tagged entities into the specified target partition. The design partition _must_ be found in the module hierarchy above (or in the same module as) the tagged entities.

Partial progress towards #2365.

- Modeling in CIRCT and PyCDE
- Move entities in the same module as the partition
2021-12-20 17:57:41 -08:00
mikeurbach 63165b00e7
[PyCDE] Add Value wrappers for comparators and ArrayConcat. (#2341)
The comparator subclasses didn't subclass OpView when they should
have, which prevents them from being automatically wrapped with PyCDE
Values.

The create extension for ArrayConcat was simply missing.
2021-12-14 14:23:40 -07:00
mikeurbach d1e8b46bb6
[PyCDE] Add support for placing CompRegOp. (#2304)
This extends the Instance wrapper to wrap not just instances but also
registers. Additionally, in the Tcl export, this looks for registers,
adds them to the symbol cache, and uses their symbol names.

Users are now able to place CompRegOp when its innerSym attribute is
set. If they create a CompRegOp directly, the inner_sym must be passed
explicitly, but the `reg(...)` helper on Value is extended to use the
name as the inner_sym when passed.
2021-12-09 17:47:06 -07:00
John Demme e7263d344c
[PyCDE] Updating naming to use new 'sv.namehint' attribute (#2284) 2021-12-07 10:27:51 -08:00
John Demme 7cf4f5e365 [PyCDE] Hide support functions which convert objects from Python to MLIR
The `obj_to_value` and `var_to_attribute` functions used to be publicly
exposed since they had to occasionally used by users. Now that we've
patched all the cases, "hide" them. Also rename to be more consistent
with each other.
2021-12-02 05:22:57 +00:00
John Demme be39c7d18f [PyCDE] Change <type>.create(obj) to <type>(obj)
Make it feel more like a class instantiation.
2021-12-02 05:17:44 +00:00
John Demme dc7d72c93e [PyCDE] Use VerbatimOp in lieu of IfDefOp 2021-11-23 19:27:49 +00:00
John Demme d2e29b5363
[PyCDE] Emit header guards for typedefs (#2221) 2021-11-19 14:42:51 -08:00
mikeurbach 7cf1caed2f
[PyCDE] Wrap all CIRCT ops in PyCDE Value veneer. (#2052)
This adds new `pycde.dialects` modules which can be imported instead
of their corresponding `circt.dialects` modules. All ops in the
`pycde.dialects` modules are enhanced to have their constructor
create a PyCDE Value. The `create` methods already work with PyCDE
Values as operands, because they generally call `support.get_value`,
which supports PyCDE Values through duck typing. Together, this means
that all PyCDE generators can uniformly work with Values, as long as
users import `pycde.dialects` and use those definitions.
2021-11-15 14:32:05 -08:00
mikeurbach bd05d96c11
[PyCDE] Add entry method for PhysicalRegions and their references. (#2174)
This add the necessary Python binding boilerplate to create
PhysicalBounds and PhysicalRegionRef attributes. A new API is added to
System, which inserts a PhysicalRegion. A wrapper class for
PhysicalRegion allows creating a region, adding bounds, and getting a
reference attribute suitable for use with the add_attribute API.
2021-11-15 10:02:34 -08:00
John Demme 2d69cf9b39 [PyCDE] Add sv/tcl files to System file list 2021-11-12 05:24:25 +00:00
John Demme 75c6cca442
[PyCDE] [MSFT] Emit modules into separate SV files (#2158)
Add an attribute to `msft.module` specifying the filename in which the
generated SystemVerilog should be placed. In PyCDE, use the module name
as the output filename.
2021-11-11 20:13:13 -08:00
mikeurbach 41bffc1b64
[PyCDE] Make tests platform-independent. (#2136)
The previous usage of environment variables and shell redirection
wouldn't work on Windows. Replace that with a command line argument
and --input-file respectively.
2021-11-10 16:10:33 -07:00
Mike Urbach c11c3376e7 [PyCDE] Remove export_verilog call from System.run_passes.
This was previously needed to get the LegalizeNames side-effects
before applying placements. Now that we apply placements and use
instance name symbols before LegalizeNames and ExportVerilog, it is
unnecessary.
2021-11-10 13:53:40 -07:00
Mike Urbach aac9048198 [PyCDE] Update compreg lowering test to check for always_ff.
Recent always_ff lowering changes now kick in for the compreg, and it
lowers to always_ff. Since that's the behavior we want, update the
test and lock it in.
2021-11-10 11:39:23 -07:00
mikeurbach a002a849b3
[MSFT] Re-work ExportQuartusTcl to export into verbatim nodes. (#2077)
This is the preferred way to output design collatoral. Closes
https://github.com/llvm/circt/issues/2068.

The ExportQuartusTcl pass is removed, and the functionality is moved
into LowerMSFTToHW. The pass now populates a SymbolCache of the things
we care about in the export, namely instances. It produces verbatim
ops containing the Tcl, which can then be emitted from ExportVerilog.

The old Python API to run the export is removed in favor of the new
approach. PyCDE now exports both System Verilog and Tcl using the
exportSplitVerilog API to output files into a directory.
2021-11-09 19:25:16 -07:00
mikeurbach 66acfe31b7
[MSFT] Introduce msft.module.extern op for PyCDE lowering. (#2106)
The op is identical to hw.module.extern, but it can be referred to by
a msft.instance op. This adds a cleaner layering where PyCDE only
generates msft.module/msft.module.extern/msft.instance ops. Before, it
would generate msft.module/hw.module.extern, leading to a mix of
msft.instance/hw.instance for LowerMSFTToHW to consume. This change
introduces a clear contract for PyCDE's output: all module and
instance ops are from the MSFT dialect.

Some of the implementation is duplicated into MSFTOps.cpp from
HWOps.cpp, but refactoring is left as a future exercise, captured in
https://github.com/llvm/circt/issues/2107.
2021-11-08 18:40:46 -07:00
John Demme 6c8c38ac90 [PyCDE] Adding some location tracking 2021-11-08 15:45:44 -08:00
Mike Urbach 22e0ea8a6c [MSFT] Combine attributes and ops into same Python namespace.
Previously, `circt.msft` contained the attributes and pysical design
functionality, and `circt.dialects.msft` contained the ops. To unify
things and avoid confusion, combine these into the
`circt.dialects.msft` Python namespace.
2021-11-05 10:09:18 -06:00
mikeurbach 26f4044899
[PyCDE] Set local_scheme to "no-local-version". (#1999)
This removes the local part of the version, which includes a commit
hash. The commit hash is redundant since the number of commits since a
version is already included in the version string, and we don't
rewrite git history. The local part of the version isn't compatible
with package registries, so we remove it.
2021-10-14 17:03:46 -07:00
mikeurbach 06e512d4b2
[PyCDE] Use setuptools_scm package to infer version from Git. (#1984)
This is "the blessed package to manage your versions by scm tags".

The current tag format is `pycde-<major>.<minor>.<patch>`.
2021-10-14 08:15:41 -07:00
John Demme 3346035189 [PyCDE] Setup.py tweaks for Windows wheel builds 2021-10-11 19:12:14 -07:00
Mike Urbach 3f7f56ab94 [PyCDE] Setup enhancements for wheel building.
* Support a new CIRCT_EXTRA_CMAKE_ARGS environment variable to allow
  CIs or users to add extra arguments to cmake.
* Set the --parallel option when building.
2021-10-11 17:49:09 -07:00
John Demme 7dd00dc842
[PyCDE] Setup.py: only compile the bare minimum (#1953) 2021-10-07 22:08:19 -07:00
John Demme ded6afc593
[PyCDE] Generate symbol names for instances and other fixes (#1952)
- Now that MSFT instances are symbols, we have to manually uniquify them.
- Legalize names is no longer a pass. Since it's a part of export verilog, run that instead 'cause code run after `run_passes` may rely on legal names.
- Update some of the tests.

These fix the broken PyCDE tests.
2021-10-07 18:09:03 -07:00
John Demme dfba36df9f
[PyCDE] Expose DeviceDB and wrap/hide some raw CIRCT objects (#1943) 2021-10-06 21:37:11 -07:00
mikeurbach bb5f6a8658
[PyCDE] Setup improvements for wheel building in CI. (#1941)
This adds two changes to PyCDE's setup.py to help build wheels in CI:

* Adds an optional CIRCT_DIRECTORY environment variable for CIs to
  pass a path to the CIRCT root. This is needed, for example, when
  building with cibuildwheel.
* Makes the path to LLVM relative to CIRCT, assuming the submodule is
  used. This previously looked for an LLVM directory sibling to the
  CIRCT directory, which puts an assumption on how LLVM is downloaded.
  The submodule is the documented location, and if something else is
  required, we can add an environment variable for that.
2021-10-06 17:34:16 -06:00
John Demme 5a4445ec3e [MSFT] [NFC] DeviceDB -> PrimitiveDB, combine all DB code
- Renames DeviceDB to PrimitiveDB.
- Puts both PrimitiveDB and PlacementDB in DeviceDB.h.
- Moves PlacementDB implementation into DeviceDB.cpp.
2021-10-06 14:23:55 -07:00
John Demme daa5dc503e [MSFT] Rename DeviceType enum to PrimitiveType 2021-10-01 22:09:52 -07:00
John Demme 21f720134e
[PyCDE] Move from returning output values to setting them (#1919)
Adds a setter on the generator argument which sets the value of the output
port. Also provides a `set_all_ports` method for programatic access and easy
legacy conversion.

There are two advantages of this: (1) Symbolic port names vs. string port
names. (2) More importantly, exceptions are raised when the code tries to set an
output port value, which provides a traceback to the relevant line.
2021-10-01 18:26:27 -07:00
Parker Mitchell f76fadad6e
[MSFT] Rename DeviceDB to PlacementDB (#1894)
No functional changes. This PR simply renames DeviceDB to PlacementDB within the MSFT dialect. The "DeviceDB" name may be used in a future PR and live alongside the PlacementDB.
2021-10-01 18:24:10 -07:00
John Demme 9b3a48b083
[PyCDE] Use `System` to track raw CIRCT module ops (#1908)
Keep all the raw CIRCT module ops in `pycde.System`. Enables the same PyCDE
modules to be used multiple Systems (theoretically, unsupported/untested for
now). It is also the only class which runs CIRCT passes, so it knows when to
invalidate the symbol cache. The symbol cache is the only data structure which
holds CIRCT module ops. Increases memory safety.
2021-09-30 13:15:04 -07:00
mikeurbach 33e975e855
[Python][CI] Fix formatting check by using an image with toml. (#1906)
This is required by the yapf tool we use to enforce formatting. Switch
back to using bash syntax for this check. Also re-format a few spots
that slipped in while the check was broken. Fixes #1162.
2021-09-30 09:40:37 -06:00
John Demme 5f7c2f8c96
[PyCDE] Fix instances to fit new model (#1900) 2021-09-29 13:03:34 -07:00
John Demme 5ce049986f [PyCDE] [MSFT] Fail / warn fast during generation and lowering 2021-09-28 21:09:48 -07:00
John Demme 04e4db7bc6
[PyCDE] Move to `msft.module`/`msft.instance` and move generation into Python (#1874)
This is a _massive_ refactor. There's still some rough edges, but it should be far simpler, more logical, and "safer" from MLIR operation memory perspective. This refactor does break the instance/appid features, which I'll fix later on. That test is marked XFAIL for the moment. This closes out #1755.
2021-09-27 11:15:42 -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
John Demme e6dfaa018b [PyCDE] Fixing tests for compreg changes 2021-09-08 21:14:08 -07:00
John Demme 027f2ed9a4
[PyCDE] Add bitvector extraction syntatic sugar (#1753)
Adds __getitem__ overload on `pycde.Value` for mlir IntegerType which creates a `comp.extract` operation and returns its value.
2021-09-08 20:23:54 -07:00
John Demme 3634b6c6e1 [PyCDE] Make Values easier to name 2021-09-08 00:38:19 -07:00
John Demme 40d0336cd5
[PyCDE] Use and expose new device database (#1719)
- Checks for existing placement when trying to attach placement.
- Exposes `get_instance_at` to check for existing placements.
2021-09-07 12:01:15 -07:00