Add stats

This commit is contained in:
Geza Lore 2026-02-15 17:59:26 +00:00
parent 65aa539ff0
commit a37af8b2d9
4 changed files with 26 additions and 2 deletions

View File

@ -71,6 +71,7 @@
#include "V3MemberMap.h"
#include "V3SenExprBuilder.h"
#include "V3SenTree.h"
#include "V3Stats.h"
#include "V3UniqueNames.h"
#include <queue>
@ -504,6 +505,11 @@ class TimingControlVisitor final : public VNVisitor {
SenTreeFinder m_finder{m_netlistp}; // Sentree finder and uniquifier
SenExprBuilder* m_senExprBuilderp = nullptr; // Sens expression builder for current m_scope
// Stats
size_t m_statZeroDelays = 0; // Number of statically known #0 delays
size_t m_statConstDelays = 0; // Number of statically known #const (non-zero) delays
size_t m_statVariableDelays = 0; // Number of delays with value unknown at compile time
// METHODS
// Transform an assignment with an intra timing control into a timing control with the
// assignment under it
@ -947,6 +953,16 @@ class TimingControlVisitor final : public VNVisitor {
valuep = V3Const::constifyEdit(valuep);
}
// Statistics
if (valuep->isZero()) {
++m_statZeroDelays;
} else if (VN_IS(valuep, Const)) {
++m_statConstDelays;
} else {
++m_statVariableDelays;
}
// Decide scheduling support for #0
if (v3Global.opt.schedZeroDelay().isSetTrue()) {
// User said to schedule for #0 support, nothing else to do
v3Global.setUsesZeroDelay();
@ -1381,7 +1397,11 @@ public:
<< "... use '--sched-zero-delay' to suppress this warning.");
}
}
~TimingControlVisitor() override = default;
~TimingControlVisitor() override {
V3Stats::addStat("Timing, known #0 delays", m_statZeroDelays);
V3Stats::addStat("Timing, known #const delays", m_statConstDelays);
V3Stats::addStat("Timing, unknown #variable delays", m_statVariableDelays);
}
};
//######################################################################

View File

@ -11,8 +11,12 @@ import vltest_bootstrap
test.scenarios('simulator')
test.compile(verilator_flags2=["--binary", "--timing"])
test.compile(verilator_flags2=["--binary", "--stats"])
test.execute(expect_filename=test.golden_filename)
test.file_grep(test.stats, r'Timing, known #0 delays\s+(\d+)', 1)
test.file_grep(test.stats, r'Timing, known #const delays\s+(\d+)', 2)
test.file_grep(test.stats, r'Timing, unknown #variable delays\s+(\d+)', 0)
test.passes()