bittide / bittide-hardware

15 stars 1 forks source link

Add `Clash.Sized.Byte` #541

Open martijnbastiaan opened 3 weeks ago

martijnbastiaan commented 3 weeks 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 3 weeks 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 3 weeks ago

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