Commit Graph

231 Commits

Author SHA1 Message Date
John Demme ab05dc700d
[ESI][PyCDE] Create cosim backend for ESI runtime API (#3854)
Adds a backend for Cap'nProtoRPC-based cosimulation to the generated ESI runtime API. Makes said API actually useful for interacting with a simulation. In the (near) future, backends will be implemented for real hardware. Also adds a test.
2022-09-19 13:10:46 -07:00
John Demme ce0c1670a1
[ESI][NFC][Services] In service implement reqs, avoid args (#3928)
Previously toServer inputs were being passed into the port req block via
block args, which needlessly complicates things. Change that.
2022-09-16 20:40:04 -07:00
John Demme 6f8ebd2cb5
[ESI][Services][NFC] Adding an OpInterface for declarations and making arg/result names more consistent (#3927)
Added the `ServiceDeclOpInterface` which is intended to be implemented by any op which'll be a service declaration. Has methods to get the list of service ports and validate a connection request. The introduction of a struct which describes a service port allowed me to clean up a bunch of code. This changed the error messages, requiring an update to the errors test.

Also took this opportunity to standardize terminology on `toClient` and `toServer` to provide better clarity. Was helpful in debugging this change.
2022-09-16 16:00:45 -07:00
John Demme fd1adf2a2d [ESI][Cosim] Automatically detect driver name
Endpoint IDs differ by simulator by prefix, wherein the prefix is based
on the top module. Instead of specializing tests to the simulator,
automatically prepend the endpoint ID prefix to endpoint IDs on open
requests.
2022-09-06 15:39:42 -07:00
Morten Borup Petersen d1ff1e1371 [PyCDE] Remove unused imports from test 2022-09-01 15:24:18 +02:00
John Demme 4d991ac633
[ESI] Software API creation infrastructure (#3765)
Build a model of the ESI system described in a `services.json` file. No 'backend' connectivity providers in this cut. Only integer types are supported for now.
2022-08-27 11:54:16 -07:00
John Demme a118a0e872 [PyCDE] Switch to `pathlib` in System 2022-08-24 14:35:54 -07:00
John Demme 59661c8bbc
[ESI][Cosim] Switch from numeric IDs to strings (#3757)
Use the module instance path + an optional extension. Solves the multiple
instance problem.
2022-08-22 13:28:45 -07: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
Morten Borup Petersen 58abeb481f
[PyCDE] Support additional include files in coco tests (#3724) 2022-08-16 13:06:38 +02:00
Morten Borup Petersen e018da33ea
[PyCDE] Use cocotb-test as test driver (#3725)
No more custom makefile generation and 'make' commands - this is handled by cocotb-test.
Eventually, we expect support for driving cocotb from within python to be included in a future cocotb release. The support in `cocotb-test` is currently identical to the (unreleased) support in upstream `cocotb`. Hence, we use `cocotb-test` since they publish a pypi package that can be easily downloaded.
2022-08-16 08:46:14 +02:00
alandy ba8c9a82d5
[PyCDE][FSM] Capture guard_port name at lamba creation time (#3718)
Fixes an issue in PyCDE gen_fsm helper that causes all transitions to use the last guard. Fix captures the intended guard_port name at lamba creation time.

Co-authored-by: Aaron Landy <aalan@microsoft.com>
2022-08-12 16:17:06 -07:00
Mike Urbach 66a63e57ae
[PyCDE] Add new API to import existing HW modules into a System. (#3704)
This can be used to load HW modules and insert them into a System.
2022-08-12 14:50:13 -06:00
John Demme 1851eacadb
[PyCDE] [ESI] Expose InOut service ports to PyCDE (#3707)
Allow PyCDE users to connect to InOut service ports. PyCDE calls these connections ToFromServer. Not sure if that's a better name than InOut.
2022-08-12 13:13:05 -07:00
John Demme 81d079a563 [PyCDE] Create module ports in lexical order rather then alphanum 2022-08-11 19:30:20 -07: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
John Demme a6275fe60a
[ESI] [PyCDE] Enable users to implement services in PyCDE (#3701)
- Add PyCDE service generator 'dispatcher' which gets called upon request from the wiring pass, then forwards the call to a generator which it has in its registry.
- Add a `ServiceImplementation` decorator to tag and mutate a class appropriately.
- Calls the `ServiceImplementation` generator passing both the usual module ports and the requested ESI connections.
- A few relevant fixes/additions to supporting code.
2022-08-11 11:22:02 -07:00
John Demme 69b1fcd2d4 [PyCDE] Use CIRCT Python backedges when building Wires
CIRCT's Python backedges have the advantage of detecting when they are
left unconnected.
2022-08-10 21:02:11 -07:00
John Demme feab86af48
[PyCDE][NFC] Value: revert fancy __new__ dispatch method (#3703)
Using `__new__` to redirect construction to a specialized class had too
many side-effects. Trying to get around them led to convoluted code.
Move back to a function-based dispatch method.
2022-08-10 20:46:54 -07:00
John Demme 786daa2b71 [PyCDE] Misc bug fixes related to ESI and llvm submodule bump 2022-08-10 15:43:27 -07:00
John Demme 4e12269350
[PyCDE] Add `Reg` and `Wire` declarations which can be assigned to (#3677)
`Wire` is intended to create backedges. `Reg` is not strictly necessary, but
it should give RTL programmers a warm and fuzzy feeling.
2022-08-08 13:14:06 -07: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
Morten Borup Petersen a7cd89fa92 [PyCDE] Enable passes in `test_hwarith.py` 2022-08-05 09:39:19 +02:00
John Demme d9c1b93592
[PyCDE] Fix liveOperations bug (#3665)
The `Else` global object was holding on to refs after __exit__. This
shouldn't have been a global object reference to begin with.

Fixes #3660.
2022-08-04 19:02:07 -07:00
Morten Borup Petersen 06f0b9d4a3 [PyCDE] Revert stray code in test_fsm.py 2022-08-04 08:32:44 +02:00
John Demme f2340e5710
[PyCDE] If-Then-Else syntactic sugar for muxes (#3633)
Allows specifying muxes with `if`-like syntax. This is the closest we can
get without having to do AST inspection (I think).

```
  @module
  class IfDemo:
    cond = Input(types.i1)
    out = Output(types.i8)

    @generator
    def build(ports):
      with If(ports.cond):
        v = types.i8(1)
      with Else:
        v = types.i8(0)
      EndIf()
      ports.out = v
```
2022-08-03 13:45:54 -07:00
John Demme 09a39346f1 [PyCDE] Make capnp dependency optional 2022-08-01 17:31:23 -07:00
John Demme 482e0ff366
[PyCDE] Integration test for ESI Cosim (#3632)
Adding an end-to-end cosimulation loopback pycde-driven flow integration test with ESI services. It works!
2022-08-01 17:21:14 -07:00
John Demme 86600f93c6 [PyCDE] Name arithmetic operations
If the two operands have names, name the result based on the operand
names and the operation.
2022-07-31 00:06:22 -07:00
John Demme df5bc024d1 [PyCDE][Bugfix] Sanitize module symbols
Avoids a bug wherein the pass parser is unable to handle oddball
characters.
2022-07-29 19:23:53 -07:00
John Demme 0af0aaea3b
[PyCDE] Add integration test infra (#3625)
Create an integration test target with all the appropriate EDA tool aliases in place.
2022-07-29 13:21:08 -07:00
John Demme 3f28797d02 [PyCDE] Bug/warning fixes
Warnings about asserts always being true. Needed the ESI connect
services pass.
2022-07-28 18:23:22 -07:00
John Demme ea3027f298
[ESI][NFC] Rename Ops and Types to include those suffixes (#3622)
Update the ESI class names to standard naming conventions. Mechanical search and replace.
2022-07-28 11:19:01 -07:00
Morten Borup Petersen c9ea6d7e65
[PyCDE] Initial cocotb integration (#3510)
This commit represents a starting point for PyCDE+cocotb integration.
Currently, only iverilog is supported, seeing as verilator has questionable cocotb support (https://github.com/cocotb/cocotb/issues/2300), with questa posting another set of challenges locally.
Given the limited capabilities, the support is at this point mostly intended for PyCDE integration testing.

The "support" is mainly syntactic sugar in terms of moving things around to make PyCDE-like code fit into a cocotb flow.
The @testbench decorator defines a testbench on a PyCDE module. In here, @pycdetest functions are expected to take a single argument representing the top-level ports of the PyCDE module under test.
This function may then contain any cocotb-style code.

Under the hood, @testbench will:
1. Run the PyCDE flow, generating an SV file
2. Verbatum copy the @pycdetest functions to a separate file, rewriting these to conform to cocotb.
3. Create a makefile for driving the cocotb flow
4. Run `make` and let cocotb do its thing.
2022-07-28 13:45:32 +02:00
Morten Borup Petersen 5cfce2ac24 [PyCDE] Add infix operator support
This commit adds support for infix operations on PyCDE bit vector values. Arithmetic operators are implemented through `hwarith` operation, logic operators through `comb`.

cleanup

review comments
2022-07-28 09:22:30 +02:00
John Demme c89724ac82 [PyCDE] Add error tests for Mux
This should have been part of the last commit. Oops.
2022-07-27 15:35:46 -07:00
John Demme d092f5c8e7 [PyCDE] Add 'Mux' construct
Multi-bit select signal mux. Detects error cases.
2022-07-27 15:33:33 -07:00
John Demme 5eaf0a6ecf Revert "[PyCDE] Add infix operator support (#3608)"
This reverts commit b5714cec52. PyCDE
tests are failing since this commit.
2022-07-27 14:33:37 -07:00
John Demme 15a5f62857
[PyCDE] [ESI] Model ESI services in PyCDE (#3611)
Adds PyCDE constructs to model ESI service declarations and request connections to/from them. Also contains a "standard" `HostComms` interface and rudimentary way to get a cosim implementation.
2022-07-27 12:26:38 -07:00
Morten Borup Petersen b5714cec52
[PyCDE] Add infix operator support (#3608)
This commit adds support for infix operations on PyCDE bit vector values. Arithmetic operators are implemented through `hwarith` operation, logic operators through `comb`.
2022-07-27 13:45:59 +02:00
John Demme 6932198ea9 [ESI] Adding Python binding for `Any` type 2022-07-26 20:57:05 -07:00
John Demme a76bb4a0c0 [PyCDE] [NFC] Creating a common module, adding _PyProxy
Moving classes without any PyCDE dependencies to common.py. Introducing
a more generic _PyProxy parent class.
2022-07-26 20:47:00 -07:00
John Demme 425099a327 [PyCDE] Fix attaching SV attributes to registers
New model of SV attributes introduced by
b356227991 requires this patch.
2022-07-25 17:00:10 -07:00
Morten Borup Petersen 21b3920d3b
[PyCDE] Add shorthand FSM builder function (#3560)
Generate a FSM from a dictionary of states and their transitions.

E.g.:
```
{
    "a": [
        ("c", "go"),
        "b",
    ],
    "b": [],
    "c": []
}
```

creates an FSM with 3 states (a, b, c). 'b' and 'c' have no outgoing transitions, and 'a' has two outgoing transitions. The first transition ("c", "go") transitions to 'c' whenever an input port 'go' is asserted. The second transition is a default transition to 'b'.

Any state and guard referenced within the dictionary will automatically be created as a state operation and top-level input, respectively.
2022-07-22 11:40:59 +02:00
Morten Borup Petersen 3e0ed79607 [PyCDE] Add missing argument to UnconnectedSignalError 2022-07-18 14:27:41 +02:00
Morten Borup Petersen 5e9a0b4048 [PyCDE] Also run convert-fsm-to-sv in passes 2022-07-18 10:24:55 +02:00
Morten Borup Petersen 44ca552b73 [PyCDE] Make rst signal required for FSM instantiations 2022-07-18 09:48:44 +02:00
Morten Borup Petersen 6f09935f3e [PyCDE] Fix regressions from 58e5845, c653bdd 2022-07-18 09:27:32 +02:00
John Demme 342d4981f4
[PyCDE] [AppID] Iterate through appids of a given name (#3457)
Provides an iterator through which a user can iterate all the indices
for a particular appid name.
2022-06-30 12:12:18 -07:00
John Demme bacadb63d6 [PyCDE] [NFC] Cleanup imports and line lengths 2022-06-30 11:10:28 -07:00