mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
Internals: Optimize updates of Vtogcov signals. No functional change intended. (#6110)
This commit is contained in:
+47
-6
@@ -103,7 +103,7 @@ class EmitCGatherDependencies final : VNVisitorConst {
|
||||
addSelfDependency(nodep->selfPointer(), nodep->varp());
|
||||
iterateChildrenConst(nodep);
|
||||
}
|
||||
void visit(AstCoverDecl* nodep) override {
|
||||
void visit(AstNodeCoverDecl* nodep) override {
|
||||
addSymsDependency();
|
||||
iterateChildrenConst(nodep);
|
||||
}
|
||||
@@ -307,17 +307,16 @@ class EmitCImp final : EmitCFunc {
|
||||
splitSizeInc(10);
|
||||
}
|
||||
void emitCoverageImp() {
|
||||
// Rather than putting out VL_COVER_INSERT calls directly, we do it via this
|
||||
// function. This gets around gcc slowness constructing all of the template
|
||||
// arguments.
|
||||
if (v3Global.opt.coverage()) {
|
||||
puts("\n// Coverage\n");
|
||||
// Rather than putting out VL_COVER_INSERT calls directly, we do it via this
|
||||
// function. This gets around gcc slowness constructing all of the template
|
||||
// arguments.
|
||||
puts("void " + prefixNameProtect(m_modp) + "::__vlCoverInsert(");
|
||||
puts(v3Global.opt.threads() > 1 ? "std::atomic<uint32_t>" : "uint32_t");
|
||||
puts("* countp, bool enable, const char* filenamep, int lineno, int column,\n");
|
||||
puts("const char* hierp, const char* pagep, const char* commentp, const char* "
|
||||
"linescovp) "
|
||||
"{\n");
|
||||
"linescovp) {\n");
|
||||
if (v3Global.opt.threads() > 1) {
|
||||
puts("assert(sizeof(uint32_t) == sizeof(std::atomic<uint32_t>));\n");
|
||||
puts("uint32_t* count32p = reinterpret_cast<uint32_t*>(countp);\n");
|
||||
@@ -343,6 +342,48 @@ class EmitCImp final : EmitCFunc {
|
||||
puts("}\n");
|
||||
splitSizeInc(10);
|
||||
}
|
||||
if (v3Global.opt.coverageToggle()) {
|
||||
puts("\n// Toggle Coverage\n");
|
||||
puts("void " + prefixNameProtect(m_modp) + "::__vlCoverToggleInsert(");
|
||||
puts("int begin, int end, bool ranged, ");
|
||||
puts(v3Global.opt.threads() > 1 ? "std::atomic<uint32_t>" : "uint32_t");
|
||||
puts("* countp, bool enable, const char* filenamep, int lineno, int column,\n");
|
||||
puts("const char* hierp, const char* pagep, const char* commentp) {\n");
|
||||
if (v3Global.opt.threads() > 1) {
|
||||
puts("assert(sizeof(uint32_t) == sizeof(std::atomic<uint32_t>));\n");
|
||||
}
|
||||
puts("int step = (end >= begin) ? 1 : -1;\n");
|
||||
// range is inclusive
|
||||
puts("for (int i = begin; i != end + step; i += step) {\n");
|
||||
if (v3Global.opt.threads() > 1) {
|
||||
puts("uint32_t* count32p = reinterpret_cast<uint32_t*>(countp);\n");
|
||||
} else {
|
||||
puts("uint32_t* count32p = countp;\n");
|
||||
}
|
||||
// static doesn't need save-restore as is constant
|
||||
puts("static uint32_t fake_zero_count = 0;\n");
|
||||
puts("std::string fullhier = std::string{VerilatedModule::name()} + hierp;\n");
|
||||
puts("if (!fullhier.empty() && fullhier[0] == '.') fullhier = fullhier.substr(1);\n");
|
||||
puts("std::string commentWithIndex = commentp;\n");
|
||||
puts("if (ranged) commentWithIndex += '[' + std::to_string(i) + ']';\n");
|
||||
// Used for second++ instantiation of identical bin
|
||||
puts("if (!enable) count32p = &fake_zero_count;\n");
|
||||
puts("*count32p = 0;\n");
|
||||
puts("VL_COVER_INSERT(vlSymsp->_vm_contextp__->coveragep(), VerilatedModule::name(), "
|
||||
"count32p,");
|
||||
puts(" \"filename\",filenamep,");
|
||||
puts(" \"lineno\",lineno,");
|
||||
puts(" \"column\",column,\n");
|
||||
puts("\"hier\",fullhier,");
|
||||
puts(" \"page\",pagep,");
|
||||
puts(" \"comment\",commentWithIndex.c_str(),");
|
||||
puts(" \"\", \"\");\n"); // linescov argument, but in toggle coverage it is always
|
||||
// empty
|
||||
puts("++countp;\n");
|
||||
puts("}\n");
|
||||
puts("}\n");
|
||||
splitSizeInc(10);
|
||||
}
|
||||
}
|
||||
void emitDestructorImp(const AstNodeModule* modp) {
|
||||
puts("\n");
|
||||
|
||||
Reference in New Issue
Block a user