Clash fails to generate a hdl for designs that contain newtype wrappers of e.g. records
Reproducer:
import Clash.Prelude
import Clash.Annotations.TH
data Foo a = Foo a
data Bar = Bar
{ a :: Int
, b :: Int
}
top :: Foo Bar
top = undefined
{-# ANN top (Synthesize
{ t_name = "top"
, t_inputs = []
, t_output = PortProduct "" [PortProduct "" [PortName "a", PortName "b"]]
})
Error:
ghci> main
GHC: Setting up GHC took: 0.093s
GHC: Compiling and loading modules took: 0.465s
Clash: Parsing and compiling primitives took 0.173s
Loading dependencies took 1.101s
Clash: Ignoring previously made caches
Clash: Compiling Main.top
Clash: Normalization took 0.
*** Exception: Saw a PortProduct in a Synthesize annotation:
PortProduct "" [PortProduct "" [PortName "a",PortName "b"]]
but the port type:
Product "Main.Bar" (Just ["a","b"]) [Signed 64,Signed 64]
is not a product!
CallStack (from HasCallStack):
error, called at clash-lib/src/Clash/Netlist/Util.hs:1942:8 in main:Clash.Netlist.Util
expandTopEntityOrErrM, called at clash-lib/src/Clash/Netlist/Util.hs:784:8 in main:Clash.Netlist.Util
mkUniqueNormalized, called at clash-lib/src/Clash/Netlist.hs:273:9 in main:Clash.Netlist
genComponentT, called at clash-lib/src/Clash/Netlist.hs:247:41 in main:Clash.Netlist
genComponent, called at clash-lib/src/Clash/Netlist.hs:125:9 in main:Clash.Netlist
ghci>
Error is generated by Clash.Netlist.Util.goPort, relevant arguments:
FilteredHwType:
Clash fails to generate a hdl for designs that contain newtype wrappers of e.g. records
Reproducer:
Error:
Error is generated by
Clash.Netlist.Util.goPort
, relevant arguments:FilteredHwType
:PortName
:The
FilteredHwType
is not considered a product by theisProduct
function, causing a fall through. AdjustingisProduct
makes hdl generation succeed: