+type ShifterState = (Bit, Bit, Bit, Bit)
+shifter :: Bit -> ShifterState -> (ShifterState, Bit)
+shifter i (a, b, c, d) =
+ (s', d)
+ where
+ s' = (i, a, b, c)
+
+{-# NOINLINE shifter_en #-}
+shifter_en :: Bit -> Bit-> ShifterState -> (ShifterState, Bit)
+shifter_en High i (a, b, c, d) =
+ (s', d)
+ where
+ s' = (i, a, b, c)
+
+shifter_en Low i s@(a, b, c, d) =
+ (s, d)
+
+-- Two multiplexed shifters
+type ShiftersState = (ShifterState, ShifterState)
+shifters :: Bit -> Bit -> ShiftersState -> (ShiftersState, Bit)
+shifters sel i (sa, sb) =
+ (s', out)
+ where
+ (sa', outa) = shifter_en sel i sa
+ (sb', outb) = shifter_en (hwnot sel) i sb
+ s' = (sa', sb')
+ out = if sel == High then outa else outb
+