forked from github/verilator
Fix generate if, broke in earlier committ, bug492. Merge from Bennett.
This commit is contained in:
parent
f3867d7f80
commit
5b532a1812
@ -369,7 +369,11 @@ private:
|
||||
// Extraction checks
|
||||
bool warnSelect(AstSel* nodep) {
|
||||
AstNode* basefromp = AstArraySel::baseFromp(nodep);
|
||||
if (m_doGenerate) V3Width::widthParamsEdit(nodep); // Never checked yet
|
||||
if (m_doGenerate) {
|
||||
// Never checked yet
|
||||
V3Width::widthParamsEdit(nodep);
|
||||
nodep->iterateChildren(*this); // May need "constifying"
|
||||
}
|
||||
if (AstNodeVarRef* varrefp = basefromp->castNodeVarRef()) {
|
||||
AstVar* varp = varrefp->varp();
|
||||
if (!varp->dtypep()) varp->v3fatalSrc("Data type lost");
|
||||
|
19
test_regress/t/t_gen_cond_const.pl
Executable file
19
test_regress/t/t_gen_cond_const.pl
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2003 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.
|
||||
|
||||
compile (
|
||||
verilator_flags2 => ["--language 1364-2001"]
|
||||
);
|
||||
|
||||
execute (
|
||||
check_finished=>1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
71
test_regress/t/t_gen_cond_const.v
Normal file
71
test_regress/t/t_gen_cond_const.v
Normal file
@ -0,0 +1,71 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test for generate IF constants
|
||||
//
|
||||
// The given generate loop should have a constant expression as argument. This
|
||||
// test checks it really does evaluate as constant.
|
||||
|
||||
// This file ONLY is placed into the Public Domain, for any use, without
|
||||
// warranty, 2012 by Jeremy Bennett.
|
||||
|
||||
|
||||
`define MAX_SIZE 4
|
||||
|
||||
|
||||
module t (/*AUTOARG*/
|
||||
// Inputs
|
||||
clk
|
||||
);
|
||||
input clk;
|
||||
|
||||
// Set the parameters, so that we use a size less than MAX_SIZE
|
||||
test_gen
|
||||
#(.SIZE (2),
|
||||
.MASK (4'b1111))
|
||||
i_test_gen (.clk (clk));
|
||||
|
||||
// This is only a compilation test, but for good measure we do one clock
|
||||
// cycle.
|
||||
integer count;
|
||||
|
||||
initial begin
|
||||
count = 0;
|
||||
end
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (count == 1) begin
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
else begin
|
||||
count = count + 1;
|
||||
end
|
||||
end
|
||||
|
||||
endmodule // t
|
||||
|
||||
|
||||
module test_gen
|
||||
|
||||
#( parameter
|
||||
SIZE = `MAX_SIZE,
|
||||
MASK = `MAX_SIZE'b0)
|
||||
|
||||
(/*AUTOARG*/
|
||||
// Inputs
|
||||
clk
|
||||
);
|
||||
|
||||
input clk;
|
||||
|
||||
// Generate blocks that rely on short-circuiting of the logic to avoid
|
||||
// errors.
|
||||
generate
|
||||
if ((SIZE < 8'h04) && MASK[0]) begin
|
||||
always @(posedge clk) begin
|
||||
`ifdef TEST_VERBOSE
|
||||
$write ("Generate IF MASK[0] = %d\n", MASK[0]);
|
||||
`endif
|
||||
end
|
||||
end
|
||||
endgenerate
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user