Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PyCDE][Handshake] Add bindings for Handshake functions #7849

Merged
merged 10 commits into from
Nov 27, 2024

Conversation

teqdruid
Copy link
Contributor

@teqdruid teqdruid commented Nov 19, 2024

Exposes the Handshake dialect's FuncOp in the same style as an HWModuleOp:

class TestFunc(Func):
  a = Input(Bits(8))
  x = Output(Bits(8))

  @generator
  def build(ports):
    ports.x = ports.a & Bits(8)(0xF)

And instantiates them via ESI channels:

class Top(Module):
  clk = Clock()
  rst = Input(Bits(1))

  a = Input(Channel(Bits(8)))
  x = Output(Channel(Bits(8)))

  @generator
  def build(ports):
    test = TestFunc(clk=ports.clk, rst=ports.rst, a=ports.a)
    ports.x = test.x

@teqdruid teqdruid added Handshake PyCDE Python CIRCT Design Entry API labels Nov 19, 2024
@teqdruid teqdruid force-pushed the teqdruid/pycde/handshake branch 2 times, most recently from 358b677 to 8720c4a Compare November 19, 2024 23:33
Base automatically changed from teqdruid/handshake-python to main November 21, 2024 19:32
@teqdruid teqdruid force-pushed the teqdruid/pycde/handshake branch from 9640109 to 5aad5e3 Compare November 26, 2024 07:12
@teqdruid teqdruid marked this pull request as ready for review November 27, 2024 03:50
@teqdruid teqdruid requested a review from mortbopet November 27, 2024 03:54
@teqdruid
Copy link
Contributor Author

@mikeurbach You might be interested in this.

@mikeurbach
Copy link
Contributor

Very cool!

Copy link
Contributor

@mortbopet mortbopet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo "locking things down" and only allowing comb and handshake operations inside the Func (... for now).

@teqdruid
Copy link
Contributor Author

LGTM modulo "locking things down" and only allowing comb and handshake operations inside the Func (... for now).

The reason I didn't is that I'm not quite sure the best way to do this. I don't want the signals module to know about the handshake module... so I'd have to create a new infrastructure for the containing module to hook into any operation creation to validate or override it. I think that's a bit too much for this PR. Unless you have any suggestions for a simpler way to do this...?

@teqdruid teqdruid merged commit 8283dcb into main Nov 27, 2024
4 checks passed
@teqdruid teqdruid deleted the teqdruid/pycde/handshake branch November 27, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Handshake PyCDE Python CIRCT Design Entry API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants