-
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
clashCompilerError leads to synthesis failure, even though it should be on a branch not taken #2870
Comments
If I replace
Compare with what we get when using
|
Hah, much simpler reproducer:
This fails, but with |
Forget all the typeclass and type-directed constants noise:
|
@christiaanb suggested trying out the |
@christiaanb from the Clash slack:
So it would be nice to have some alternative that scales. For example, I'd be happy to mark either the definition of (Chalk this up to another example why explicit staging a la https://andraskovacs.github.io/pdfs/2ltt_icfp24.pdf would be The Way to do Clash, just like #1536 :( ) |
More generally, if I wanted this to happen during synthesis, I'd use Template Haskell. But another option I sometimes use is s =
smap (\_ c -> ascii c) $
'F' :>
'O' :>
Nil I think this would have been a nice topic on https://clash-lang.discourse.group/ :-). I don't consider the current behaviour a bug; it's a missed optimisation opportunity, where it could do constant propagation at compile-time more. I respect it if you say "Clash should be able to do this and it's still a bug", though. |
Well I do think it should be able to do that (the distinction between |
It just renders the
Yeah I consider them fully equivalent. It's just that one by chance happens to do more at Haskell compile time and the other happens to do more at HDL compile time. [edit] |
Interesting! Indeed using |
I'd use Template Haskell. Talking about "proper staging" though X-( |
I'm actually kinda grateful that |
Yes, that's also a feature of I do wonder whether it actually hurts that the HDL is expressed in terms of 23-bit constants. Synthesis tools do a fair bit of constant propagation (although sometimes I'm surprised when someone reports "this could have been less LUTs" and they didn't). |
BTW it might be hard to see in these mangled versions, but I am applying |
I'm afraid they turn into regular [edit] You could do |
But that's pretty much what I'm doing -- I have The problems come when I start to explore ways of generalizing most of my stream formatter for arbitrary input-output types. I would like |
What does |
Well what do you know, I now tried it via
and indeed by the end of synthesis, I get the same parts count as before! So maybe for my particular problem, I should just drop |
I do feel that would be possible, to add a primitive in
That sounds like it would indeed need such a magic function as Rowan suggests. Otherwise I'd expect it to just end up as [edit] |
Yeah I expect a primitive that just does |
Doesn't work out of the box...
|
Perhaps we should add an equivalent of [edit]
Or something of that order. Again, I'm not familiar enough with the inner workings. But we could add a variant of |
Try: topEntity :: "X" ::: Index 2 -> "Y" ::: Word8
topEntity = \i -> s !! i
where
-- s =
-- smap (\_ c -> ascii c) $
-- 'F' :>
-- 'O' :>
-- Nil
-- -- This alternate definition of `s` works
-- s = ascii 'F' :>
-- ascii 'O' :>
-- Nil
s = makeConst $ fmap ascii $
'F' :>
'O' :>
Nil |
D'oh! Of course! Yeah, that actually works! |
As usual, I have a reproducer that is reduced beyond usefulness but still not minimal. In the following code, the
ascii
function usesclashCompilerError
when given a non-ASCIIChar
. I use it in the definition ofsymbolValASCII
:but that leads to an error at synthesis time:
An alternate definition that uses an alternate typeclass method that puts ASCII characters into
symbolVecASCII'
does work, so the problem is ensuringascii
is pushed down deep enough at synthesis time.The text was updated successfully, but these errors were encountered: