add trace-activation for a #defined number of cycles
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 11 Jan 2022 07:43:07 +0000 (07:43 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 11 Jan 2022 07:43:07 +0000 (07:43 +0000)
verilator/microwatt-verilator.cpp

index 836540c497f07a9f624dc55e344f9fb74c48e6e1..f714d4d702d73bd316b1b2b48f9b8e8401cf4c13 100644 (file)
@@ -81,6 +81,7 @@ static void mem_write(unsigned char *mem,
 #define TRIGGER_ENABLE
 #define TRIGGER_NIA 0xa580
 #define TRIGGER_INSN 0xe8628008
+#define TRIGGER_COUNTDOWN 200000
 //#define TRIGGER_NIA 0x335c
 //#define TRIGGER_INSN 0x3c400001
 
@@ -184,6 +185,7 @@ int main(int argc, char **argv)
 
     // trace conditions
     bool traceme = true;
+    int trigger_countdown = TRIGGER_COUNTDOWN;
 #ifdef TRIGGER_ENABLE
     traceme = false;
 #endif
@@ -213,6 +215,13 @@ int main(int argc, char **argv)
                 traceme = true;
                 fprintf(dump, "trace trigger enabled\n");
             }
+            // tracing active for only TRIGGER_COUNTDOWN cycles
+            if (traceme) {
+                trigger_countdown--;
+                if (trigger_countdown == 0) {
+                    traceme = false;
+                }
+            }
 #endif
             fprintf(dump, "pc %8x insn %8x msr %16lx",
                                 top->nia, top->insn, top->msr_o);