sig_id <- genSignalId SigInternal ty
-- Add a name hint to the signal
addNameHint (Name.getOccString id) sig_id
- addDef (UncondDef (Right $ Literal lit) sig_id)
+ addDef (UncondDef (Right $ Literal lit Nothing) sig_id)
return ([], Single sig_id)
IdInfo.VanillaGlobal ->
-- Treat references to globals as an application with zero elements
let len = sized_word_len ty
-- TODO: to_stdlogicvector doesn't work here, since SizedWord
-- translates to a different type...
- addDef (UncondDef (Right $ Literal $ "to_stdlogicvector(to_unsigned(" ++ (show int) ++ ", " ++ (show len) ++ "))") sig_id)
+ addDef $ UncondDef (Right $ Literal ("to_stdlogicvector(to_unsigned(" ++ (show int) ++ ", " ++ (show len) ++ "))") Nothing) sig_id
return ([], Single sig_id)
else
flattenApplicationExpr binds (CoreUtils.exprType app) f args
-- | An expression on signals
data SignalExpr =
EqLit SignalId String -- ^ Is the given signal equal to the given (VHDL) literal
- | Literal String -- ^ A literal value
+ | Literal String (Maybe Type.Type)-- ^ A literal value, with an optional type to cast to
| Eq SignalId SignalId -- ^ A comparison between to signals
deriving (Show, Eq)
+-- Instantiate Eq for Type, so we can derive Eq for SignalExpr.
+instance Eq Type.Type where
+ (==) = Type.coreEqType
+
-- | Which signals are used by the given SignalExpr?
sigExprUses :: SignalExpr -> [SignalId]
sigExprUses (EqLit id _) = [id]
-sigExprUses (Literal _) = []
+sigExprUses (Literal _ _) = []
sigExprUses (Eq a b) = [a, b]
-- Returns the function used by the given SigDef, if any
instance Pretty SignalExpr where
pPrint (EqLit id lit) =
parens $ pPrint id <> text " = " <> text lit
- pPrint (Literal lit) =
- text lit
+ pPrint (Literal lit ty) =
+ text "(" <> text (show ty) <> text ") " <> text lit
pPrint (Eq a b) =
parens $ pPrint a <> text " = " <> pPrint b
case expr of
(EqLit id lit) ->
(mkIdExpr sigs id) AST.:=: (AST.PrimLit lit)
- (Literal lit) ->
+ (Literal lit _) ->
AST.PrimLit lit
(Eq a b) ->
(mkIdExpr sigs a) AST.:=: (mkIdExpr sigs b)