mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
parent
13114f2efe
commit
2537431273
@ -19,6 +19,7 @@ Andrew Miloradovsky
|
||||
Andrew Nolte
|
||||
Anthony Donlon
|
||||
Arkadiusz Kozdra
|
||||
Arthur Rosa
|
||||
Aylon Chaim Porat
|
||||
Bartłomiej Chmiel
|
||||
Cameron Kirk
|
||||
|
@ -89,16 +89,17 @@ public:
|
||||
// Create data type
|
||||
const int width = elemDType->width();
|
||||
AstNodeDType* const subDTypep
|
||||
= elemDType->isString()
|
||||
= elemDType->isString() || elemDType->isDouble()
|
||||
? elemDType
|
||||
: v3Global.rootp()->findBitDType(width, width, VSigning::UNSIGNED);
|
||||
AstUnpackArrayDType* const tableDTypep = new AstUnpackArrayDType{
|
||||
m_fl, subDTypep, new AstRange{m_fl, static_cast<int>(size), 0}};
|
||||
v3Global.rootp()->typeTablep()->addTypesp(tableDTypep);
|
||||
// Create table initializer (with default value 0)
|
||||
AstConst* const defaultp = elemDType->isString()
|
||||
? new AstConst{m_fl, AstConst::String{}, ""}
|
||||
: new AstConst{m_fl, AstConst::WidthedValue{}, width, 0};
|
||||
AstConst* const defaultp
|
||||
= elemDType->isString() ? new AstConst{m_fl, AstConst::String{}, ""}
|
||||
: elemDType->isDouble() ? new AstConst{m_fl, AstConst::RealDouble{}, 0.0}
|
||||
: new AstConst{m_fl, AstConst::WidthedValue{}, width, 0};
|
||||
m_initp = new AstInitArray{m_fl, tableDTypep, defaultp};
|
||||
}
|
||||
|
||||
|
9
test_regress/t/t_opt_table_real.out
Normal file
9
test_regress/t/t_opt_table_real.out
Normal file
@ -0,0 +1,9 @@
|
||||
cyle 0 = 1.0
|
||||
cyle 1 = 2.0
|
||||
cyle 2 = 3.0
|
||||
cyle 3 = 0.0
|
||||
cyle 4 = 5.0
|
||||
cyle 5 = 6.0
|
||||
cyle 6 = 0.0
|
||||
cyle 7 = 0.0
|
||||
*-* All Finished *-*
|
28
test_regress/t/t_opt_table_real.pl
Executable file
28
test_regress/t/t_opt_table_real.pl
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2024 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
scenarios(simulator => 1);
|
||||
|
||||
compile(
|
||||
verilator_flags2 => ["--stats"],
|
||||
);
|
||||
|
||||
if ($Self->{vlt_all}) {
|
||||
file_grep($Self->{stats}, qr/Optimizations, Tables created\s+(\d+)/i, 1);
|
||||
file_grep($Self->{stats}, qr/ConstPool, Tables emitted\s+(\d+)/i, 1);
|
||||
}
|
||||
|
||||
execute(
|
||||
check_finished => 1,
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
39
test_regress/t/t_opt_table_real.v
Normal file
39
test_regress/t/t_opt_table_real.v
Normal file
@ -0,0 +1,39 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2024.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t (
|
||||
// Inputs
|
||||
clk
|
||||
);
|
||||
input clk;
|
||||
|
||||
reg [2:0] cyc;
|
||||
real x;
|
||||
|
||||
initial cyc = 0;
|
||||
always @(posedge clk) cyc <= cyc + 1;
|
||||
|
||||
always @(cyc) begin
|
||||
case (cyc)
|
||||
3'd0: x = 1.0;
|
||||
3'd1: x = 2.0;
|
||||
3'd2: x = 3.0;
|
||||
3'd4: x = 5.0;
|
||||
3'd5: x = 6.0;
|
||||
default: x = 0.0;
|
||||
endcase
|
||||
end
|
||||
|
||||
always @(posedge clk) begin
|
||||
$display("cyle %d = %.1f", cyc, x);
|
||||
if (cyc == 7) begin
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
;
|
Loading…
Reference in New Issue
Block a user