mirror of https://github.com/zachjs/sv2v.git
fix double multipack conversion of Exprs in LHSs
This commit is contained in:
parent
78f3db8803
commit
e7381c4db2
|
|
@ -115,13 +115,18 @@ traverseExprM = traverseNestedExprsM $ stately traverseExpr
|
|||
-- LHSs need to be converted too. Rather than duplicating the procedures, we
|
||||
-- turn LHSs into expressions temporarily and use the expression conversion.
|
||||
traverseLHSM :: LHS -> State Info LHS
|
||||
traverseLHSM lhs = do
|
||||
let expr = lhsToExpr lhs
|
||||
expr' <- traverseExprM expr
|
||||
case exprToLHS expr' of
|
||||
Just lhs' -> return lhs'
|
||||
Nothing -> error $ "multi-packed conversion created non-LHS from "
|
||||
++ (show expr) ++ " to " ++ (show expr')
|
||||
traverseLHSM = traverseNestedLHSsM traverseLHSSingleM
|
||||
where
|
||||
-- We can't use traverseExprM directly because that would cause Exprs
|
||||
-- inside of LHSs to be converted twice in a single cycle!
|
||||
traverseLHSSingleM :: LHS -> State Info LHS
|
||||
traverseLHSSingleM lhs = do
|
||||
let expr = lhsToExpr lhs
|
||||
expr' <- stately traverseExpr expr
|
||||
case exprToLHS expr' of
|
||||
Just lhs' -> return lhs'
|
||||
Nothing -> error $ "multi-packed conversion created non-LHS from "
|
||||
++ (show expr) ++ " to " ++ (show expr')
|
||||
|
||||
traverseExpr :: Info -> Expr -> Expr
|
||||
traverseExpr typeMap =
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
module top;
|
||||
logic [3:0][7:0] arr;
|
||||
logic [3:0][1:0] idx;
|
||||
assign idx = { 2'b01, 2'b11, 2'b00, 2'b10 };
|
||||
initial begin
|
||||
arr[idx[0]] = 8'hDE;
|
||||
arr[idx[1]] = 8'hAD;
|
||||
arr[idx[2]] = 8'hBE;
|
||||
arr[idx[3]] = 8'hEF;
|
||||
$display("%h", arr);
|
||||
end
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
module top;
|
||||
reg [31:0] arr;
|
||||
wire [7:0] idx;
|
||||
assign idx = { 2'b01, 2'b11, 2'b00, 2'b10 };
|
||||
initial begin
|
||||
arr[idx[0 * 2 +: 2] * 8 +: 8] = 8'hDE;
|
||||
arr[idx[1 * 2 +: 2] * 8 +: 8] = 8'hAD;
|
||||
arr[idx[2 * 2 +: 2] * 8 +: 8] = 8'hBE;
|
||||
arr[idx[3 * 2 +: 2] * 8 +: 8] = 8'hEF;
|
||||
$display("%h", arr);
|
||||
end
|
||||
endmodule
|
||||
Loading…
Reference in New Issue