From: Matthijs Kooijman Date: Mon, 22 Jun 2009 10:57:20 +0000 (+0200) Subject: Make the hw functions builtin operators instead of components. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=0c9640079a295e972d4c0a8857faeefcad2fc15d;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Make the hw functions builtin operators instead of components. --- diff --git a/Generate.hs b/Generate.hs index 2beacb8..26c0448 100644 --- a/Generate.hs +++ b/Generate.hs @@ -3,6 +3,17 @@ module Generate where import qualified ForSyDe.Backend.VHDL.AST as AST import Constants +-- | Generate a binary operator application. The first argument should be a +-- constructor from the AST.Expr type, e.g. AST.And. +genExprOp2 :: (AST.Expr -> AST.Expr -> AST.Expr) -> [AST.Expr] -> AST.Expr +genExprOp2 op [arg1, arg2] = op arg1 arg2 +genExprOp2 _ _ = error "Generate.genExprOp2 wrong number of argumetns" + +-- | Generate a unary operator application +genExprOp1 :: (AST.Expr -> AST.Expr) -> [AST.Expr] -> AST.Expr +genExprOp1 op [arg] = op arg +genExprOp1 _ _ = error "Generate.genExprOp1 wrong number of argumetns" + -- | Generate a function call from the Function Name and a list of expressions -- (its arguments) genExprFCall :: AST.VHDLId -> [AST.Expr] -> AST.Expr @@ -154,4 +165,4 @@ genUnconsVectorFuns elemTM vectorTM = (AST.PrimName (AST.NAttribute $ AST.AttribName (AST.NSimple vecPar) lengthId Nothing) AST.:-: AST.PrimLit "1")) - dropRet = AST.ReturnSm (Just $ AST.PrimName $ AST.NSimple resId) \ No newline at end of file + dropRet = AST.ReturnSm (Just $ AST.PrimName $ AST.NSimple resId) diff --git a/GlobalNameTable.hs b/GlobalNameTable.hs index c860dcb..8c3faab 100644 --- a/GlobalNameTable.hs +++ b/GlobalNameTable.hs @@ -17,6 +17,10 @@ mkGlobalNameTable = Map.fromList globalNameTable :: NameTable globalNameTable = mkGlobalNameTable - [ ("!" , (2, genExprFCall2L exId ) ) + [ ("!" , (2, genExprFCall2L exId ) ) , ("head" , (1, genExprFCall1L headId ) ) - ] \ No newline at end of file + , ("hwxor" , (2, genExprOp2 AST.Xor ) ) + , ("hwand" , (2, genExprOp2 AST.And ) ) + , ("hwor" , (2, genExprOp2 AST.And ) ) + , ("hwnot" , (1, genExprOp1 AST.Not ) ) + ]