From 0c9640079a295e972d4c0a8857faeefcad2fc15d Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 22 Jun 2009 12:57:20 +0200 Subject: [PATCH] Make the hw functions builtin operators instead of components. --- Generate.hs | 13 ++++++++++++- GlobalNameTable.hs | 8 ++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) 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 ) ) + ] -- 2.30.2