Skip to content

Commit

Permalink
Retract math fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Boronski <[email protected]>
  • Loading branch information
kboronski-ant committed Oct 18, 2024
1 parent ccea93c commit 1bcdc17
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 52 deletions.
1 change: 0 additions & 1 deletion bin/verilator
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ detailed descriptions of these arguments.
--Mdir <directory> Name of output object directory
--MMD Create .d dependency files
--mod-prefix <topname> Name to prepend to lower classes
--no-null-arithmetics-quirks Return neutral element for nullary reductions instead of zero
--MP Create phony dependency targets
+notimingchecks Ignored
-O0 Disable optimizations
Expand Down
29 changes: 8 additions & 21 deletions include/verilated_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -840,33 +840,28 @@ class VlQueue final {
return out;
}
T_Value r_product() const {
#ifdef VERILATOR_BIG3_NULLARY_ARITHMETICS_QUIRKS
if (m_deque.empty()) return T_Value(0);
#endif
if (m_deque.empty()) return T_Value(0); // The big three do it this way
T_Value out = T_Value(1);
for (const auto& i : m_deque) out *= i;
return out;
}
template <typename Func>
WithFuncReturnType<Func> r_product(Func with_func) const {
#ifdef VERILATOR_BIG3_NULLARY_ARITHMETICS_QUIRKS
if (m_deque.empty()) return WithFuncReturnType<Func>(0);
#endif
if (m_deque.empty()) return WithFuncReturnType<Func>(0); // The big three do it this way
WithFuncReturnType<Func> out = WithFuncReturnType<Func>(1);
IData index = 0;
for (const auto& i : m_deque) out *= with_func(index++, i);
return out;
}
T_Value r_and() const {
#ifdef VERILATOR_BIG3_NULLARY_ARITHMETICS_QUIRKS
if (m_deque.empty()) return T_Value(0);
#endif
if (m_deque.empty()) return T_Value(0); // The big three do it this way
T_Value out = ~T_Value(0);
for (const auto& i : m_deque) out &= i;
return out;
}
template <typename Func>
WithFuncReturnType<Func> r_and(Func with_func) const {
if (m_deque.empty()) return WithFuncReturnType<Func>(0); // The big three do it this way
IData index = 0;
WithFuncReturnType<Func> out = ~WithFuncReturnType<Func>(0);
for (const auto& i : m_deque) out &= with_func(index++, i);
Expand Down Expand Up @@ -1186,35 +1181,27 @@ class VlAssocArray final {
return out;
}
T_Value r_product() const {
#ifdef VERILATOR_BIG3_NULLARY_ARITHMETICS_QUIRKS
if (m_map.empty()) return T_Value(0);
#endif
if (m_map.empty()) return T_Value(0); // The big three do it this way
T_Value out = T_Value(1);
for (const auto& i : m_map) out *= i.second;
return out;
}
template <typename Func>
WithFuncReturnType<Func> r_product(Func with_func) const {
#ifdef VERILATOR_BIG3_NULLARY_ARITHMETICS_QUIRKS
if (m_map.empty()) return WithFuncReturnType<Func>(0);
#endif
if (m_map.empty()) return WithFuncReturnType<Func>(0); // The big three do it this way
WithFuncReturnType<Func> out = WithFuncReturnType<Func>(1);
for (const auto& i : m_map) out *= with_func(i.first, i.second);
return out;
}
T_Value r_and() const {
#ifdef VERILATOR_BIG3_NULLARY_ARITHMETICS_QUIRKS
if (m_map.empty()) return T_Value(0);
#endif
if (m_map.empty()) return T_Value(0); // The big three do it this way
T_Value out = ~T_Value(0);
for (const auto& i : m_map) out &= i.second;
return out;
}
template <typename Func>
WithFuncReturnType<Func> r_and(Func with_func) const {
#ifdef VERILATOR_BIG3_NULLARY_ARITHMETICS_QUIRKS
if (m_map.empty()) return WithFuncReturnType<Func>(0);
#endif
if (m_map.empty()) return WithFuncReturnType<Func>(0); // The big three do it this way
WithFuncReturnType<Func> out = ~WithFuncReturnType<Func>(0);
for (const auto& i : m_map) out &= with_func(i.first, i.second);
return out;
Expand Down
5 changes: 1 addition & 4 deletions src/V3EmitCMake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ class CMakeEmitter final {
*of << "\n### Compiler flags...\n";

*of << "# User CFLAGS (from -CFLAGS on Verilator command line)\n";
V3StringList cFlagsList = v3Global.opt.cFlags();
if (v3Global.opt.nullArithmeticsQuirks())
cFlagsList.push_back("-DVERILATOR_BIG3_NULLARY_ARITHMETICS_QUIRKS");
cmake_set_raw(*of, name + "_USER_CFLAGS", cmake_list(cFlagsList));
cmake_set_raw(*of, name + "_USER_CFLAGS", cmake_list(v3Global.opt.cFlags()));

*of << "# User LDLIBS (from -LDFLAGS on Verilator command line)\n";
cmake_set_raw(*of, name + "_USER_LDLIBS", cmake_list(v3Global.opt.ldLibs()));
Expand Down
3 changes: 0 additions & 3 deletions src/V3EmitMk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "V3EmitMk.h"

#include "V3EmitCBase.h"
#include "V3Global.h"
#include "V3HierBlock.h"
#include "V3Os.h"

Expand Down Expand Up @@ -689,8 +688,6 @@ class EmitMk final {
of.puts("\t-DVM_SOLVER_DEFAULT='\"" + V3OutFormatter::quoteNameControls(solver)
+ "\"' \\\n");
if (!v3Global.opt.libCreate().empty()) of.puts("\t-fPIC \\\n");
if (v3Global.opt.nullArithmeticsQuirks())
of.puts("-DVERILATOR_BIG3_NULLARY_ARITHMETICS_QUIRKS \\\n");
const V3StringList& cFlags = v3Global.opt.cFlags();
for (const string& i : cFlags) of.puts("\t" + i + " \\\n");
of.puts("\n");
Expand Down
2 changes: 0 additions & 2 deletions src/V3Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,8 +1399,6 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc,
DECL_OPTION("-max-num-width", Set, &m_maxNumWidth);
DECL_OPTION("-mod-prefix", Set, &m_modPrefix);

DECL_OPTION("-null-arithmetics-quirks", OnOff, &m_nullArithmeticsQuirks);

DECL_OPTION("-O0", CbCall, [this]() { optimize(0); });
DECL_OPTION("-O1", CbCall, [this]() { optimize(1); });
DECL_OPTION("-O2", CbCall, [this]() { optimize(2); });
Expand Down
2 changes: 0 additions & 2 deletions src/V3Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ class V3Options final {
bool m_xInitialEdge = false; // main switch: --x-initial-edge
bool m_xmlOnly = false; // main switch: --xml-only
bool m_jsonOnly = false; // main switch: --json-only
bool m_nullArithmeticsQuirks = true; // main switch: --no-null-arithmetics-quirks

int m_buildJobs = -1; // main switch: --build-jobs, -j
int m_convergeLimit = 100; // main switch: --converge-limit
Expand Down Expand Up @@ -548,7 +547,6 @@ class V3Options final {
bool jsonOnly() const { return m_jsonOnly; }
bool serializeOnly() const { return m_xmlOnly || m_jsonOnly; }
bool topIfacesSupported() const { return lintOnly() && !hierarchical(); }
bool nullArithmeticsQuirks() const { return m_nullArithmeticsQuirks; }

int buildJobs() const VL_MT_SAFE { return m_buildJobs; }
int convergeLimit() const { return m_convergeLimit; }
Expand Down
2 changes: 1 addition & 1 deletion test_regress/t/t_assoc_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

test.scenarios('simulator')

test.compile(verilator_flags2=["--no-null-arithmetics-quirks"])
test.compile()

test.execute()

Expand Down
10 changes: 5 additions & 5 deletions test_regress/t/t_assoc_method.v
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ module t (/*AUTOARG*/);
i = qe.sum with (item + 1);
`checkh(i, 32'h0);
i = qe.product;
`checkh(i, 32'h1);
`checkh(i, 32'h0);
i = qe.product with (item + 1);
`checkh(i, 32'h1);
`checkh(i, 32'h0);

q = '{10:32'b1100, 11:32'b1010};
i = q.and;
Expand All @@ -145,9 +145,9 @@ module t (/*AUTOARG*/);
`checkh(i, 32'b0110);

i = qe.and;
`checkh(i, 32'hffff_ffff);
`checkh(i, 32'b0);
i = qe.and with (item + 1);
`checkh(i, 32'hffff_ffff);
`checkh(i, 32'h0);
i = qe.or;
`checkh(i, 32'b0);
i = qe.or with (item + 1);
Expand All @@ -171,7 +171,7 @@ module t (/*AUTOARG*/);
`checkh(i, 32'b0110);

i = qe.and();
`checkh(i, 32'hffff_ffff);
`checkh(i, 32'b0);
i = qe.or();
`checkh(i, 32'b0);
i = qe.xor();
Expand Down
2 changes: 1 addition & 1 deletion test_regress/t/t_assoc_wildcard_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

test.scenarios('simulator')

test.compile(verilator_flags2=["--no-null-arithmetics-quirks"])
test.compile()

test.execute()

Expand Down
8 changes: 4 additions & 4 deletions test_regress/t/t_assoc_wildcard_method.v
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module t (/*AUTOARG*/);
i = qe.sum;
`checkh(i, 32'h0);
i = qe.product;
`checkh(i, 32'h1);
`checkh(i, 32'h0);

q = '{10:32'b1100, 11:32'b1010};
i = q.and;
Expand All @@ -103,9 +103,9 @@ module t (/*AUTOARG*/);
`checkh(i, 32'b0110);

i = qe.and;
`checkh(i, 32'hffff_ffff);
`checkh(i, 32'h0);
i = qe.and with (item + 1);
`checkh(i, 32'hffff_ffff);
`checkh(i, 32'h0);
i = qe.or;
`checkh(i, 32'b0);
i = qe.or with (item + 1);
Expand All @@ -129,7 +129,7 @@ module t (/*AUTOARG*/);
`checkh(i, 32'b0110);

i = qe.and();
`checkh(i, 32'hffff_ffff);
`checkh(i, 32'b0);
i = qe.or();
`checkh(i, 32'b0);
i = qe.xor();
Expand Down
2 changes: 1 addition & 1 deletion test_regress/t/t_dynarray_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

test.scenarios('simulator')

test.compile(verilator_flags2=["--no-null-arithmetics-quirks"])
test.compile()

test.execute()

Expand Down
4 changes: 2 additions & 2 deletions test_regress/t/t_dynarray_method.v
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ module t (/*AUTOARG*/);
`checkh(i, 32'h0);

i = de.product;
`checkh(i, 32'h1);
`checkh(i, 32'h0);

d = '{32'b1100, 32'b1010};

Expand All @@ -149,7 +149,7 @@ module t (/*AUTOARG*/);
`checkh(i, 32'b0110);

i = de.and;
`checkh(i, 32'hffff_ffff);
`checkh(i, 32'b0);
i = de.or;
`checkh(i, 32'b0);
i = de.xor;
Expand Down
2 changes: 1 addition & 1 deletion test_regress/t/t_queue_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

test.scenarios('simulator')

test.compile(verilator_flags2=["--no-null-arithmetics-quirks"])
test.compile()

test.execute()

Expand Down
8 changes: 4 additions & 4 deletions test_regress/t/t_queue_method.v
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ module t (/*AUTOARG*/);
`checkh(i, 32'h0);

i = qe.product;
`checkh(i, 32'h1);
`checkh(i, 32'h0);
i = qe.product with (item + 1);
`checkh(i, 32'h1);
`checkh(i, 32'h0);

q = '{32'b1100, 32'b1010};
i = q.and;
Expand All @@ -210,9 +210,9 @@ module t (/*AUTOARG*/);
`checkh(i, 32'b0110);

i = qe.and;
`checkh(i, 32'hffff_ffff);
`checkh(i, 32'b0);
i = qe.and with (item + 1);
`checkh(i, 32'hffff_ffff);
`checkh(i, 32'b0);
i = qe.or;
`checkh(i, 32'b0);
i = qe.or with (item + 1);
Expand Down

0 comments on commit 1bcdc17

Please sign in to comment.