Commit 5351dee8 by Zachary Snow

minor scoping/ordering fixes for pesky VCS restrictions

parent ba7ffdf1
...@@ -12,6 +12,7 @@ module Convert.Enum (convert) where ...@@ -12,6 +12,7 @@ module Convert.Enum (convert) where
import Text.Read (readMaybe) import Text.Read (readMaybe)
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import Data.List (sortOn)
import Control.Monad.Writer import Control.Monad.Writer
import qualified Data.Set as Set import qualified Data.Set as Set
...@@ -31,7 +32,7 @@ convertDescription :: Description -> Description ...@@ -31,7 +32,7 @@ convertDescription :: Description -> Description
convertDescription (description @ (Part _ _ _ _ _ _)) = convertDescription (description @ (Part _ _ _ _ _ _)) =
Part extern kw lifetime name ports (enumItems ++ items) Part extern kw lifetime name ports (enumItems ++ items)
where 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 enumItems = map (\(x, v) -> MIDecl $ Localparam (Implicit Unspecified []) x v) enumPairs
(Part extern kw lifetime name ports items, enums) = (Part extern kw lifetime name ports items, enums) =
runWriter $ traverseModuleItemsM (traverseTypesM traverseType) $ runWriter $ traverseModuleItemsM (traverseTypesM traverseType) $
......
...@@ -195,7 +195,7 @@ unflattener writeToFlatVariant arr (t, (majorHi, majorLo)) = ...@@ -195,7 +195,7 @@ unflattener writeToFlatVariant arr (t, (majorHi, majorLo)) =
(index, majorLo) (index, majorLo)
(BinOp Le (Ident index) majorHi) (BinOp Le (Ident index) majorHi)
(index, AsgnOp Add, Number "1") (index, AsgnOp Add, Number "1")
(Just $ prefix "unflatten") (Just $ prefix "unflatten_" ++ arr)
[ localparam startBit [ localparam startBit
(simplify $ BinOp Add majorLo (simplify $ BinOp Add majorLo
(BinOp Mul (Ident index) size)) (BinOp Mul (Ident index) size))
...@@ -206,9 +206,9 @@ unflattener writeToFlatVariant arr (t, (majorHi, majorLo)) = ...@@ -206,9 +206,9 @@ unflattener writeToFlatVariant arr (t, (majorHi, majorLo)) =
] ]
] ]
where where
startBit = prefix "_tmp_start" startBit = prefix "_tmp_start_" ++ arr
arrUnflat = prefix arr arrUnflat = prefix arr
index = prefix "_tmp_index" index = prefix "_tmp_index_" ++ arr
(minorHi, minorLo) = head $ snd $ typeRanges t (minorHi, minorLo) = head $ snd $ typeRanges t
size = rangeSize (minorHi, minorLo) size = rangeSize (minorHi, minorLo)
localparam :: Identifier -> Expr -> GenItem localparam :: Identifier -> Expr -> GenItem
......
...@@ -105,6 +105,8 @@ traverseModuleItemsM :: Monad m => MapperM m ModuleItem -> MapperM m Description ...@@ -105,6 +105,8 @@ traverseModuleItemsM :: Monad m => MapperM m ModuleItem -> MapperM m Description
traverseModuleItemsM mapper (Part extern kw lifetime name ports items) = traverseModuleItemsM mapper (Part extern kw lifetime name ports items) =
mapM fullMapper items >>= return . Part extern kw lifetime name ports mapM fullMapper items >>= return . Part extern kw lifetime name ports
where where
fullMapper (Generate [GenBlock Nothing genItems]) =
mapM fullGenItemMapper genItems >>= mapper . Generate
fullMapper (Generate genItems) = fullMapper (Generate genItems) =
mapM fullGenItemMapper genItems >>= mapper . Generate mapM fullGenItemMapper genItems >>= mapper . Generate
fullMapper other = mapper other 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