-
Notifications
You must be signed in to change notification settings - Fork 155
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
Remove KnowDomain #2589
base: master
Are you sure you want to change the base?
Remove KnowDomain #2589
Conversation
This changes the error when using non-existant arguments in blackboxes from: Blackbox required at least 32 arguments, but only 8 were passed. to the new error: Blackbox used "~ISSYNC[31]" , but only 8 arguments were passed.
So it'll be easier to keep the temp directory
In preparation for #2589 "Remove KnownDomain". This is the only constraint addition in clash-prelude in for the KnownDomain removal, by adding it here for 1.8 we can do the KnownDomain removal later, with less backwards compatibility issues. This commit also had to add a KnownDomain to invertReset, because it used unsafeToReset, but this will be removed again by #2589.
1a32fa9
to
e22bb55
Compare
It now correctly "escapes" square brackets in the right places. And correctly brackets the second argument of ~SIGD
Utility that can convert blackboxes from clash-lib .primitives.yaml files to InlineYamlPrimitive ANNotations.
You can now use ~PERIOD, ~ISSYNC, ~ISINITDEFINED and ~ACTIVEEDGE on arguments of type Clock,Reset,Enable,ClockN and DiffClock.
This allows the removal of the KnownDomain constraint on functions which take a Clock and/or a Reset/ Which is most of them. The only functions that still need a KnownDomain constraint should be the ones creating Clocks and/or Resets.
* ZKnownDomain is used only blackboxes, it used to replace the KnownDomain there, so we can postpone the renumbering of arguments
For the more complex ones I've replaced KnownDomain with the a dummy ZKnownDomain constraint, so the argument numbers stay the same for now.
For some functions we add explicit foralls, so the order of the type arguments stays the same.
You don't need to provide a KnownDomain anymore
The conversion was done automatically by running: cabal run -- prim-yaml-to-inlineyaml Clash.Explicit.BlockRam.blockRamU# Clash.Explicit.BlockRam.blockRam1# Clash.Explicit.BlockRam.blockRam# Clash.Explicit.BlockRam.Blob.blockRamBlob# Clash.Explicit.BlockRam.File.blockRamFile# Clash.Explicit.RAM.asyncRam# Clash.Explicit.ROM.rom# Clash.Explicit.ROM.Blob.romBlob# Clash.Explicit.ROM.File.romFile# Clash.Explicit.Testbench.assert Clash.Explicit.Testbench.assertBitVector Clash.Signal.Internal.delay# Clash.Signal.Internal.register# Clash.Signal.Internal.asyncRegister# Then the annotations were manually moved to be next to their haskell definitions.
Current doctest(-parallel) can't pickup such defines automatically, so we have to do it manually. And also define CLASH_OPAQUE, to prevent a ton of warnings.
e22bb55
to
50594a4
Compare
50594a4
to
8dae71e
Compare
In preparation for #2589 "Remove KnownDomain". This is the only constraint addition in clash-prelude in for the KnownDomain removal, by adding it here for 1.8 we can do the KnownDomain removal later, with less backwards compatibility issues. This commit also had to add a KnownDomain to invertReset, because it used unsafeToReset, but this will be removed again by #2589.
In preparation for #2589 "Remove KnownDomain". This is the only constraint addition in clash-prelude in for the KnownDomain removal, by adding it here for 1.8 we can do the KnownDomain removal later, with less backwards compatibility issues. This commit also had to add a KnownDomain to invertReset, because it used unsafeToReset, but this will be removed again by #2589.
In preparation for #2589 "Remove KnownDomain". This is the only constraint addition in clash-prelude in for the KnownDomain removal, by adding it here for 1.8 we can do the KnownDomain removal later, with less backwards compatibility issues. This commit also had to add a KnownDomain to invertReset, because it used unsafeToReset, but this will be removed again by #2589.
Overall this looks good, although it will take me more time to review it properly. Concerning the bike shedding, here are my thoughts:
An alternative take on (3) would be to wrap existing types ( My preference would be (2), (0), (3). |
Removing the need for KnownDomain constraints
This an implementation of the idea from #978, removing (most of the need for) the KnownDomain constraint.
The core change of this PR is to hide the
KnownDomain
constraint inside theClock
andReset
types.The allows us to drop the
KnownDomain
constraint from every function take takes either aClock
or aReset
, which is most of them.The only things that still require a
KnownDomain
constraint are functions that createClock
s orReset
s:noReset
,clockGen
,resetGen
and their variantssimulate
,sample
and all their variants 1unsafeFromActive[High,Low]
,unsafeToReset
altpll
,alteraPll
,clockWizard
,clockWizardDifferential
And some tracing functions:
traceSignal
,traceVecSignal
When using any of these functions that still requires a
KnownDom
there a couple of ways of handling it:Don't do anything, just propagate the constraint up to your type signature, so your caller will have to solve it.
Make your code monomorphic.
By specializing to a specific domain, GHC will automatically solve
KnownDomain
constraints for you.Use the new
provideKnownDomainFrom
Click here for its definition
This helper function take something containing a KnownDomain contraint as first argument, extracts it and provides it to the second argument.
Use the new
ExtractClockDom
andExtractResetDom
PatternSynonyms to extract the KnownDomain for youClick here for its definition
ExtractResetDom
is just a synonyms for the patternReset{}
. But limited in such a way that it is safe to use, and won't generate broken (V)HDL, and therefore is safe to export fromClash.Prelude
etc.Change or make variants of (some of) these that take an additional
Clock dom
argument.I'm think this could be convenient for:
noReset
,traceSignal
,traceVecSignal
and maybeunsafeFromActive[High,Low]
.Options
0.
and1.
are nothing new, they were already possible before this PR.Options
2.
and3.
are new options added in this PR, but I'm unsure if it makes sense to add both, or if that would just clutter up the API unnecessarily.Also I'm not happy with the current names, they could do with some bike shedding.
Option
4.
I haven't implemented, could be convenient, but would be more incompatible API changes, or add more slightly different variants of existing functions.Still TODO:
Footnotes
Except the Explicit variants of
simulate
,simulateB
,sample
,sampleN
,sample_lazy
andsampleN_lazy
. ↩