Commit 37760007 by Zachary Snow

struct conversion attempts to size unsized constants when packing patterns

parent 006e0e08
......@@ -10,6 +10,7 @@ import Data.Maybe (fromJust, isJust)
import Data.List (elemIndex, sortOn)
import Data.Tuple (swap)
import Control.Monad.Writer
import Text.Read (readMaybe)
import qualified Data.Map.Strict as Map
import Convert.Traverse
......@@ -231,7 +232,21 @@ convertAsgn structs types (lhs, expr) =
items'' = map subMap items'
fieldNames = map snd fields
itemPosition = \(Just x, _) -> fromJust $ elemIndex x fieldNames
exprs = map snd $ sortOn itemPosition items''
packItem (Just x, Number n) =
Number $
case readMaybe unticked :: Maybe Int of
Nothing ->
if unticked == n
then n
else size ++ n
Just num -> size ++ "'d" ++ show num
where
Number size = rangeSize $ lookupUnstructRange structTf x
unticked = case n of
'\'' : rest -> rest
rest -> rest
packItem (_, itemExpr) = itemExpr
exprs = map packItem $ sortOn itemPosition items''
convertExpr _ other = other
-- try expression conversion by looking at the *innermost* type first
......
......@@ -50,7 +50,7 @@ module CacheHelper (
writeData: `WORD_POISON,
requestType: CACHE_READ,
isValid: 1'b1,
writeEnable: 4'b0,
writeEnable: 0,
// This is effectively 32-bits wide which is sufficient, but not technically correct. The "compiler" will truncate the bits to the width of 'writeSet'
writeSet: '0
};
......
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