Merge pull request #877 from larsclausen/assign-pattern-continuous

Handle continuous assignment of assignment patterns to array elements
This commit is contained in:
Stephen Williams 2023-04-13 09:18:04 -07:00 committed by GitHub
commit 7fc38a19e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 113 additions and 4 deletions

View File

@ -890,11 +890,8 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
if (sig->pin_count() > 1 && widx_flag) {
if (widx < 0 || widx >= (long) sig->pin_count())
return 0;
netvector_t*tmp2_vec = new netvector_t(sig->data_type(),
sig->vector_width()-1,0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
sig->type(), tmp2_vec);
sig->type(), sig->net_type());
tmp->set_line(*this);
tmp->local_flag(true);
connect(sig->pin(widx), tmp->pin(0));

View File

@ -0,0 +1,21 @@
// Check that positional assignment patterns are supported for packed arrays
// when doing continuous assignments.
module test;
wire [3:0][3:0] x;
wire [1:0][3:0][3:0] y;
assign x = '{1'b1, 32'h2, 3.0, "TEST"};
assign y = '{'{1'b1, 1 + 1, 3.0, "TEST"},
'{5, 6, '{1'b0, 1 * 1, 3, 1.0}, 8}};
final begin
if (x === 16'h1234 && y == 32'h12345678) begin
$display("PASSED");
end else begin
$display("FAILED");
end
end
endmodule

View File

@ -0,0 +1,21 @@
// Check that positional assignment patterns are supported for packed arrays
// when doing continuous assignments to array elements.
module test;
wire [3:0][3:0] x[2];
wire [1:0][3:0][3:0] y[2];
assign x[0] = '{1'b1, 32'h2, 3.0, "TEST"};
assign y[1] = '{'{1'b1, 1 + 1, 3.0, "TEST"},
'{5, 6, '{1'b0, 1 * 1, 3, 1.0}, 8}};
final begin
if (x[0] === 16'h1234 && y[1] == 32'h12345678) begin
$display("PASSED");
end else begin
$display("FAILED");
end
end
endmodule

View File

@ -0,0 +1,32 @@
// Check that positional assigment patterns are supported for structs when using
// continuous assignments.
module test;
typedef struct packed {
logic [31:0] x;
logic [15:0] y;
logic [7:0] z;
} T;
T x;
// Check nested assignment patterns
struct packed {
T x;
logic [2:0][3:0] y;
} y;
assign x = '{1'b1, 2.0, 2 + 1};
assign y = '{'{1'b1, 2.0, 2 + 1}, '{4, 5, 6}};
final begin
if (x === 56'h00000001000203 &&
y === 68'h00000001000203456) begin
$display("PASSED");
end else begin
$display("FAILED");
end
end
endmodule

View File

@ -0,0 +1,32 @@
// Check that positional assigment patterns are supported for structs when using
// continuous assignments to array elements.
module test;
typedef struct packed {
logic [31:0] x;
logic [15:0] y;
logic [7:0] z;
} T;
T x[2];
// Check nested assignment patterns
struct packed {
T x;
logic [2:0][3:0] y;
} y[2];
assign x[0] = '{1'b1, 2.0, 2 + 1};
assign y[1] = '{'{1'b1, 2.0, 2 + 1}, '{4, 5, 6}};
final begin
if (x[0] === 56'h00000001000203 &&
y[1] === 68'h00000001000203456) begin
$display("PASSED");
end else begin
$display("FAILED");
end
end
endmodule

View File

@ -521,11 +521,15 @@ struct_signed normal,-g2009 ivltests
sv-constants normal,-g2005-sv ivltests
sv_ap_parray1 normal,-g2005-sv ivltests
sv_ap_parray2 normal,-g2005-sv ivltests
sv_ap_parray3 normal,-g2005-sv ivltests
sv_ap_parray4 normal,-g2005-sv ivltests
sv_ap_parray_fail1 CE,-g2005-sv ivltests
sv_ap_parray_fail2 CE,-g2005-sv ivltests
sv_ap_parray_fail3 CE,-g2005-sv ivltests
sv_ap_struct1 normal,-g2005-sv ivltests
sv_ap_struct2 normal,-g2005-sv ivltests
sv_ap_struct3 normal,-g2005-sv ivltests
sv_ap_struct4 normal,-g2005-sv ivltests
sv_ap_struct_fail1 CE,-g2005-sv ivltests
sv_ap_struct_fail2 CE,-g2005-sv ivltests
sv_assign_pattern_cast normal,-g2005-sv ivltests

View File

@ -260,6 +260,8 @@ scan-invalid CE ivltests
sel_rval_bit_ob CE ivltests
sel_rval_part_ob CE ivltests
signed_net_display CE,-pallowsigned=1 ivltests
sv_ap_parray4 CE,-g2005-sv ivltests
sv_ap_struct4 CE,-g2005-sv ivltests
sv_array_cassign1 CE,-g2005-sv ivltests
sv_array_cassign2 CE,-g2005-sv ivltests
sv_array_cassign3 CE,-g2005-sv ivltests