-
Notifications
You must be signed in to change notification settings - Fork 159
Remove the need for KnownDomain
constraints throughout Clash designs
#978
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
Comments
Hi Martijn, Brilliant idea. Regards, Paddy |
See issue #978. Currently SDomainConfiguration has been added to Clocks, and functions which destructure clocks have been updated. Any more radical change involves massive fixing of black boxes, which is very time consuming.
Me and @leonschoorl talked about this yesterday. We concluded that the easiest way is probably to add GADT wrappers around data SClock (dom :: Domain) where
SClock (Clock dom) :: KnownDomain dom => SClock dom A few observations:
|
Will you be able to do something like edit: Ahh sorry I'm confused. |
It does since #2541 :-) You will need to pattern match, yeah.
The idea being that you can pass in any Clock/Signal/etc.? Yeah I like it. |
Clash primitives currently require
KnownDomain
constraints in order to change their behavior depending on their synthesis domain. It's implemented using class constraints as this - apart from all the dormant bugs it exposed - didn't require adding additional logic to the Clash compiler. An example of a primitive requiring aKnownDomain
constraint isregister#
:clash-compiler/clash-prelude/src/Clash/Signal/Internal.hs
Lines 1078 to 1082 in 9d278c2
To remove the need for this constraint we would need to do two things:
KnownDomain
constraints on Clash primitives. We subsequently need to add them toclockGen
,resetGen
, andenableGen
. These primitives would useknownDomain
to store aSDomainConfiguration
inside the constructs they're building. For example,Clock
might look like:(If this doesn't work out, we could go for
VDomainConfiguration
too.) Simulation constructs can now simply extract the synthesis domains from their given clocks. Of course, deconstructing clocks, resets, and enables is still not synthesizable! Thus...Clock
this would look like:(We might want to wrap this in a typeclass so we can use the same function on clocks, resets, and enables all the same.) Clash would need to collect all instances of
KnownDomain
before synthesis and insert the result ofknownDomain
for everyclockDomain
it sees.The text was updated successfully, but these errors were encountered: