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
Fix asyncRam#: multiple clocks, undefineds, laziness #2031
Merged
Merged
Conversation
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
DigitalBrains1
force-pushed
the
asyncram_multi_clk_fix_1.4
branch
from
January 7, 2022 12:58
2beec6b
to
90f2feb
Compare
This is a partial backport of #2006. 1. In Haskell simulation, the way read samples were produced, with `unsafeSynchronizer`, was simply wrong. It would compress and duplicate samples while traversing clock domains, which is not a correct model of how it works. The generated HDL was fine, it only affected Haskell simulation. 2. The Haskell model of `asyncRAM#` treated an _undefined_ write enable as an asserted enable. But an _undefined_ value in Haskell can correspond to any value whatsoever in HDL, so HDL simulation might or might not write. With this commit, the `XException` of the write enable is written as the value in the RAM, since it could have either been written to or not been written to. On the next read of that address, it will return the `XException`. This issue did not propagate to `asyncRam` and `asyncRamPow2`, since there, the same condition also causes the write address to be undefined, and this is properly handled by the primitive. 3. The `asyncRAM#` primitive was also too strict in most of its inputs. Combinatorially feeding the read output to the write-side inputs would lock up the simulation, while it is a valid circuit. This problem did not propagate to the `asyncRam` and `asyncRamPow2` functions, which are lazy enough because the signals go through `Signal`'s `fmap` and `<*>`. 4. Data written to memory is `seqX`d for efficiency. Additionally, documentation for memory components was harmonized and corrected.
DigitalBrains1
force-pushed
the
asyncram_multi_clk_fix_1.4
branch
from
January 7, 2022 13:57
90f2feb
to
df62dd6
Compare
alex-mckenna
approved these changes
Jan 7, 2022
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.
LGTM
DigitalBrains1
added a commit
that referenced
this pull request
Jan 7, 2022
2 tasks
2 tasks
DigitalBrains1
added a commit
that referenced
this pull request
Jan 26, 2022
The Haskell models of `blockRam#` and `blockRamFile#` treated an _undefined_ write enable as an asserted enable. But an _undefined_ value in Haskell can correspond to any value whatsoever in HDL, so HDL simulation might or might not write. With this commit, the `XException` of the write enable is written as the value in the RAM, since it could have either been written to or not been written to. On the next read of that address, it will return the `XException`. This issue did not propagate to any other `blockRam` variants, the bug solely manifested when using the `blockRam#` and `blockRamFile#` primitives directly. All the other variants built upon those primitives always have their write address undefined whenever the write enable is undefined, and that case was properly handled by the primitive. The issue is identical to one of the issues in PR #2006 and PR #2031, for different memory primitives.
DigitalBrains1
added a commit
that referenced
this pull request
Jan 27, 2022
The Haskell models of `blockRam#` and `blockRamFile#` treated an _undefined_ write enable as an asserted enable. But an _undefined_ value in Haskell can correspond to any value whatsoever in HDL, so HDL simulation might or might not write. With this commit, the `XException` of the write enable is written as the value in the RAM, since it could have either been written to or not been written to. On the next read of that address, it will return the `XException`. This issue did not propagate to any other `blockRam` variants, the bug solely manifested when using the `blockRam#` and `blockRamFile#` primitives directly. All the other variants built upon those primitives always have their write address undefined whenever the write enable is undefined, and that case was properly handled by the primitive. The issue is identical to one of the issues in PR #2006 and PR #2031, for different memory primitives.
mergify bot
pushed a commit
that referenced
this pull request
Jan 27, 2022
The Haskell models of `blockRam#` and `blockRamFile#` treated an _undefined_ write enable as an asserted enable. But an _undefined_ value in Haskell can correspond to any value whatsoever in HDL, so HDL simulation might or might not write. With this commit, the `XException` of the write enable is written as the value in the RAM, since it could have either been written to or not been written to. On the next read of that address, it will return the `XException`. This issue did not propagate to any other `blockRam` variants, the bug solely manifested when using the `blockRam#` and `blockRamFile#` primitives directly. All the other variants built upon those primitives always have their write address undefined whenever the write enable is undefined, and that case was properly handled by the primitive. The issue is identical to one of the issues in PR #2006 and PR #2031, for different memory primitives. (cherry picked from commit ac97f0d) # Conflicts: # clash-prelude/src/Clash/Explicit/BlockRam.hs # clash-prelude/src/Clash/Explicit/BlockRam/File.hs # clash-prelude/tests/Clash/Tests/BlockRam.hs
DigitalBrains1
added a commit
that referenced
this pull request
Jan 30, 2022
The Haskell models of `blockRam#` and `blockRamFile#` treated an _undefined_ write enable as an asserted enable. But an _undefined_ value in Haskell can correspond to any value whatsoever in HDL, so HDL simulation might or might not write. With this commit, the `XException` of the write enable is written as the value in the RAM, since it could have either been written to or not been written to. On the next read of that address, it will return the `XException`. This issue did not propagate to any other `blockRam` variants, the bug solely manifested when using the `blockRam#` and `blockRamFile#` primitives directly. All the other variants built upon those primitives always have their write address undefined whenever the write enable is undefined, and that case was properly handled by the primitive. The issue is identical to one of the issues in PR #2006 and PR #2031, for different memory primitives. (cherry picked from commit ac97f0d)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a partial backport of #2006.
unsafeSynchronizer
, was simply wrong. It would compress and duplicatesamples while traversing clock domains, which is not a correct model of
how it works.
The generated HDL was fine, it only affected Haskell simulation.
asyncRAM#
treated an undefined write enableas an asserted enable. But an undefined value in Haskell can
correspond to any value whatsoever in HDL, so HDL simulation might or
might not write. With this commit, the
XException
of the write enableis written as the value in the RAM, since it could have either been
written to or not been written to. On the next read of that address, it
will return the
XException
.This issue did not propagate to
asyncRam
andasyncRamPow2
, sincethere, the same condition also causes the write address to be undefined,
and this is properly handled by the primitive.
The
asyncRAM#
primitive was also too strict in most of its inputs.Combinatorially feeding the read output to the write-side inputs would
lock up the simulation, while it is a valid circuit. This problem did
not propagate to the
asyncRam
andasyncRamPow2
functions, which arelazy enough because the signals go through
Signal
'sfmap
and<*>
.Data written to memory is
seqX
d for efficiency.Additionally, documentation for memory components was harmonized and
corrected.
Still TODO: