-
Notifications
You must be signed in to change notification settings - Fork 159
Clash gets stuck on this design #2882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A bit smaller reproducer: {-# LANGUAGE UndecidableInstances #-}
module Top where
import Clash.Prelude
class KnownNat (UsbSize a) => UsbSerialize a where
type UsbSize a :: Nat
usbDeserialize :: BitVector (UsbSize a) -> a
newtype Packed a = Packed { unPacked :: a }
instance BitPack a => UsbSerialize (Packed a) where
type UsbSize (Packed a) = BitSize a
usbDeserialize = Packed . unpack
instance UsbSerialize Bit where
type UsbSize Bit = UsbSize (Packed Bit)
usbDeserialize = unPacked . usbDeserialize
topEntity :: HiddenClockResetEnable System => Signal System Bit
topEntity = mealy step 0 $ pure ()
where
step x _ = (x, usbDeserialize (x .<<+ 0))
-- {-# INLINE step #-} Note that the commented |
Change newtype Packed a = Packed { unPacked :: a } to data Packed a = Packed { unPacked :: a } This is a known bug in the Clash compiler: type families over newtypes break Clash. There's an attempt at a fix here #1064 but it needs to be rewritten and gotten into a working state. |
For posterity: the motivation for this approach is to be able to use data PID = In | Out | Setup
deriving (Generic, BitPack)
deriving UsbSerialize via (Packed PID) Since |
The below self-contained example makes clash not terminate:
Unfold for original example
The text was updated successfully, but these errors were encountered: