X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=VHDLTools.hs;h=96a8ae50b28afd8e69434f8d6cc2cfe0a72317f2;hb=c154f599b83d1a91e99993666139e01f10033d5c;hp=12681160b25b7556acd9cc5998590816fe4aeaa7;hpb=fc9e13429a9f75f03ef75b91ca540c08b40083a2;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/VHDLTools.hs b/VHDLTools.hs index 1268116..96a8ae5 100644 --- a/VHDLTools.hs +++ b/VHDLTools.hs @@ -8,6 +8,7 @@ import qualified Control.Monad as Monad import qualified Control.Arrow as Arrow import qualified Data.Monoid as Monoid import Data.Accessor +import Debug.Trace -- ForSyDe import qualified ForSyDe.Backend.VHDL.AST as AST @@ -126,7 +127,20 @@ varToVHDLExpr var = -- This is a dataconstructor. -- Not a datacon, just another signal. Perhaps we should check for -- local/global here as well? - Nothing -> AST.PrimName $ AST.NSimple $ varToVHDLId var + -- Sadly so.. tfp decimals are types, not data constructors, but instances + -- should still be translated to integer literals. It is probebly not the + -- best solution to translate them here. + -- FIXME: Find a better solution for translating instances of tfp integers + Nothing -> + let + ty = Var.varType var + res = case Type.splitTyConApp_maybe ty of + Just (tycon, args) -> + case Name.getOccString (TyCon.tyConName tycon) of + "Dec" -> AST.PrimLit $ (show (eval_tfp_int ty)) + otherwise -> AST.PrimName $ AST.NSimple $ varToVHDLId var + in + res -- Turn a VHDLName into an AST expression vhdlNameToVHDLExpr = AST.PrimName @@ -243,7 +257,8 @@ mkIndexedName name index = AST.NIndexed (AST.IndexedName name [index]) builtin_types = Map.fromList [ ("Bit", std_logicTM), - ("Bool", booleanTM) -- TysWiredIn.boolTy + ("Bool", booleanTM), -- TysWiredIn.boolTy + ("Dec", integerTM) ] -- Translate a Haskell type to a VHDL type, generating a new type if needed.