Commit 5351dee8 by Zachary Snow

minor scoping/ordering fixes for pesky VCS restrictions

parent ba7ffdf1
......@@ -12,6 +12,7 @@ module Convert.Enum (convert) where
import Text.Read (readMaybe)
import Data.Maybe (fromMaybe)
import Data.List (sortOn)
import Control.Monad.Writer
import qualified Data.Set as Set
......@@ -31,7 +32,7 @@ convertDescription :: Description -> Description
convertDescription (description @ (Part _ _ _ _ _ _)) =
Part extern kw lifetime name ports (enumItems ++ items)
where
enumPairs = concat $ map (uncurry enumVals) $ Set.toList enums
enumPairs = sortOn snd $ concatMap (uncurry enumVals) $ Set.toList enums
enumItems = map (\(x, v) -> MIDecl $ Localparam (Implicit Unspecified []) x v) enumPairs
(Part extern kw lifetime name ports items, enums) =
runWriter $ traverseModuleItemsM (traverseTypesM traverseType) $
......
......@@ -195,7 +195,7 @@ unflattener writeToFlatVariant arr (t, (majorHi, majorLo)) =
(index, majorLo)
(BinOp Le (Ident index) majorHi)
(index, AsgnOp Add, Number "1")
(Just $ prefix "unflatten")
(Just $ prefix "unflatten_" ++ arr)
[ localparam startBit
(simplify $ BinOp Add majorLo
(BinOp Mul (Ident index) size))
......@@ -206,9 +206,9 @@ unflattener writeToFlatVariant arr (t, (majorHi, majorLo)) =
]
]
where
startBit = prefix "_tmp_start"
startBit = prefix "_tmp_start_" ++ arr
arrUnflat = prefix arr
index = prefix "_tmp_index"
index = prefix "_tmp_index_" ++ arr
(minorHi, minorLo) = head $ snd $ typeRanges t
size = rangeSize (minorHi, minorLo)
localparam :: Identifier -> Expr -> GenItem
......
......@@ -105,6 +105,8 @@ traverseModuleItemsM :: Monad m => MapperM m ModuleItem -> MapperM m Description
traverseModuleItemsM mapper (Part extern kw lifetime name ports items) =
mapM fullMapper items >>= return . Part extern kw lifetime name ports
where
fullMapper (Generate [GenBlock Nothing genItems]) =
mapM fullGenItemMapper genItems >>= mapper . Generate
fullMapper (Generate genItems) =
mapM fullGenItemMapper genItems >>= mapper . Generate
fullMapper other = mapper other
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment