import qualified Control.Monad.State as State
import CoreSyn
+import qualified Type
import HsValueMap
-- | Information on a signal definition
data SignalInfo = SignalInfo {
- name :: Maybe String
-} deriving (Eq, Show)
+ name :: Maybe String,
+ ty :: Type.Type
+}
-- | A flattened function
data FlatFunction' sigid = FlatFunction {
apps :: [FApp sigid],
conds :: [CondDef sigid],
sigs :: [(sigid, SignalInfo)]
-} deriving (Show, Eq)
+}
-- | A flat function that does not have its signals named
type FlatFunction = FlatFunction' UnnamedSignal
State.put (apps, c:conds, sigs, n)
-- | Generates a new signal id, which is unique within the current flattening.
-genSignalId :: FlattenState UnnamedSignal
-genSignalId = do
+genSignalId :: Type.Type -> FlattenState UnnamedSignal
+genSignalId ty = do
(apps, conds, sigs, n) <- State.get
-- Generate a new numbered but unnamed signal
- let s = (n, SignalInfo Nothing)
+ let s = (n, SignalInfo Nothing ty)
State.put (apps, conds, s:sigs, n+1)
return n
pPrint _ = text "TODO"
instance Pretty SignalInfo where
- pPrint (SignalInfo Nothing) = empty
- pPrint (SignalInfo (Just name)) = text ":" <> text name
+ pPrint (SignalInfo Nothing ty) = empty
+ pPrint (SignalInfo (Just name) ty) = text ":" <> text name
instance Pretty VHDLSession where
pPrint (VHDLSession mod nameCount funcs) =
-- Name the signals in all other functions
Just flatfunc ->
let s = sigs flatfunc in
- let s' = map (\(id, (SignalInfo Nothing)) -> (id, SignalInfo (Just $ "sig_" ++ (show id)))) s in
+ let s' = map (\(id, (SignalInfo Nothing ty)) -> (id, SignalInfo (Just $ "sig_" ++ (show id)) ty)) s in
let flatfunc' = flatfunc { sigs = s' } in
fdata { flatFunc = Just flatfunc' }