From: Matthijs Kooijman Date: Tue, 17 Feb 2009 16:50:05 +0000 (+0100) Subject: Add a type alias StateId for state numbers. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fc%CE%BBash.git;a=commitdiff_plain;h=ed9f3e71c71db41d85a9dabb3a676f4c342b8266 Add a type alias StateId for state numbers. --- diff --git a/Flatten.hs b/Flatten.hs index 4194904..1076d95 100644 --- a/Flatten.hs +++ b/Flatten.hs @@ -210,7 +210,7 @@ appToHsFunction ty f args = 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) = @@ -222,7 +222,7 @@ filterState _ _ = Nothing stateList :: HsUseMap -> (SignalMap) - -> [(Int, SignalId)] + -> [(StateId, SignalId)] stateList uses signals = Maybe.catMaybes $ Foldable.toList $ zipValueMapsWith filterState signals uses @@ -231,7 +231,7 @@ stateList uses signals = 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. diff --git a/FlattenTypes.hs b/FlattenTypes.hs index fc77816..409c2ac 100644 --- a/FlattenTypes.hs +++ b/FlattenTypes.hs @@ -16,11 +16,14 @@ type SignalId = Int -- | 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? @@ -92,8 +95,8 @@ data SigUse = 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? diff --git a/VHDL.hs b/VHDL.hs index 32279fd..67b8394 100644 --- a/VHDL.hs +++ b/VHDL.hs @@ -144,7 +144,7 @@ createArchitecture hsfunc fdata = 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