From: Luke Kenneth Casson Leighton Date: Fri, 21 Jan 2022 13:03:41 +0000 (+0000) Subject: add trigger occurrences option in microwatt-verilator. useful for tracing X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2ad928c637e25a8f0573848391a608474762ae83;p=microwatt.git add trigger occurrences option in microwatt-verilator. useful for tracing loops or just when something goes wrong only on the 3rd, 4th or Nth call --- diff --git a/verilator/microwatt-verilator.cpp b/verilator/microwatt-verilator.cpp index f714d4d..ed6661a 100644 --- a/verilator/microwatt-verilator.cpp +++ b/verilator/microwatt-verilator.cpp @@ -79,9 +79,21 @@ static void mem_write(unsigned char *mem, #define BRAM_DEBUG #define TRIGGER_ENABLE -#define TRIGGER_NIA 0xa580 -#define TRIGGER_INSN 0xe8628008 -#define TRIGGER_COUNTDOWN 200000 +#define TRIGGER_OCCURENCES 1 +#define TRIGGER_COUNTDOWN 10000 +//#define TERMINATE_AT_COUNTDOWN +//#define TRIGGER_NIA 0xa580 +//#define TRIGGER_INSN 0xe8628008 +//#define TRIGGER_NIA 0x900 +//#define TRIGGER_INSN 0x7db243a6 +//define TRIGGER_NIA 0x603348 +//#define TRIGGER_INSN 0x7c842a14 +#define TRIGGER_NIA 0xc00000000042f788 +#define TRIGGER_INSN 0x7c0802a6 +//#define TRIGGER_NIA 0xc000000000077b90 +//#define TRIGGER_NIA 0xc0000000000cf600 +//#define TRIGGER_INSN 0x38210040 +//#define TRIGGER_INSN 0xb3be000a //#define TRIGGER_NIA 0x335c //#define TRIGGER_INSN 0x3c400001 @@ -186,6 +198,7 @@ int main(int argc, char **argv) // trace conditions bool traceme = true; int trigger_countdown = TRIGGER_COUNTDOWN; + int trigger_occurrences = TRIGGER_OCCURENCES; #ifdef TRIGGER_ENABLE traceme = false; #endif @@ -212,23 +225,31 @@ int main(int argc, char **argv) if (top->nia_req) { #ifdef TRIGGER_ENABLE if ((top->nia == TRIGGER_NIA) && (top->insn == TRIGGER_INSN)) { - traceme = true; - fprintf(dump, "trace trigger enabled\n"); + if (trigger_occurrences == 1) { + traceme = true; + fprintf(dump, "trace trigger enabled\n"); + } + if (trigger_occurrences != 0) { + --trigger_occurrences; + } } // tracing active for only TRIGGER_COUNTDOWN cycles if (traceme) { - trigger_countdown--; + --trigger_countdown; if (trigger_countdown == 0) { traceme = false; +#ifdef TERMINATE_AT_COUNTDOWN + break; +#endif } } #endif - fprintf(dump, "pc %8x insn %8x msr %16lx", + fprintf(dump, "pc %16lx insn %8x msr %16lx", top->nia, top->insn, top->msr_o); } if (top->ldst_req) { if (!top->nia_req) { - fprintf(dump, "pc %-8s insn %-8s msr %-16s", "", "", ""); + fprintf(dump, "pc %-16s insn %-8s msr %-16s", "", "", ""); } fprintf(dump, " ldst %16lx", top->ldst_addr); }