-
Notifications
You must be signed in to change notification settings - Fork 162
Closed
Description
There seems to be some confusion about the direction of the TestBench annotation.
Is it:
- an annotation on a
Synthesize
d binder pointing to its testbench - an annotation on a testbench pointing to the thing that it is testing
The current docs state:
Tell what binder is the TestBench for a Synthesize-annotated binder.
Not very clear.
But luckily there is also an example:
..., f has a Synthesize annotation, and g is the HDL test bench for f.
f = ... {-# ANN f (defSyn "f") #-} {-# ANN f (TestBench 'g) #-} g :: Signal Bool g = ...
This is option 1.
This work, and clash will create HDL output for both f
and g
, but it will produce a warning:
Clash: Compiling TestNames.g
Clash: Normalization took 0.001s
[WARNING] Dubious primitive instantiation for Clash.Explicit.Testbench.tbClockGen: Clash.Signal.Internal.tbClockGen is not synthesizable! (disable with -fclash-no-prim-warn)
Clash: Netlist generation took 0.000s
Clash: Compiling TestNames.f
Clash: Normalization took 0.001s
Clash: Netlist generation took 0.000s
If we try option 2:
f = ...
{-# ANN f (defSyn "f") #-}
g :: Signal Bool
g = ...
{-# ANN g (TestBench 'f) #-}
This also work, clash will also generate HDL files for both f
and g
, but this time the netlist code actually considers g to be a testbench and suppresses the tbClockGen
warning:
Clash: Compiling TestNames.g
Clash: Normalization took 0.001s
Clash: Netlist generation took 0.000s
Clash: Compiling TestNames.f
Clash: Normalization took 0.001s
Clash: Netlist generation took 0.000s
Clash: Total compilation took 0.957s