use repeats for converted unbased-unsized literals

- reduces the number of cast functions which are generated
- adjust package_function_cast to preserve cast converage
- fix issue where cast functions would be generated before localparam
  substitution within a procedure
This commit is contained in:
Zachary Snow
2020-07-24 21:29:59 -06:00
parent 39519dd439
commit 21ebbb5a19
3 changed files with 9 additions and 5 deletions
+4 -1
View File
@@ -31,7 +31,10 @@ traverseDeclM decl = do
if isPrefixOf "sv2v_cast_" x && details /= Nothing
then return $ Variable Local DuplicateTag x [] Nil
else insertElem x t >> return decl
Param _ t x _ -> insertElem x t >> return decl
Param _ t x _ -> do
inProcedure <- withinProcedureM
when (not inProcedure) $ insertElem x t
return decl
ParamType _ _ _ -> return decl
CommentDecl _ -> return decl
traverseDeclExprsM traverseExprM decl'
+2 -2
View File
@@ -102,7 +102,7 @@ convertModuleItemM (Instance moduleName params instanceName [] bindings) = do
expr'' <- traverseNestedExprsM (replaceBindingExpr port) expr'
return (portName, expr'')
replaceBindingExpr :: Port -> Expr -> Writer Binds Expr
replaceBindingExpr port (orig @ (Cast Right{} (ConvertedUU a b))) = do
replaceBindingExpr port (orig @ (Repeat _ [ConvertedUU a b])) = do
let ch = charForBit a b
if orig == sizedLiteralFor tag ch
then do
@@ -141,7 +141,7 @@ charForBit _ _ = error "charForBit invariant violated"
sizedLiteralFor :: Expr -> Char -> Expr
sizedLiteralFor expr ch =
Cast (Right size) (literalFor ch)
Repeat size [literalFor ch]
where size = DimsFn FnBits $ Right expr
convertAsgn :: (LHS, Expr) -> (LHS, Expr)