size using lhs for reg continuous assignment indirection

This commit is contained in:
Zachary Snow 2021-04-14 14:31:31 -04:00
parent 44afcf5b29
commit 1ba5ab2739
4 changed files with 48 additions and 1 deletions

View File

@ -118,7 +118,7 @@ traverseModuleItem ports scopes =
]
where
t = Net (NetType TWire) Unspecified
[(DimsFn FnBits $ Right expr, RawNum 1)]
[(DimsFn FnBits $ Right $ lhsToExpr lhs, RawNum 1)]
x = "sv2v_tmp_" ++ shortHash (lhs, expr)
-- rewrite port bindings to use temporary nets where necessary
fixModuleItem (Instance moduleName params instanceName rs bindings) =

View File

@ -0,0 +1,22 @@
module example(sel, out);
parameter W = 8;
typedef struct packed {
logic [W/2-1:0] x;
logic [W/2-1:0] y;
} line_t;
line_t [3:0] arr;
initial begin
arr[0] = 8'b01000011;
arr[1] = 8'b00010110;
arr[2] = 8'b10001111;
arr[3] = 8'b01100110;
end
input logic [1:0] sel;
output line_t out;
assign out.x = sel ? arr[sel].x : '0;
always @* out.y = sel ? arr[sel].y : '0;
endmodule

View File

@ -0,0 +1,16 @@
module example(sel, out);
parameter W = 8;
reg [7:0] arr [3:0];
initial begin
arr[0] = 8'b01000011;
arr[1] = 8'b00010110;
arr[2] = 8'b10001111;
arr[3] = 8'b01100110;
end
input [1:0] sel;
output [7:0] out;
assign out = sel ? arr[sel] : 8'b0;
endmodule

View File

@ -0,0 +1,9 @@
module top;
reg [1:0] sel;
wire [7:0] out;
example e(.sel, .out);
integer i = 0;
initial
for (i = 0; i < 10; i = i + 1)
#1 sel = i;
endmodule