-
Notifications
You must be signed in to change notification settings - Fork 154
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
Clash 1.4.3 generates Verilator-unfriendly code #1934
Comments
I managed to bisect it to the following commit:
|
To reproduce it easily, check out the
and
|
Not quite minimal yet, but I managed to shrink my input to a mere 98 lines:
|
With no external dependencies:
|
Without all that
|
Generated Verilog: from "good" (1.4.2-equivalent):
From "bad" (1.4.3-equivalent):
|
The difference is that "good" has:
whereas "bad" has:
Unfortunately, this is where my expertise runs out... |
I've moved all code related to this to https://github.com/gergoerdi/clash-issue-1934 please use that repo (or, really, just copy the code from #1934 (comment), it is fully standalone now) |
I guess this is an unintended consequence of 10aca06 I'll have to look at the debug logs to see what changes wrt the core expressions between 1.4.2 and 1.4.3 exactly. |
I couldn't reproduce this with v1.4.3 and the code from #1934 (comment) assign VGA = f2[7:0]; Tried it with clash-1.4.3 from snapcraft and local builds of the I also tried you cloning your repo and doing Could you confirm that issue still happens with the current example, and you haven't accidentally minimized it too much or something like that. |
Here is what I see with https://github.com/gergoerdi/clash-issue-1934/tree/f47158f752cd13dfb5f15b57e8515f9ad42aadcd:
|
I get:
Maybe my (old) verilator behaves differently then yours.
|
I have Verilator 4.038 2020-07-11 rev v4.036-114-g0cd4a57ad installed. |
I have now pushed a version that you can just |
Please let me know if you can reproduce this now with https://github.com/gergoerdi/clash-issue-1934/tree/aeaf219c620edafb9bd7271e8fdd67328d2d89b3 and if you need anything more from me to look into this. |
Thanks I've since updated to Although mostly a distraction for this bug, it is interesting that building through clashilator seems to result in different HDL then building with a standalone clash binary. The offending verilog template is just in there: clash-compiler/clash-lib/src/Clash/Primitives/Sized/Vector.hs Lines 275 to 277 in b4ddd62
And can be triggered more reliably with something like: f :: Unsigned 8 -> Unsigned 8
f x = (3 :> x :> Nil) !! 1
{-# NOINLINE f #-}
topEntity = f I'll try to find a better way to write that template tomorrow. |
As a work-around you can use |
So the fix is to extend clash-compiler/clash-lib/src/Clash/Netlist/BlackBox/Util.hs Lines 603 to 607 in 0415bcf
To also match on BlackBoxE "GHC.Types.I#" ... and BlackBoxE "GHC.Types.W#" ... in the same way that we match on the DataCon , i.e. they should have a bbInputs = [(Literal (Just ((Signed/Unsigned _,_)) i,_,True)] field.
|
It now works for: KnownNat, SNat, Integer, Natural, Int, Word and their 8,16,32,64 bits variants Unsigned,Signed,Index Int#, Word# And better document what ~LIT and ~CONST are supposed to do. Fixes #1934
It now works for: KnownNat, SNat, Integer, Natural, Int, Word and their 8,16,32,64 bits variants Unsigned,Signed,Index Int#, Word# And better document what ~LIT and ~CONST are supposed to do. Fixes #1934
The clashilated version of https://github.com/gergoerdi/clash-compucolor2 compiles just fine with Clash 1.4.2, but on 1.4.3 I get the following error from Verilator:
I also get a whole load of new warnings:
The text was updated successfully, but these errors were encountered: