-
Notifications
You must be signed in to change notification settings - Fork 162
Open
Description
The following program fails to compile to Verilog with clash
master
(although I suspect that this isn't a new issue):
{-# LANGUAGE DataKinds #-}
module Repro where
import Clash.Prelude
import Prelude ()
topEntity
:: Signal System (Vec 4 (Vec 4 (Unsigned 32)))
-> Signal System (Vec 4 (Unsigned 32))
topEntity = f
f
:: Signal System (Vec n (Vec 4 (Unsigned 32)))
-> Signal System (Vec n (Unsigned 32))
f x = fmap (fmap head) x
{-# OPAQUE f #-}
{-# ANN topEntity
(Synthesize
{ t_name = "repro"
, t_inputs = [ PortName "inp" ]
, t_output = PortName "outp"
}) #-}
Concretely, the failure is (although this error includes a fair amount of additional context that I have added in https://github.com/bgamari/clash-compiler/tree/wip/blackbox-parse-failure):
<no location info>: error:
Clash error call:
error while parsing blackbox: Clash.Sized.Vector.head
in component Hi_topEntity_f
error:
:1:38: error: expected: "[\\", "\\]", "]", "~ACTIVEEDGE", "~AND", "~ARG",
"~ARGN", "~CMPLE", "~COMPNAME", "~CONST", "~CTXNAME", "~DEPTH", "~DEVNULL",
"~ENDGENERATE", "~ERROR", "~ERRORO", "~FILE", "~FROMBV", "~GENERATE",
"~GENSYM", "~INCLUDENAME", "~INDEXTYPE", "~ISACTIVEENABLE", "~ISACTIVEHIGH",
"~ISINITDEFINED", "~ISLIT", "~ISSCALAR", "~ISSYNC", "~ISUNDEFINED",
"~ISVAR", "~IW64", "~LENGTH", "~LIT", "~LONGESTPERIOD", "~MAXINDEX",
"~NAME", "~OTHERSYN", "~OUTPUTUSAGE", "~OUTPUTWIREREG", "~PERIOD",
"~REPEAT", "~RESULT", "~SEL", "~SIGD", "~SIGDO", "~SIZE", "~STRCMP", "~SYM",
"~TAG", "~TEMPLATE", "~TOBV", "~TYP", "~TYPEL", "~TYPM", "~TYPMO", "~TYPO",
"~VAR", "~VARS", "~VIVADO"
1 | assign ~RESULT = ~FROMBV[~VAR[vec][0][~SIZE[~TYP[0]]-1 -: ~SIZE[~TYPO]]][~>
| ^
template:
assign ~RESULT = ~FROMBV[~VAR[vec][0][~SIZE[~TYP[0]]-1 -: ~SIZE[~TYPO]]][~TYPO];
CallStack (from HasCallStack):
error, called at src/Clash/Netlist/BlackBox/Util.hs:687:5 in clash-lib-1.9.0-inplace:Clash.Netlist.BlackBox.Util
Specifically, the problem is the template, which differs from that defined in clash-lib/prims/verilog/Clash_Sized_Vector.primitives.yaml
:
+ assign ~RESULT = ~FROMBV[~VAR[vec][0][~SIZE[~TYP[0]]-1 -: ~SIZE[~TYPO]]][~TYPO];
- assign ~RESULT = ~FROMBV[~VAR[vec][0][\\~SIZE[~TYP[0]]-1 -: ~SIZE[~TYPO]\\]][~TYPO];
Metadata
Metadata
Assignees
Labels
No labels