Merge pull request #845 from wmlye/wmlye/assertion-issue823

Clean up assertions in #823 and #840
This commit is contained in:
Stephen Williams 2023-01-16 10:35:00 -08:00 committed by GitHub
commit 46a11f4b67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 66 additions and 5 deletions

View File

@ -6196,7 +6196,14 @@ NetExpr* PEIdent::elaborate_expr_net_bit_(Design*des, NetScope*scope,
unsigned long lwid;
long idx;
rc = net->sig()->sb_to_slice(prefix_indices, msv, idx, lwid);
ivl_assert(*this, rc);
if(!rc) {
cerr << get_fileline() << ": error: Index " << net->sig()->name()
<< "[" << msv << "] is out of range."
<< endl;
des->errors += 1;
return 0;
}
// Make an expression out of the index
NetEConst*idx_c = new NetEConst(verinum(idx));

View File

@ -465,9 +465,17 @@ bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
unsigned long tmp_lwid;
bool rcl = sig->sb_to_slice(prefix_indices, msb,
tmp_loff, tmp_lwid);
ivl_assert(*this, rcl);
if(rcl) {
midx = tmp_loff + tmp_lwid - 1;
lidx = tmp_loff;
} else {
cerr << get_fileline() << ": error: Index " << sig->name()
<< "[" << msb << "] is out of range."
<< endl;
des->errors += 1;
midx = 0;
lidx = 0;
}
} else {
midx = sig->sb_to_idx(prefix_indices, msb);
if (midx >= (long)sig->vector_width()) {
@ -632,13 +640,21 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
// containing vector, and member y an offset and width within
// that.
pform_name_t use_path = member_path;
while (! use_path.empty()) {
const name_component_t member_comp = use_path.front();
const perm_string&member_name = member_comp.name;
unsigned long tmp_off;
const struct netstruct_t::member_t*member = struct_type->packed_member(member_name, tmp_off);
ivl_assert(*this, member);
if(!member) {
cerr << get_fileline() << ": error: missing element " << path() << endl;
des->errors += 1;
return 0;
}
member_off += tmp_off;
member_width = member->net_type->packed_width();

View File

@ -0,0 +1,7 @@
// Testcase for Issue #823 on Github
module test;
struct packed {logic a;} s;
assign s.a = 1;
assign s.c = 1;
endmodule

View File

@ -0,0 +1,7 @@
// Testcase for Issue #823 on Github
module test;
struct packed {struct packed {logic a;} t;} u;
assign u.t.a = 1;
assign u.t.c = 1;
endmodule

View File

@ -0,0 +1,10 @@
// Testcase for Issue #840 on Github
module test;
logic [1:0][1:0] a;
logic [1:0][1:0] b;
generate
for(genvar i=0;i<3;i++)
assign b[i] = a[i];
endgenerate
endmodule

View File

@ -0,0 +1,10 @@
// Testchase for #840 on Github
module test;
logic [1:0][1:0] a;
logic [2:0][1:0] b;
generate
for(genvar i=0;i<3;i++)
assign b[i] = a[i];
endgenerate
endmodule

View File

@ -942,3 +942,7 @@ br_gh451 normal,-g2012,-Ptest.foo=4 ivltests gold=br_gh451.gold
br_gh453 normal,-g2012 ivltests
br_gh460 normal,-g2012 ivltests
issue576 normal,-g2012 ivltests
br_gh823a CE,-g2012 ivltests
br_gh823b CE,-g2012 ivltests
br_gh840a CE,-g2012 ivltests
br_gh840b CE,-g2012 ivltests