Skip to content
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

~VAR[][n] (without a name) generates invalid HDL #2237

Closed
leonschoorl opened this issue Jun 8, 2022 · 2 comments
Closed

~VAR[][n] (without a name) generates invalid HDL #2237

leonschoorl opened this issue Jun 8, 2022 · 2 comments
Assignees
Labels

Comments

@leonschoorl
Copy link
Member

Using a ~VAR[][n] without providing an explicit name breaks code generation.

{-# LANGUAGE QuasiQuotes #-}
module TestPrim where

import           Clash.Annotations.Primitive
import           Clash.Prelude
import           Data.String.Interpolate      (i)
import           Data.String.Interpolate.Util (unindent)

{-# ANN double (InlineYamlPrimitive [VHDL] $ unindent [i|
 BlackBox:
   kind: Expression
   name: TestPrim.double
   template: |-
     (~VAR[foo][0] + ~VAR[][0])
|]) #-}
{-# NOINLINE double #-}
double :: Int -> Int
double = (*2)

topEntity x = double (x+1)

generates

  ccase_alt <= (\c$foo\ + ;

Notice the missing ).
It doesn't just use an empty string for a name, but completely stops generating code for the blackbox at that point.
Also when you do fill in a name other then foo clash will just ignore it and use the first name you gave to that argument position.

I'd like clash to come up with a name when I can't be bothered.
Or it could report an error,

@leonschoorl leonschoorl added the bug label Jun 8, 2022
@leonschoorl leonschoorl self-assigned this Jun 8, 2022
leonschoorl added a commit that referenced this issue Jun 8, 2022
@leonschoorl
Copy link
Member Author

This is caused by the blackbox parser failing to parse ~VAR[].
And a bug where a parse failure caused the parser to return succes for everything it had parsed so far, and just dropping any unparsed input leftover.

leonschoorl added a commit that referenced this issue Jun 13, 2022
This turns #2237 into an error.
And fix blackboxes for clogBase and altddioIn, which were silently broken :'(
leonschoorl added a commit that referenced this issue Jun 13, 2022
leonschoorl added a commit that referenced this issue Jun 15, 2022
This turns #2237 into an error.
And fix blackboxes for clogBase and altddioIn, which were silently broken :'(
mergify bot pushed a commit that referenced this issue Jun 17, 2022
This turns #2237 into an error.
And fix blackboxes for clogBase and altddioIn, which were silently broken :'(

(cherry picked from commit fc3c51d)
mergify bot pushed a commit that referenced this issue Jun 17, 2022
@martijnbastiaan
Copy link
Member

We've released v1.6.4, which includes a fix for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants