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

valid field of TemplateFunction isn't checked for includes #1945

Closed
christiaanb opened this issue Oct 7, 2021 · 2 comments · Fixed by #1946
Closed

valid field of TemplateFunction isn't checked for includes #1945

christiaanb opened this issue Oct 7, 2021 · 2 comments · Fixed by #1946
Labels

Comments

@christiaanb
Copy link
Member

The following:

{-# LANGUAGE OverloadedStrings #-}
module BBCtxIncludeCheck where

import           Clash.Annotations.Primitive  (Primitive(..), HDL(..), hasBlackBox)
import           Clash.Netlist.Types          (TemplateFunction (..))
import           Clash.Prelude

import           Data.String.Interpolate      (i)
import           Data.String.Interpolate.Util (unindent)

bb :: a -> a
bb x = x
{-# NOINLINE bb #-}
{-# ANN bb hasBlackBox #-}
{-# ANN bb (InlinePrimitive [VHDL,Verilog,SystemVerilog] $ unindent [i|
   [ { "BlackBox" :
        { "name" : "BBCtxIncludeCheck.bb",
          "kind" : "Expression",
          "template": "~ARG[0]",
          "includes" :
            [ { "extension" : "bin"
              , "name" : "mem"
              , "format" : "Haskell"
              , "templateFunction" : "BBCtxIncludeCheck.tf"}

            ]
        }
     }
   ]
   |]) #-}

tf :: TemplateFunction
tf = TemplateFunction used valid (const (pure "QQ"))
 where
  used = [0]
  valid = const False

topEntity :: Bool -> Bool
topEntity = bb

passes, but shouldn't. The context check of the TemplateFunction never succeeds, but it seems this context check is never performed.

@martijnbastiaan
Copy link
Member

Not really relevant to this issue, but it should really return a Maybe Text so the blackbox can explain why it failed.

@alex-mckenna
Copy link
Contributor

I look forward to reading bbFailure = Just "because" in bug reports

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

Successfully merging a pull request may close this issue.

3 participants