varToVHDLExpr :: Var.Var -> TypeSession AST.Expr
varToVHDLExpr var =
case Id.isDataConWorkId_maybe var of
- Just dc -> dataconToVHDLExpr dc
-- This is a dataconstructor.
- -- Not a datacon, just another signal. Perhaps we should check for
- -- local/global here as well?
- -- 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 -> do
- let ty = Var.varType var
- case Type.splitTyConApp_maybe ty of
- Just (tycon, args) ->
- case Name.getOccString (TyCon.tyConName tycon) of
- "Dec" -> do
- len <- tfp_to_int ty
- return $ AST.PrimLit (show len)
- otherwise -> return $ AST.PrimName $ AST.NSimple $ varToVHDLId var
+ Just dc -> dataconToVHDLExpr dc
+ -- Not a datacon, just another signal.
+ Nothing -> return $ AST.PrimName $ AST.NSimple $ varToVHDLId var
-- Turn a VHDLName into an AST expression
vhdlNameToVHDLExpr = AST.PrimName
builtin_types =
Map.fromList [
(BuiltinType "Bit", Just (std_logicTM, Nothing)),
- (BuiltinType "Bool", Just (booleanTM, Nothing)), -- TysWiredIn.boolTy
- (BuiltinType "Dec", Just (integerTM, Nothing))
+ (BuiltinType "Bool", Just (booleanTM, Nothing)) -- TysWiredIn.boolTy
]
-- Is the given type representable at runtime?
(Just x) -> return $ Right $ BuiltinType name
Nothing ->
case name of
- "TFVec" -> do
+ "Vector" -> do
let el_ty = tfvec_elem ty
elem_htype_either <- mkHTypeEither el_ty
case elem_htype_either of
-- Could not create element type
Left err -> return $ Left $
"\nVHDLTools.mkHTypeEither': Can not construct vectortype for elementtype: " ++ pprString el_ty ++ err
- "SizedWord" -> do
+ "Unsigned" -> do
len <- tfp_to_int (sized_word_len_ty ty)
return $ Right $ SizedWType len
- "SizedInt" -> do
+ "Signed" -> do
len <- tfp_to_int (sized_word_len_ty ty)
return $ Right $ SizedIType len
- "RangedWord" -> do
+ "Index" -> do
bound <- tfp_to_int (ranged_word_bound_ty ty)
return $ Right $ RangedWType bound
otherwise ->