Skip to content

Commit

Permalink
Merge pull request #1115 from grebe/single_element_array
Browse files Browse the repository at this point in the history
Update handling of single-element arrays.
  • Loading branch information
martinwhitaker authored Apr 16, 2024
2 parents ef7f0a8 + 2818782 commit 35f344a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
31 changes: 31 additions & 0 deletions ivtest/ivltests/single_element_array.v
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions ivtest/regress-vvp.list
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ sf_countones_fail vvp_tests/sf_countones_fail.json
sf_isunknown_fail vvp_tests/sf_isunknown_fail.json
sf_onehot_fail vvp_tests/sf_onehot_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_field_left_right vvp_tests/struct_field_left_right.json
struct_nested1 vvp_tests/struct_nested1.json
Expand Down
4 changes: 4 additions & 0 deletions ivtest/vvp_tests/single_element_array.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "normal",
"source" : "single_element_array.v"
}
8 changes: 4 additions & 4 deletions tgt-vvp/vvp_scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,21 +689,21 @@ static void draw_net_in_scope(ivl_signal_t sig)
nex_data->net_word = iword;

} else if (dimensions > 0) {

/* In this case, we have an alias to an existing
signal array. this typically is an instance of
port collapsing that the elaborator combined to
discover that the entire array can be collapsed,
so the word count for the signal and the alias
*must* match. */

if (word_count == ivl_signal_array_count(nex_data->net)) {
if (iword == 0) {
if (ivl_signal_dimensions(nex_data->net) > 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",
sig, vvp_mangle_name(ivl_signal_basename(sig)),
nex_data->net,
ivl_signal_basename(nex_data->net));
}
}
/* An alias for an individual word. */
} else {
if (iword == 0) {
Expand Down

0 comments on commit 35f344a

Please sign in to comment.