mirror of https://github.com/zachjs/sv2v.git
struct conversion attempts to size unsized constants when packing patterns
This commit is contained in:
parent
006e0e0830
commit
377600078a
|
|
@ -10,6 +10,7 @@ import Data.Maybe (fromJust, isJust)
|
||||||
import Data.List (elemIndex, sortOn)
|
import Data.List (elemIndex, sortOn)
|
||||||
import Data.Tuple (swap)
|
import Data.Tuple (swap)
|
||||||
import Control.Monad.Writer
|
import Control.Monad.Writer
|
||||||
|
import Text.Read (readMaybe)
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
|
|
||||||
import Convert.Traverse
|
import Convert.Traverse
|
||||||
|
|
@ -231,7 +232,21 @@ convertAsgn structs types (lhs, expr) =
|
||||||
items'' = map subMap items'
|
items'' = map subMap items'
|
||||||
fieldNames = map snd fields
|
fieldNames = map snd fields
|
||||||
itemPosition = \(Just x, _) -> fromJust $ elemIndex x fieldNames
|
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
|
convertExpr _ other = other
|
||||||
|
|
||||||
-- try expression conversion by looking at the *innermost* type first
|
-- try expression conversion by looking at the *innermost* type first
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ module CacheHelper (
|
||||||
writeData: `WORD_POISON,
|
writeData: `WORD_POISON,
|
||||||
requestType: CACHE_READ,
|
requestType: CACHE_READ,
|
||||||
isValid: 1'b1,
|
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'
|
// 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
|
writeSet: '0
|
||||||
};
|
};
|
||||||
|
|
@ -62,4 +62,4 @@ module CacheHelper (
|
||||||
|
|
||||||
assign flatRequest = request;
|
assign flatRequest = request;
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue