Merge pull request #662 from larsclausen/array-base-type-scope
Elaborate base type of array types in the right scope
This commit is contained in:
commit
99eaf007a1
20
elab_sig.cc
20
elab_sig.cc
|
|
@ -1029,9 +1029,13 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
|
|||
unsigned wid = 1;
|
||||
vector<netrange_t>packed_dimensions;
|
||||
|
||||
NetScope*base_type_scope = scope;
|
||||
NetScope*array_type_scope = scope;
|
||||
if (uarray_type_ && !uarray_type_->name.nil())
|
||||
array_type_scope = array_type_scope->find_typedef_scope(des, uarray_type_);
|
||||
|
||||
NetScope*base_type_scope = array_type_scope;
|
||||
if (set_data_type_ && !set_data_type_->name.nil())
|
||||
base_type_scope = scope->find_typedef_scope(des, set_data_type_);
|
||||
base_type_scope = base_type_scope->find_typedef_scope(des, set_data_type_);
|
||||
|
||||
des->errors += error_cnt_;
|
||||
|
||||
|
|
@ -1142,10 +1146,6 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
|
|||
list<netrange_t>unpacked_dimensions;
|
||||
netdarray_t*netdarray = 0;
|
||||
|
||||
NetScope*array_type_scope = scope;
|
||||
if (uarray_type_ && !uarray_type_->name.nil())
|
||||
array_type_scope = scope->find_typedef_scope(des, uarray_type_);
|
||||
|
||||
for (list<pform_range_t>::const_iterator cur = unpacked_.begin()
|
||||
; cur != unpacked_.end() ; ++cur) {
|
||||
PExpr*use_lidx = cur->first;
|
||||
|
|
@ -1155,7 +1155,8 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
|
|||
// dimensions, then turn this into a dynamic array and
|
||||
// put all the packed dimensions there.
|
||||
if (use_lidx==0 && use_ridx==0) {
|
||||
ivl_type_t base_type = elaborate_darray_type(des, scope,
|
||||
ivl_type_t base_type = elaborate_darray_type(des,
|
||||
array_type_scope,
|
||||
"Dynamic array",
|
||||
packed_dimensions);
|
||||
packed_dimensions.clear();
|
||||
|
|
@ -1167,7 +1168,8 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
|
|||
// Special case: Detect the mark for a QUEUE
|
||||
// declaration, which is the dimensions [null:max_idx].
|
||||
if (dynamic_cast<PENull*>(use_lidx)) {
|
||||
ivl_type_t base_type = elaborate_darray_type(des, scope,
|
||||
ivl_type_t base_type = elaborate_darray_type(des,
|
||||
array_type_scope,
|
||||
"Queue",
|
||||
packed_dimensions);
|
||||
packed_dimensions.clear();
|
||||
|
|
@ -1285,7 +1287,7 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
|
|||
sig = new NetNet(scope, name_, wtype, netdarray);
|
||||
|
||||
} else {
|
||||
ivl_type_t use_type = elaborate_type(des, scope,
|
||||
ivl_type_t use_type = elaborate_type(des, array_type_scope,
|
||||
packed_dimensions);
|
||||
|
||||
if (debug_elaborate) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
// Check that a vector base typeof an array type is evaluated in the scope where
|
||||
// the array type is declared.
|
||||
|
||||
localparam A = 8;
|
||||
|
||||
typedef logic [A-1:0] T[1:0];
|
||||
|
||||
module test;
|
||||
localparam A = 4;
|
||||
|
||||
T x;
|
||||
|
||||
initial begin
|
||||
x[0] = 8'hff;
|
||||
if (x[0] === 8'hff) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Check that a complex base type (like a struct) of an array type is evaluated
|
||||
// in the scope where the array type is declared.
|
||||
|
||||
localparam A = 8;
|
||||
|
||||
typedef struct packed {
|
||||
logic [A-1:0] x;
|
||||
} T[1:0];
|
||||
|
||||
module test;
|
||||
localparam A = 4;
|
||||
|
||||
T x;
|
||||
|
||||
initial begin
|
||||
x[0] = 8'hff;
|
||||
if (x[0] === 8'hff) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Check that a vector base type of an array type gets evaluated in the right
|
||||
// scope if the base type is defined in a different scope than the array type.
|
||||
|
||||
localparam A = 8;
|
||||
|
||||
typedef logic [A-1:0] Base;
|
||||
|
||||
module test;
|
||||
localparam A = 4;
|
||||
|
||||
typedef Base T[1:0];
|
||||
|
||||
T x;
|
||||
|
||||
initial begin
|
||||
x[0] = 8'hff;
|
||||
if (x[0] === 8'hff) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// Check that a complex base type (like a struct) of an array type gets
|
||||
// evaluated in the right scope if the base type is defined in a different scope
|
||||
// than the array type.
|
||||
|
||||
localparam A = 8;
|
||||
|
||||
typedef struct packed {
|
||||
logic [A-1:0] x;
|
||||
} Base;
|
||||
|
||||
module test;
|
||||
localparam A = 4;
|
||||
|
||||
typedef Base T[1:0];
|
||||
|
||||
T x;
|
||||
|
||||
initial begin
|
||||
x[0] = 8'hff;
|
||||
if (x[0] === 8'hff) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
// Check that a vector base typeof a dynamic array type is evaluated in the
|
||||
// scope where the array type is declared.
|
||||
|
||||
localparam A = 8;
|
||||
|
||||
typedef logic [A-1:0] T[];
|
||||
|
||||
module test;
|
||||
localparam A = 4;
|
||||
|
||||
T x;
|
||||
|
||||
initial begin
|
||||
x = new [1];
|
||||
x[0] = 8'hff;
|
||||
if (x[0] === 8'hff) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
// Check that a complex base type (like a packed array) of a dynamic array type
|
||||
// is evaluated in the scope where the array type is declared.
|
||||
|
||||
localparam A = 8;
|
||||
|
||||
// Use type identifier for the base to force packed array
|
||||
typedef logic l;
|
||||
typedef l [A-1:0] T[];
|
||||
|
||||
module test;
|
||||
localparam A = 4;
|
||||
|
||||
T x;
|
||||
|
||||
initial begin
|
||||
x = new [1];
|
||||
x[0] = 8'hff;
|
||||
if (x[0] === 8'hff) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// Check that a vector base type of a dynamic array type gets evaluated in the
|
||||
// right scope if the base type is defined in a different scope than the array
|
||||
// type.
|
||||
|
||||
localparam A = 8;
|
||||
|
||||
typedef logic [A-1:0] Base;
|
||||
|
||||
module test;
|
||||
localparam A = 4;
|
||||
|
||||
typedef Base T[];
|
||||
|
||||
T x;
|
||||
|
||||
initial begin
|
||||
x = new [1];
|
||||
x[0] = 8'hff;
|
||||
if (x[0] === 8'hff) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// Check that a complex base type (like a struct) of a dynamic array type gets
|
||||
// evaluated in the right scope if the base type is defined in a different scope
|
||||
// than the array type.
|
||||
|
||||
localparam A = 8;
|
||||
|
||||
// Use type identifier for the base to force packed array
|
||||
typedef logic l;
|
||||
typedef l [A-1:0] Base;
|
||||
|
||||
module test;
|
||||
localparam A = 4;
|
||||
|
||||
typedef Base T[];
|
||||
T x;
|
||||
|
||||
initial begin
|
||||
x = new [1];
|
||||
x[0] = 8'hff;
|
||||
if (x[0] === 8'hff) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
// Check that a vector base typeof a queue type is evaluated in the scope where
|
||||
// the array type is declared.
|
||||
|
||||
localparam A = 8;
|
||||
|
||||
typedef logic [A-1:0] T[$];
|
||||
|
||||
module test;
|
||||
localparam A = 4;
|
||||
|
||||
T x;
|
||||
|
||||
initial begin
|
||||
x.push_back(8'hff);
|
||||
if (x[0] === 8'hff) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Check that a complex base type (like a packed array) of a queue type is
|
||||
// evaluated in the scope where the array type is declared.
|
||||
|
||||
localparam A = 8;
|
||||
|
||||
// Use type identifier for the base to force packed array
|
||||
typedef logic l;
|
||||
typedef l [A-1:0] T[$];
|
||||
|
||||
module test;
|
||||
localparam A = 4;
|
||||
|
||||
T x;
|
||||
|
||||
initial begin
|
||||
x.push_back(8'hff);
|
||||
if (x[0] === 8'hff) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Check that a vector base type of a queue type gets evaluated in the right
|
||||
// scope if the base type is defined in a different scope than the array type.
|
||||
|
||||
localparam A = 8;
|
||||
|
||||
typedef logic [A-1:0] Base;
|
||||
|
||||
module test;
|
||||
localparam A = 4;
|
||||
|
||||
typedef Base T[$];
|
||||
|
||||
T x;
|
||||
|
||||
initial begin
|
||||
x.push_back(8'hff);
|
||||
if (x[0] === 8'hff) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// Check that a complex base type (like a packed array) of a queue type gets
|
||||
// evaluated in the right scope if the base type is defined in a different scope
|
||||
// than the array type.
|
||||
|
||||
localparam A = 8;
|
||||
|
||||
// Use type identifier for the base to force packed array
|
||||
typedef logic l;
|
||||
typedef l [A-1:0] Base;
|
||||
|
||||
module test;
|
||||
localparam A = 4;
|
||||
|
||||
typedef Base T[$];
|
||||
|
||||
T x;
|
||||
|
||||
initial begin
|
||||
x.push_back(8'hff);
|
||||
if (x[0] === 8'hff) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -591,6 +591,18 @@ sv_timeunit_prec_fail2 CE,-g2009,-u,\
|
|||
./ivltests/sv_timeunit_prec_fail2a.v,\
|
||||
./ivltests/sv_timeunit_prec_fail2b.v,\
|
||||
./ivltests/sv_timeunit_prec_fail2c.v, ivltests gold=sv_timeunit_prec_fail2.gold
|
||||
sv_typedef_array_base1 normal,-g2009 ivltests
|
||||
sv_typedef_array_base2 normal,-g2009 ivltests
|
||||
sv_typedef_array_base3 normal,-g2009 ivltests
|
||||
sv_typedef_array_base4 normal,-g2009 ivltests
|
||||
sv_typedef_darray_base1 normal,-g2009 ivltests
|
||||
sv_typedef_darray_base2 normal,-g2009 ivltests
|
||||
sv_typedef_darray_base3 normal,-g2009 ivltests
|
||||
sv_typedef_darray_base4 normal,-g2009 ivltests
|
||||
sv_typedef_queue_base1 normal,-g2009 ivltests
|
||||
sv_typedef_queue_base2 normal,-g2009 ivltests
|
||||
sv_typedef_queue_base3 normal,-g2009 ivltests
|
||||
sv_typedef_queue_base4 normal,-g2009 ivltests
|
||||
sv_typedef_scope1 normal,-g2009 ivltests
|
||||
sv_typedef_scope2 normal,-g2009 ivltests
|
||||
sv_typedef_scope3 normal,-g2009 ivltests
|
||||
|
|
|
|||
|
|
@ -441,6 +441,14 @@ pr3390385b CE,-g2009 ivltests # ++
|
|||
pr3390385c CE,-g2009 ivltests # ++
|
||||
pr3390385d CE,-g2009 ivltests # ++
|
||||
pr3462145 CE,-g2009 ivltests # ++
|
||||
sv_typedef_darray_base1 CE,-g2009 ivltests # Dyanmic array
|
||||
sv_typedef_darray_base2 CE,-g2009 ivltests # Dyanmic array
|
||||
sv_typedef_darray_base3 CE,-g2009 ivltests # Dyanmic array
|
||||
sv_typedef_darray_base4 CE,-g2009 ivltests # Dyanmic array
|
||||
sv_typedef_queue_base1 CE,-g2009 ivltests # queue
|
||||
sv_typedef_queue_base2 CE,-g2009 ivltests # queue
|
||||
sv_typedef_queue_base3 CE,-g2009 ivltests # queue
|
||||
sv_typedef_queue_base4 CE,-g2009 ivltests # queue
|
||||
wait_fork CE,-g2009 ivltests # wait fork and join_*
|
||||
wild_cmp_err CE,-g2009 ivltests # ==?/!=?
|
||||
wild_cmp_err2 CE,-g2009 ivltests # ==?/!=?
|
||||
|
|
|
|||
Loading…
Reference in New Issue