Fix little endian cell ranges, bug1631.

Signed-off-by: Wilson Snyder <wsnyder@wsnyder.org>
This commit is contained in:
Julien Margetts 2019-12-11 17:15:45 -05:00 committed by Wilson Snyder
parent 521418d832
commit f7a06cb54a
4 changed files with 111 additions and 1 deletions

View File

@ -10,6 +10,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
**** Update FST trace API for better performance.
**** Fix little endian cell ranges, bug1631. [Julien Margetts]
* Verilator 4.024 2019-12-08

View File

@ -328,8 +328,11 @@ private:
<<" pd="<<pinDim.first<<","<<pinDim.second<<endl);
if (expDim.first == pinDim.first && expDim.second == pinDim.second+1) {
// Connection to array, where array dimensions match the instant dimension
AstRange* rangep = VN_CAST(nodep->exprp()->dtypep(), UnpackArrayDType)->rangep();
int arraySelNum = rangep->littleEndian()
? (rangep->elementsConst() - 1 - m_instSelNum) : m_instSelNum;
AstNode* exprp = nodep->exprp()->unlinkFrBack();
exprp = new AstArraySel(exprp->fileline(), exprp, m_instSelNum);
exprp = new AstArraySel(exprp->fileline(), exprp, arraySelNum);
nodep->exprp(exprp);
} else if (expwidth == pinwidth) {
// NOP: Arrayed instants: widths match so connect to each instance

View File

@ -0,0 +1,20 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2019 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
scenarios(simulator => 1);
compile(
);
execute(
check_finished => 1,
);
ok(1);
1;

View File

@ -0,0 +1,85 @@
// DESCRIPTION: Verilator: Verilog Test module for Issue#1631
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2019 by Julien Margetts.
module t (/*AUTOARG*/
clk
);
input clk;
localparam N = 4;
wire [7:0] cval1[0:N-1];
wire [7:0] cval2[N-1:0];
wire [7:0] cval3[0:N-1];
wire [7:0] cval4[N-1:0];
wire [3:0] inc;
assign inc = 4'b0001;
// verilator lint_off LITENDIAN
COUNTER UCOUNTER1[N-1:0]
(
.clk (clk),
.inc (inc),
.o (cval1) // Twisted
);
COUNTER UCOUNTER2[N-1:0]
(
.clk (clk),
.inc (inc),
.o (cval2) // Matches
);
COUNTER UCOUNTER3[0:N-1]
(
.clk (clk),
.inc (inc),
.o (cval3) // Matches
);
COUNTER UCOUNTER4[0:N-1]
(
.clk (clk),
.inc (inc),
.o (cval4) // Twisted
);
always @(posedge clk) begin
if ((cval1[3] != cval2[0]) || (cval3[3] != cval4[0]))
$stop;
if ((cval1[0] + cval1[1] + cval1[2] + cval2[1] + cval2[2] + cval2[3] +
cval3[0] + cval3[1] + cval3[2] + cval4[1] + cval4[2] + cval4[3]) != 0)
$stop;
`ifdef TEST_VERBOSE
$display("%d %d %d %d", cval1[0], cval1[1], cval1[2], cval1[3]);
$display("%d %d %d %d", cval2[0], cval2[1], cval2[2], cval2[3]);
$display("%d %d %d %d", cval3[0], cval3[1], cval3[2], cval3[3]);
$display("%d %d %d %d", cval4[0], cval4[1], cval4[2], cval4[3]);
`endif
if (cval1[0] + cval1[3] > 3) begin
$write("*-* All Finished *-*\n");
$finish;
end
end
endmodule
module COUNTER
(
input clk,
input inc,
output reg [7:0] o
);
initial o = 8'd0; // No reset input
always @(posedge clk) if (inc) o <= o + 1;
endmodule