-
Notifications
You must be signed in to change notification settings - Fork 151
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
New function: memFile #1840
New function: memFile #1840
Conversation
Just (Bit 0 0) -> go n (val .&. (mask `xor` fullMask)) ('\n' : s) | ||
Just (Bit 0 1) -> go n (val .|. mask) ('\n' : s) |
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's unlikely that low
and high
will change, but maybe it's better to do
case care of
Just b
| b == low -> ...
| b == high -> ...
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.
That'll error on don't care bits!
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 don't care about those 😉
But more seriously, I thought they had a non-zero mask anyway? Or is that only undefined bits?
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.
s/bits/bit/ :-)
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 never saw your comment before, odd. I was s/-ing my own "don't care bits" comment. The problem is that Eq Bit
correctly stumbles over undefined bits. After all, you want lsb $(bLit ".") == 0
to throw an error instead of taking a wild stab at a boolean result.
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.
Ah yes, I see now. I guess you would need to use something like Clash.Class.BitPack.isLike
to compare in a way that's friendly to don't care values
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.
The semantics of that here would mean that you want don't care bits to be mapped to don't care bits. And that is precisely the semantics of the current code. Just $ lsb $(bLit ".")
is handled the same as Nothing
by the _
pattern match.
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.
User code should probably not peek under the hood of Bit
, but we can do that, it's the same body of code as where it is defined.
Also, you've ticked the changelog box but haven't pushed a changelog. Have you forgotten a |
Again? Man.... |
6dbaa02
to
d05a426
Compare
A helper function for producing files with memory contents for such modules as Clash.Explicit.BlockRam.File, etcetera.
A helper function for producing files with memory contents for such
modules as Clash.Explicit.BlockRam.File, etcetera.
I know you agreed to my initial proposal of
but I changed my mind. The point of
ShowS
is that you can combine it with other datatypes that have aShow
instance. But the memory file only contains words of a single lengthn
. If people really want to put multiple datatypes into one memory, they can justpack
it intoBitVector n
. So the function doesn't need to be combined in ways asShowS
, and you would in practice always invoke it asfoldr showsBitPackFile ""
, so why not incorporate that directly so people don't have to write it.Still TODO: