bittide / bittide-hardware

17 stars 1 forks source link

Add `Clash.Sized.Byte` #541

Open martijnbastiaan opened 5 months ago

martijnbastiaan commented 5 months ago

Clash offers BitVector, but in memory mapped systems we often use bytes. To this end we've introduced type synonyms:

https://github.com/bittide/bittide-hardware/blob/703b881e8e468e7916dc01b2f8c49ba559ac4649/bittide/src/Bittide/SharedTypes.hs#L46-L49

It would be nice if we would get a whole bunch of convenience functions that work on bytes, e.g. shiftL.

DigitalBrains1 commented 5 months ago

We should make a class ClashBits (?) where bit indices and counts are expressed as Index n (for n-wide words) instead of the default Bits class with its Ints. Those are pretty annoying; right now Jasper is using fromEnum to go from Index n to Int without getting the dreaded warning about fromInteger during HDL generation.

martijnbastiaan commented 4 months ago

Yeah or just Bits, and make a Clash.Compat.Prelude18 for backwards compat. (Though it must be noted this is the bittide repo :-))