-
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
Keep casts of the form x ~ Integer
#1928
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FIXED: Don't error out on `counter ~ (Index numStages)` like equalities [#1927](https://github.com/clash-lang/clash-compiler/issues/1927) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{-# LANGUAGE AllowAmbiguousTypes #-} | ||
module T1927 where | ||
|
||
import Clash.Prelude | ||
import Control.Monad | ||
|
||
topEntity | ||
:: Signal System (Vec 1 (Signed 1)) | ||
-> Signal System (Maybe (Vec 1 (Signed 1, Signed 1))) | ||
-> Clock System -> Reset System -> Enable System | ||
-> Signal System (Maybe (Vec 1 (Signed 1, Signed 1))) | ||
topEntity angles xs c r e = exposeClockResetEnable (machine @8 angles xs) c r e | ||
|
||
machine | ||
:: forall numStages pairs coord angle dom counter | ||
. HiddenClockResetEnable dom | ||
=> (1 <= numStages) | ||
=> (KnownNat numStages, KnownNat pairs) | ||
=> (Default coord, NFDataX coord) | ||
=> (Default angle, NFDataX angle) | ||
=> counter ~ (Index numStages) | ||
=> Signal dom (Vec pairs angle) | ||
-> Signal dom (Maybe (Vec pairs (coord, coord))) | ||
-> Signal dom (Maybe (Vec pairs (coord, coord))) | ||
machine thetas coords = mealy transition def $ liftA2 (liftM2 zip) coords (return <$> thetas) | ||
where | ||
transition :: (counter, Vec pairs ((coord, coord), angle)) | ||
-> Maybe (Vec pairs ((coord, coord), angle)) | ||
-> ( (counter, Vec pairs ((coord, coord), angle)) | ||
, Maybe (Vec pairs (coord, coord)) | ||
) | ||
transition (k, xyzs) maybeInputs = case (k == 0, maybeInputs) | ||
of (True, Nothing) -> ((0, xyzs), Just $ map fst xyzs) | ||
(True, Just xyzs0) -> ((0, xyzs0), Just $ map fst xyzs) | ||
(False, _) -> ((satSucc SatWrap k, xyzs), Nothing) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also need a case for
Integer ~ x
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for issue #1927 specifically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but would you trigger the same issue by changing
counter ~ (Index numStages)
to(Index numStages) ~ counter
in the test? If so I think we should add the extra case to avoid weird (albeit unlikely) situations where someone's design fails unexpectedly unless they change the argument order to(~)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tried. I'm somewhat uncomfortable with this PR to begin with. I'd rather properly support all casts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, supporting all casts would be the better option. How far was #1064 from being finished?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It went in the right direction. But I would want to redo some aspects, especially with regards to
Tick
. SosquashCollectApp
was there in terms of handling casts I think, butTicks
still need more care: depending on the type of info (source location, HDL naming, etc.) the ticks either should or shouldn't be distributed towards the arguments as we "squash" the entire application.