Commit 21ebbb5a by Zachary Snow

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
parent 39519dd4
......@@ -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'
......
......@@ -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)
......
package P;
function automatic logic [7:0] f(input logic [2:0] p);
logic [7:0] r;
r = '0;
r[p+:2] = '1;
localparam T = $bits(r[7:0]);
r = T'(1'sb0);
r[p+:2] = $bits(r[p+:2])'(1'sb1);
return r;
endfunction
endpackage
......
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