mirror of https://github.com/zachjs/sv2v.git
size using lhs for reg continuous assignment indirection
This commit is contained in:
parent
44afcf5b29
commit
1ba5ab2739
|
|
@ -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) =
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
Loading…
Reference in New Issue