partially update spike to newer debug spec
[riscv-isa-sim.git] / riscv / processor.h
index ab3af22930ab64e321d78d3e83a995f62a250be8..41d778e589263a1cbfb43ad51fb0263c65e0343f 100644 (file)
@@ -45,7 +45,6 @@ typedef struct
 
 typedef enum
 {
-  ACTION_NONE = MCONTROL_ACTION_NONE,
   ACTION_DEBUG_EXCEPTION = MCONTROL_ACTION_DEBUG_EXCEPTION,
   ACTION_DEBUG_MODE = MCONTROL_ACTION_DEBUG_MODE,
   ACTION_TRACE_START = MCONTROL_ACTION_TRACE_START,
@@ -189,7 +188,8 @@ public:
 
   // When true, display disassembly of each instruction that's executed.
   bool debug;
-  void update_slow_path();
+  // When true, take the slow simulation path.
+  bool slow_path();
 
   // Return the index of a trigger that matched, or -1.
   inline int trigger_match(trigger_operation_t operation, reg_t address, reg_t data)
@@ -197,18 +197,22 @@ public:
     if (state.dcsr.cause)
       return -1;
 
-    bool chain_ok = false;
+    bool chain_ok = true;
 
     for (unsigned int i = 0; i < state.num_triggers; i++) {
-      if (state.mcontrol[i].action == ACTION_NONE ||
-          (operation == OPERATION_EXECUTE && !state.mcontrol[i].execute) ||
+      if (!chain_ok) {
+        chain_ok |= !state.mcontrol[i].chain;
+        continue;
+      }
+
+      if ((operation == OPERATION_EXECUTE && !state.mcontrol[i].execute) ||
           (operation == OPERATION_STORE && !state.mcontrol[i].store) ||
           (operation == OPERATION_LOAD && !state.mcontrol[i].load) ||
           (state.prv == PRV_M && !state.mcontrol[i].m) ||
           (state.prv == PRV_H && !state.mcontrol[i].h) ||
           (state.prv == PRV_S && !state.mcontrol[i].s) ||
           (state.prv == PRV_U && !state.mcontrol[i].u)) {
-        goto next;
+        continue;
       }
 
       reg_t value;
@@ -227,54 +231,42 @@ public:
       switch (state.mcontrol[i].match) {
         case MATCH_EQUAL:
           if (value != state.tdata1[i])
-            goto next;
+            continue;
           break;
         case MATCH_NAPOT:
           {
             reg_t mask = ~((1 << cto(state.tdata1[i])) - 1);
             if ((value & mask) != (state.tdata1[i] & mask))
-              goto next;
+              continue;
           }
           break;
         case MATCH_GE:
           if (value < state.tdata1[i])
-            goto next;
+            continue;
           break;
         case MATCH_LT:
           if (value >= state.tdata1[i])
-            goto next;
+            continue;
           break;
         case MATCH_MASK_LOW:
           {
             reg_t mask = state.tdata1[i] >> (xlen/2);
             if ((value & mask) != (state.tdata1[i] & mask))
-              goto next;
+              continue;
           }
           break;
         case MATCH_MASK_HIGH:
           {
             reg_t mask = state.tdata1[i] >> (xlen/2);
             if (((value >> (xlen/2)) & mask) != (state.tdata1[i] & mask))
-              goto next;
+              continue;
           }
           break;
       }
 
-      if (state.mcontrol[i].chain && !chain_ok) {
-        goto next;
-      }
-
-      // We got here, so this trigger matches. But if the next trigger has
-      // chain set, then we can't perform the action.
-      if (i+1 < state.num_triggers && state.mcontrol[i+1].chain) {
-        chain_ok = true;
-        continue;
-      } else {
+      if (!state.mcontrol[i].chain)
         return i;
-      }
-
-next:
-      chain_ok = false;
+      chain_ok = true;
     }
     return -1;
   }
@@ -294,8 +286,6 @@ private:
   std::string isa_string;
   bool histogram_enabled;
   bool halt_on_reset;
-  // When true, take the slow simulation path.
-  bool slow_path;
 
   std::vector<insn_desc_t> instructions;
   std::map<reg_t,uint64_t> pc_histogram;