Circuit simulation with CSignal

I have hard time understanding what should be the declaration of circuit.

I have component:

myComponent :: (KnownNat ws, HiddenClockResetEnable dom) => Signal dom Bit -> Signal dom (Maybe (BitVector ws))
myCompoennt = _

If I use

myComponentC :: (KnownNat ws, KnownDomain dom) => Circuit (CSignal dom Bit) (Df dom (BitVector ws))
myComponentC = fromSignals (\_ -> _ $ myComponent @ws @dom _) |> _

compiler complains about lack of clock/reset/enable signals. But if I add it to the signature I get complaints from simulation functions that they cannot prove HiddenClockResetEnable. Strangely they do have reset config. Additionally Df does have this signals but functions only work on Df.

Hey!

It’s very important to realize there’s two ways of supplying clock, reset and enable signals to your circuit:

  • The implicit way, through the HiddenClockResetEnable constraint. This is what you have in your first example.
  • The explicit way, where you supply Clock dom, Reset dom and Enable dom as separate arguments.

Observe these two different register functions that live in different modules:
Clash.Prelude.register vs Clash.Explicit.Prelude.register

In your second example, you only have the KnownDomain constraint on dom, but you should change it to HiddenClockResetEnable dom , which, besides constraining that it’s a KnownDomain, also now implicitly adds the control signals.

I hope that helps you! If not, could you provide how you are trying to use the simulation functions?