0 | module BitsUtil
 1 |
 2 | import Data.Bits
 3 | import Data.Vect
 4 |
 5 | export
 6 | bits32FromBigEndian : Vect 4 Bits8 -> Bits32
 7 | bits32FromBigEndian [b3, b2, b1, b0] =
 8 |             (cast b3 `shiftL` 24)
 9 |         .|. (cast b2 `shiftL` 16)
10 |         .|. (cast b1 `shiftL` 8)
11 |         .|. (cast b0)
12 |
13 | export
14 | bits32ToBigEndian : Bits32 -> Vect 4 Bits8
15 | bits32ToBigEndian streamIdent =
16 |   [ cast (streamIdent `shiftR` 24)
17 |   , cast (streamIdent `shiftR` 16)
18 |   , cast (streamIdent `shiftR` 8)
19 |   , cast streamIdent
20 |   ]
21 |