Give HighOrdAlu an and operation.
[matthijs/master-project/cλash.git] / HighOrdAlu.hs
1 module HighOrdAlu where
2
3 import Prelude hiding (
4   null, length, head, tail, last, init, take, drop, (++), map, foldl, foldr,
5   zipWith, zip, unzip, concat, reverse, iterate )
6 import Bits
7 import Types
8 import Data.Param.TFVec
9 import Data.RangedWord
10
11 constant :: e -> Op D4 e
12 constant e a b =
13   e +> (e +> (e +> (singleton e )))
14
15 inv = hwnot
16
17 invop :: Op n Bit
18 invop a b = map inv a
19
20 xand = hwand
21
22 andop :: Op n Bit
23 andop a b = zipWith xand a b
24
25 type Op n e = (TFVec n e -> TFVec n e -> TFVec n e)
26 type Opcode = Bit
27
28 alu :: Op n e -> Op n e -> Opcode -> TFVec n e -> TFVec n e -> TFVec n e
29 alu op1 op2 opc a b =
30   case opc of
31     Low -> op1 a b
32     High -> op2 a b
33
34 actual_alu :: Opcode -> TFVec D4 Bit -> TFVec D4 Bit -> TFVec D4 Bit
35 actual_alu = alu (constant Low) andop