Skip to content

Conversation

@kleinreact
Copy link
Member

@kleinreact kleinreact commented Oct 3, 2025

The PR adds some more high level primitives that are convenient to use during Clash circuit design. In particular, the PR adds:

  • the static left and right shift operators (<<%) and (%>>)
  • the apWhen apEn primitive, which is just a convenience extension of mux
  • the regEnN primitive, which is the probably most primitive FIFO just chaining regEns.

Still TODO:

  • Write a changelog entry (see changelog/README.md)
  • Check copyright notices are up to date in edited files

@gergoerdi
Copy link
Contributor

As a small comment, to me the name apWhen conjures the idea of whenA :: (Applicative f) => f Bool -> f () -> f (). I think your apWhen is more closely related to regEn, so maybe apEn or updateEn or something would be a more intuitive name?

@kleinreact
Copy link
Member Author

As a small comment, to me the name apWhen conjures the idea of whenA :: (Applicative f) => f Bool -> f () -> f (). I think your apWhen is more closely related to regEn, so maybe apEn or updateEn or something would be a more intuitive name?

I totally agree. I'm happy with apEn as well. It's nice, short, free and appealing.

@kleinreact kleinreact force-pushed the add-convenience-primitives branch from 0d809c1 to a26f3a1 Compare October 3, 2025 09:14
@kleinreact kleinreact force-pushed the add-convenience-primitives branch 2 times, most recently from 3fcaaaa to 98985c5 Compare October 4, 2025 15:47
@kleinreact kleinreact force-pushed the add-convenience-primitives branch from 98985c5 to faab3f8 Compare October 6, 2025 04:37
@martijnbastiaan
Copy link
Member

As discussed on Slack:

  • The shift primitives should be called %<<. and %>>. to fit the patterns set in Data.Bits
  • The shift primitives should work on Bits a, as doing it on BitPack a leads to unexpected behavior for signed numbers.

We've decided to drop it from this PR.

@kleinreact kleinreact force-pushed the add-convenience-primitives branch from faab3f8 to 6fadf21 Compare October 21, 2025 05:24
@kleinreact
Copy link
Member Author

I removed the static shift operations from the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants