mirror of https://github.com/zachjs/sv2v.git
fix elaboration of struct array fields referenced hierarchically
- `expr.name[idx]` considers `expr.name` could be a struct array - remove fallback struct type lookups which were guaranteed to fail
This commit is contained in:
parent
f71accb3c8
commit
a6ebc0e3ff
|
|
@ -349,7 +349,7 @@ convertSubExpr scopes (Dot e x) =
|
|||
else Range e' IndexedMinus (base, len)
|
||||
convertSubExpr scopes (Range (Dot e x) NonIndexed rOuter) =
|
||||
if isntStruct subExprType then
|
||||
fallbackType scopes orig'
|
||||
(UnknownType, orig')
|
||||
else if structIsntReady subExprType then
|
||||
(replaceInnerTypeRange NonIndexed rOuter' fieldType, orig')
|
||||
else
|
||||
|
|
@ -371,7 +371,7 @@ convertSubExpr scopes (Range (Dot e x) NonIndexed rOuter) =
|
|||
endianCondRange dim rangeLeft rangeRight
|
||||
convertSubExpr scopes (Range (Dot e x) mode (baseO, lenO)) =
|
||||
if isntStruct subExprType then
|
||||
fallbackType scopes orig'
|
||||
(UnknownType, orig')
|
||||
else if structIsntReady subExprType then
|
||||
(replaceInnerTypeRange mode (baseO', lenO') fieldType, orig')
|
||||
else
|
||||
|
|
@ -401,7 +401,7 @@ convertSubExpr scopes (Range e mode (left, right)) =
|
|||
r' = (left', right')
|
||||
convertSubExpr scopes (Bit (Dot e x) i) =
|
||||
if isntStruct subExprType then
|
||||
fallbackType scopes orig'
|
||||
(dropInnerTypeRange backupType, orig')
|
||||
else if structIsntReady subExprType then
|
||||
(dropInnerTypeRange fieldType, orig')
|
||||
else
|
||||
|
|
@ -409,6 +409,7 @@ convertSubExpr scopes (Bit (Dot e x) i) =
|
|||
where
|
||||
(subExprType, e') = convertSubExpr scopes e
|
||||
(_, i') = convertSubExpr scopes i
|
||||
(backupType, _) = fallbackType scopes $ Dot e' x
|
||||
orig' = Bit (Dot e' x) i'
|
||||
(fieldType, bounds, dims) = lookupFieldInfo subExprType x
|
||||
[dim] = dims
|
||||
|
|
@ -417,7 +418,7 @@ convertSubExpr scopes (Bit (Dot e x) i) =
|
|||
iFlat = endianCondExpr dim left right
|
||||
convertSubExpr scopes (Bit e i) =
|
||||
if t == UnknownType
|
||||
then fallbackType scopes $ Bit e' i'
|
||||
then (UnknownType, Bit e' i')
|
||||
else (dropInnerTypeRange t, Bit e' i')
|
||||
where
|
||||
(t, e') = convertSubExpr scopes e
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
module top;
|
||||
if (1) begin : blk
|
||||
struct packed {
|
||||
logic x, y;
|
||||
} [1:0] s;
|
||||
end
|
||||
assign blk.s[0].x = 0;
|
||||
assign top.blk.s[0].y = 1;
|
||||
assign top.blk.s[1].x = 1;
|
||||
assign blk.s[1].y = 0;
|
||||
initial #1 $display("%b", blk.s);
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
module top;
|
||||
if (1) begin : blk
|
||||
wire [3:0] s;
|
||||
end
|
||||
assign blk.s = 4'b1001;
|
||||
initial #1 $display("%b", blk.s);
|
||||
endmodule
|
||||
Loading…
Reference in New Issue