1 {-# LANGUAGE TemplateHaskell #-}
3 module HighOrdAlu where
5 import Prelude hiding (
6 null, length, head, tail, last, init, take, drop, (++), map, foldl, foldr,
7 zipWith, zip, unzip, concat, reverse, iterate )
10 import Data.Param.TFVec
11 import Data.RangedWord
12 import CLasH.Translator.Annotations
14 constant :: e -> Op D4 e
16 (e +> (e +> (e +> (singleton e))))
19 invop a b = map hwnot a
22 andop a b = zipWith hwand a b
25 --anyset :: (PositiveT n) => Op n Bit
26 anyset :: (Bit -> Bit -> Bit) -> Op D4 Bit
27 --anyset a b = copy undefined (a' `hwor` b')
28 anyset f a b = constant (a' `hwor` b') a b
35 type Op n e = (TFVec n e -> TFVec n e -> TFVec n e)
38 {-# ANN sim_input TestInput#-}
39 sim_input = [ (High,$(vectorTH [High,Low,Low,Low]),$(vectorTH [High,Low,Low,Low]))
40 , (High,$(vectorTH [High,High,High,High]),$(vectorTH [High,High,High,High]))
41 , (Low,$(vectorTH [High,Low,Low,High]),$(vectorTH [High,Low,High,Low]))]
43 {-# ANN actual_alu InitState #-}
46 alu :: Op n e -> Op n e -> Opcode -> TFVec n e -> TFVec n e -> TFVec n e
52 {-# ANN actual_alu TopEntity #-}
53 actual_alu :: (Opcode, TFVec D4 Bit, TFVec D4 Bit) -> TFVec D4 Bit
54 --actual_alu = alu (constant Low) andop
55 actual_alu (opc, a, b) = alu (anyset xhwor) (andop) opc a b