mirror of https://github.com/zachjs/sv2v.git
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:
parent
39519dd439
commit
21ebbb5a19
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue