Commit e7381c4d by Zachary Snow

fix double multipack conversion of Exprs in LHSs

parent 78f3db88
...@@ -115,9 +115,14 @@ traverseExprM = traverseNestedExprsM $ stately traverseExpr ...@@ -115,9 +115,14 @@ traverseExprM = traverseNestedExprsM $ stately traverseExpr
-- LHSs need to be converted too. Rather than duplicating the procedures, we -- LHSs need to be converted too. Rather than duplicating the procedures, we
-- turn LHSs into expressions temporarily and use the expression conversion. -- turn LHSs into expressions temporarily and use the expression conversion.
traverseLHSM :: LHS -> State Info LHS traverseLHSM :: LHS -> State Info LHS
traverseLHSM lhs = do 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 let expr = lhsToExpr lhs
expr' <- traverseExprM expr expr' <- stately traverseExpr expr
case exprToLHS expr' of case exprToLHS expr' of
Just lhs' -> return lhs' Just lhs' -> return lhs'
Nothing -> error $ "multi-packed conversion created non-LHS from " Nothing -> error $ "multi-packed conversion created non-LHS from "
......
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
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
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