Update handling of single-element arrays.

Also, add a test. This fixes #1113.
This commit is contained in:
Paul Rigge 2024-04-11 15:56:20 -07:00
parent ef7f0a8f38
commit 28187823ed
No known key found for this signature in database
GPG Key ID: ED304C51F2CC0EE7
4 changed files with 40 additions and 4 deletions

View File

@ -0,0 +1,31 @@
module SingleElementArray(
input wire [48:0] x1,
output wire [48:0] out
);
wire [48:0] x17[0:0];
assign x17[0] = x1;
assign out = {x17[0]};
endmodule
module testbench;
reg [48:0] in;
wire [48:0] out;
SingleElementArray dut(.x1(in), .out(out));
initial begin
in = 49'h0000000000000;
#1;
if (out != 49'h0000000000000) begin
$display("FAILED");
$finish;
end
in = 49'h1555555555555;
#1;
if (out != 49'h1555555555555) begin
$display("FAILED");
$finish;
end
$display("PASSED");
end
endmodule

View File

@ -173,6 +173,7 @@ sf_countones_fail vvp_tests/sf_countones_fail.json
sf_isunknown_fail vvp_tests/sf_isunknown_fail.json sf_isunknown_fail vvp_tests/sf_isunknown_fail.json
sf_onehot_fail vvp_tests/sf_onehot_fail.json sf_onehot_fail vvp_tests/sf_onehot_fail.json
sf_onehot0_fail vvp_tests/sf_onehot0_fail.json sf_onehot0_fail vvp_tests/sf_onehot0_fail.json
single_element_array vvp_tests/single_element_array.json
struct_enum_partsel vvp_tests/struct_enum_partsel.json struct_enum_partsel vvp_tests/struct_enum_partsel.json
struct_field_left_right vvp_tests/struct_field_left_right.json struct_field_left_right vvp_tests/struct_field_left_right.json
struct_nested1 vvp_tests/struct_nested1.json struct_nested1 vvp_tests/struct_nested1.json

View File

@ -0,0 +1,4 @@
{
"type" : "normal",
"source" : "single_element_array.v"
}

View File

@ -689,7 +689,6 @@ static void draw_net_in_scope(ivl_signal_t sig)
nex_data->net_word = iword; nex_data->net_word = iword;
} else if (dimensions > 0) { } else if (dimensions > 0) {
/* In this case, we have an alias to an existing /* In this case, we have an alias to an existing
signal array. this typically is an instance of signal array. this typically is an instance of
port collapsing that the elaborator combined to port collapsing that the elaborator combined to
@ -697,13 +696,14 @@ static void draw_net_in_scope(ivl_signal_t sig)
so the word count for the signal and the alias so the word count for the signal and the alias
*must* match. */ *must* match. */
if (word_count == ivl_signal_array_count(nex_data->net)) { if (ivl_signal_dimensions(nex_data->net) > 0 &&
if (iword == 0) { word_count == ivl_signal_array_count(nex_data->net)) {
if (iword == 0) {
fprintf(vvp_out, "v%p .array \"%s\", v%p; Alias to %s \n", fprintf(vvp_out, "v%p .array \"%s\", v%p; Alias to %s \n",
sig, vvp_mangle_name(ivl_signal_basename(sig)), sig, vvp_mangle_name(ivl_signal_basename(sig)),
nex_data->net, nex_data->net,
ivl_signal_basename(nex_data->net)); ivl_signal_basename(nex_data->net));
} }
/* An alias for an individual word. */ /* An alias for an individual word. */
} else { } else {
if (iword == 0) { if (iword == 0) {