clash-lang / clash-compiler

Haskell to VHDL/Verilog/SystemVerilog compiler
https://clash-lang.org/
Other
1.4k stars 147 forks source link

Only domains with a positive period are valid, alternative #2741

Open christiaanb opened 1 week ago

christiaanb commented 1 week ago

An alternative means to achieve https://github.com/clash-lang/clash-compiler/pull/2734#issuecomment-2182893091

import Clash.Prelude
import Data.Proxy

f ::
  forall dom .
  KnownDomain dom =>
  Proxy dom ->
  SNat (PeriodToCycles dom (Milliseconds 1))
f Proxy = SNat

now typechecks.

Though at the very high cost of needing to add @dom to any use of hideClockResetEnable which might affect user code out in the wild. https://github.com/clash-lang/clash-compiler/pull/2740 is probably a more desirable alternative.

Still TODO:

DigitalBrains1 commented 1 week ago

I agree the other alternative is more desirable, all the more since the error message you get when you forget to explicitly type-apply it is not all that clear.