diff --git a/src/Convert/Struct.hs b/src/Convert/Struct.hs index ed304c5..6089f2e 100644 --- a/src/Convert/Struct.hs +++ b/src/Convert/Struct.hs @@ -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 diff --git a/test/relong/cache_request.sv b/test/relong/cache_request.sv index 8fd29f2..c651a00 100644 --- a/test/relong/cache_request.sv +++ b/test/relong/cache_request.sv @@ -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 }; @@ -62,4 +62,4 @@ module CacheHelper ( assign flatRequest = request; -endmodule \ No newline at end of file +endmodule