mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Fix coverage with member
This commit is contained in:
parent
365537d8e3
commit
248de2be2e
@ -63,14 +63,16 @@ class VerilatedCovImp;
|
||||
/// for (int i = 0; i < 10; ++i) m_cases[i] = 0;
|
||||
/// // Insert
|
||||
/// for (int i = 0; i < 10; ++i)
|
||||
/// VL_COVER_INSERT(&m_cases[i], "comment", "Coverage Case", "i", cvtToNumStr(i));
|
||||
/// VL_COVER_INSERT(covp, name(), &m_cases[i], "comment", "Coverage Case",
|
||||
/// "i", cvtToNumStr(i));
|
||||
/// }
|
||||
|
||||
#define VL_COVER_INSERT(covcontextp, countp, ...) \
|
||||
#define VL_COVER_INSERT(covcontextp, name, countp, ...) \
|
||||
do { \
|
||||
covcontextp->_inserti(countp); \
|
||||
covcontextp->_insertf(__FILE__, __LINE__); \
|
||||
covcontextp->_insertp("hier", name(), __VA_ARGS__); \
|
||||
auto const ccontextp = covcontextp; \
|
||||
ccontextp->_inserti(countp); \
|
||||
ccontextp->_insertf(__FILE__, __LINE__); \
|
||||
ccontextp->_insertp("hier", name, __VA_ARGS__); \
|
||||
} while (false)
|
||||
|
||||
//=============================================================================
|
||||
|
@ -324,13 +324,14 @@ class EmitCImp final : EmitCFunc {
|
||||
// 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(), count32p,");
|
||||
puts("VL_COVER_INSERT(vlSymsp->_vm_contextp__->coveragep(), VerilatedModule::name(), "
|
||||
"count32p,");
|
||||
puts(" \"filename\",filenamep,");
|
||||
puts(" \"lineno\",lineno,");
|
||||
puts(" \"column\",column,\n");
|
||||
// Need to move hier into scopes and back out if do this
|
||||
// puts( "\"hier\",std::string{vlSymsp->name()} + hierp,");
|
||||
puts("\"hier\",std::string{name()} + hierp,");
|
||||
puts("\"hier\",std::string{VerilatedModule::name()} + hierp,");
|
||||
puts(" \"page\",pagep,");
|
||||
puts(" \"comment\",commentp,");
|
||||
puts(" (linescovp[0] ? \"linescov\" : \"\"), linescovp);\n");
|
||||
|
@ -36,7 +36,7 @@ void hier_insert(VerilatedCovContext* covContextp, uint64_t* countp, const char*
|
||||
const char* peri) {
|
||||
// This needs to be a function at one line number so all of the
|
||||
// line numbers for coverage are constant, otherwise instances won't combine.
|
||||
VL_COVER_INSERT(covContextp, countp, "hier", hierp, "per_instance", peri);
|
||||
VL_COVER_INSERT(covContextp, name(), countp, "hier", hierp, "per_instance", peri);
|
||||
}
|
||||
|
||||
int main() {
|
||||
@ -45,9 +45,9 @@ int main() {
|
||||
|
||||
VerilatedCovContext* covContextp = Verilated::defaultContextp()->coveragep();
|
||||
|
||||
VL_COVER_INSERT(covContextp, &covers[0], "comment", "kept_one");
|
||||
VL_COVER_INSERT(covContextp, &coverw[0], "comment", "kept_two");
|
||||
VL_COVER_INSERT(covContextp, &coverw[1], "comment", "lost_three");
|
||||
VL_COVER_INSERT(covContextp, name(), &covers[0], "comment", "kept_one");
|
||||
VL_COVER_INSERT(covContextp, name(), &coverw[0], "comment", "kept_two");
|
||||
VL_COVER_INSERT(covContextp, name(), &coverw[1], "comment", "lost_three");
|
||||
|
||||
hier_insert(covContextp, &coverw[2], "top.a0.pi", "0");
|
||||
hier_insert(covContextp, &coverw[3], "top.a1.pi", "0");
|
||||
|
@ -11,6 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
|
||||
scenarios(simulator => 1);
|
||||
|
||||
compile(
|
||||
verilator_flags2 => ['--coverage'],
|
||||
);
|
||||
|
||||
execute(
|
||||
|
Loading…
Reference in New Issue
Block a user