未验证 提交 77701a78 编写于 作者: Y Yinan Xu 提交者: GitHub

Merge pull request #331 from RISCVERS/coverage

Coverage
......@@ -247,6 +247,13 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
diff.wdata = wdata;
diff.wdst = wdst;
#if VM_COVERAGE == 1
// we dump coverage into files at the end
// since we are not sure when an emu will stop
// we distinguish multiple dat files by emu start time
time_t start_time = time(NULL);
#endif
while (!Verilated::gotFinish() && trapCode == STATE_RUNNING) {
if (!(max_cycle > 0 && max_instr > 0 && instr_left_last_cycle >= max_instr /* handle overflow */)) {
trapCode = STATE_LIMIT_EXCEEDED;
......@@ -336,7 +343,7 @@ uint64_t Emulator::execute(uint64_t max_cycle, uint64_t max_instr) {
#endif
#if VM_COVERAGE == 1
save_coverage();
save_coverage(start_time);
#endif
display_trapinfo();
......@@ -370,15 +377,16 @@ inline char* Emulator::waveform_filename(time_t t) {
#if VM_COVERAGE == 1
inline void Emulator::save_coverage(void) {
char *noop_home = getenv("NOOP_HOME");
assert(noop_home != NULL);
inline char* Emulator::coverage_filename(time_t t) {
static char buf[1024];
char *p = timestamp_filename(t, buf);
strcpy(p, ".coverage.dat");
return buf;
}
char buf[1024];
snprintf(buf, 1024, "%s/build/logs", noop_home);
Verilated::mkdir(buf);
snprintf(buf, 1024, "%s/build/logs/coverage.dat", noop_home);
VerilatedCov::write(buf);
inline void Emulator::save_coverage(time_t t) {
char *p = coverage_filename(t);
VerilatedCov::write(p);
}
#endif
......
......@@ -56,11 +56,12 @@ class Emulator {
void display_trapinfo();
inline char* timestamp_filename(time_t t, char *buf);
inline char* snapshot_filename(time_t t);
inline char* coverage_filename(time_t t);
void snapshot_save(const char *filename);
void snapshot_load(const char *filename);
inline char* waveform_filename(time_t t);
#if VM_COVERAGE == 1
inline void save_coverage(void);
inline void save_coverage(time_t t);
#endif
public:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册