filterState ::
SignalId -- | The signal id to look at
-> HsValueUse -- | How is this signal used?
- -> Maybe (Int, SignalId ) -- | The state num and signal id, if this
+ -> Maybe (StateId, SignalId ) -- | The state num and signal id, if this
-- signal was used as state
filterState id (State num) =
stateList ::
HsUseMap
-> (SignalMap)
- -> [(Int, SignalId)]
+ -> [(StateId, SignalId)]
stateList uses signals =
Maybe.catMaybes $ Foldable.toList $ zipValueMapsWith filterState signals uses
getOwnStates ::
HsFunction -- | The function to look at
-> FlatFunction -- | The function to look at
- -> [(Int, SignalInfo, SignalInfo)]
+ -> [(StateId, SignalInfo, SignalInfo)]
-- | The state signals. The first is the state number, the second the
-- signal to assign the current state to, the last is the signal
-- that holds the new state.
-- | A map of a Haskell value to signal ids
type SignalMap = HsValueMap SignalId
+-- | A state identifier
+type StateId = Int
+
-- | How is a given (single) value in a function's type (ie, argument or
-- return value) used?
data HsValueUse =
Port -- ^ Use it as a port (input or output)
- | State Int -- ^ Use it as state (input or output). The int is used to
+ | State StateId -- ^ Use it as state (input or output). The int is used to
-- match input state to output state.
| HighOrder { -- ^ Use it as a high order function input
hoName :: String, -- ^ Which function is passed in?
SigPortIn -- | Use as an input port
| SigPortOut -- | Use as an input port
| SigInternal -- | Use as an internal signal
- | SigStateOld Int -- | Use as the current internal state
- | SigStateNew Int -- | Use as the new internal state
+ | SigStateOld StateId -- | Use as the current internal state
+ | SigStateNew StateId -- | Use as the new internal state
| SigSubState -- | Do not use, state variable is used in a subcircuit
-- | Is this a port signal use?
let arch = AST.ArchBody (mkVHDLId "structural") (AST.NSimple entity_id) (map AST.BDISD sig_decs) (insts' ++ procs')
setArchitecture hsfunc arch
-mkStateProcSm :: (Int, SignalInfo, SignalInfo) -> AST.ProcSm
+mkStateProcSm :: (StateId, SignalInfo, SignalInfo) -> AST.ProcSm
mkStateProcSm (num, old, new) =
AST.ProcSm label [clk] [statement]
where