Rename tdata[0-2] to tdata[1-3].
authorTim Newsome <tim@sifive.com>
Wed, 31 Aug 2016 22:51:58 +0000 (15:51 -0700)
committerTim Newsome <tim@sifive.com>
Wed, 31 Aug 2016 22:51:58 +0000 (15:51 -0700)
Add timing bit (but it doesn't do anything).
Implement dmode bit.

riscv/processor.cc
riscv/processor.h

index 04d483c613459c6e70526cfe5ada567534dc498a..57823f536a0f4c9d808635c20fa54ba627314fbd 100644 (file)
@@ -381,12 +381,20 @@ void processor_t::set_csr(int which, reg_t val)
     case CSR_MSCRATCH: state.mscratch = val; break;
     case CSR_MCAUSE: state.mcause = val; break;
     case CSR_MBADADDR: state.mbadaddr = val; break;
-    case CSR_TSELECT: state.tselect = val; break;
+    case CSR_TSELECT:
+      if (val < state.num_triggers) {
+        state.tselect = val;
+      }
+      break;
     case CSR_TDATA1:
-      if (state.tselect < state.num_triggers) {
+      {
         mcontrol_t *mc = &state.mcontrol[state.tselect];
+        if (mc->dmode && !state.dcsr.cause) {
+          throw trap_illegal_instruction();
+        }
         mc->dmode = get_field(val, MCONTROL_DMODE(xlen));
         mc->select = get_field(val, MCONTROL_SELECT);
+        mc->timing = get_field(val, MCONTROL_TIMING);
         mc->action = (mcontrol_action_t) get_field(val, MCONTROL_ACTION);
         mc->chain = get_field(val, MCONTROL_CHAIN);
         mc->match = (mcontrol_match_t) get_field(val, MCONTROL_MATCH);
@@ -403,7 +411,7 @@ void processor_t::set_csr(int which, reg_t val)
       break;
     case CSR_TDATA2:
       if (state.tselect < state.num_triggers) {
-        state.tdata1[state.tselect] = val;
+        state.tdata2[state.tselect] = val;
       }
       break;
     case CSR_DCSR:
@@ -518,6 +526,7 @@ reg_t processor_t::get_csr(int which)
         v = set_field(v, MCONTROL_DMODE(xlen), mc->dmode);
         v = set_field(v, MCONTROL_MASKMAX(xlen), mc->maskmax);
         v = set_field(v, MCONTROL_SELECT, mc->select);
+        v = set_field(v, MCONTROL_TIMING, mc->timing);
         v = set_field(v, MCONTROL_ACTION, mc->action);
         v = set_field(v, MCONTROL_CHAIN, mc->chain);
         v = set_field(v, MCONTROL_MATCH, mc->match);
@@ -535,7 +544,7 @@ reg_t processor_t::get_csr(int which)
       break;
     case CSR_TDATA2:
       if (state.tselect < state.num_triggers) {
-        return state.tdata1[state.tselect];
+        return state.tdata2[state.tselect];
       } else {
         return 0;
       }
index 2eac770ffa160fd578d49d95aaccb22b60b35852..d5e8bc05a3841392423d5b81c7c60728766250e9 100644 (file)
@@ -65,9 +65,10 @@ typedef enum
 typedef struct
 {
   uint8_t type;
+  bool dmode;
   uint8_t maskmax;
   bool select;
-  bool dmode;
+  bool timing;
   mcontrol_action_t action;
   bool chain;
   mcontrol_match_t match;
@@ -117,7 +118,7 @@ struct state_t
   dcsr_t dcsr;
   reg_t tselect;
   mcontrol_t mcontrol[num_triggers];
-  reg_t tdata1[num_triggers];
+  reg_t tdata2[num_triggers];
 
   uint32_t fflags;
   uint32_t frm;
@@ -231,42 +232,43 @@ public:
 
       switch (state.mcontrol[i].match) {
         case MATCH_EQUAL:
-          if (value != state.tdata1[i])
+          if (value != state.tdata2[i])
             continue;
           break;
         case MATCH_NAPOT:
           {
-            reg_t mask = ~((1 << cto(state.tdata1[i])) - 1);
-            if ((value & mask) != (state.tdata1[i] & mask))
+            reg_t mask = ~((1 << cto(state.tdata2[i])) - 1);
+            if ((value & mask) != (state.tdata2[i] & mask))
               continue;
           }
           break;
         case MATCH_GE:
-          if (value < state.tdata1[i])
+          if (value < state.tdata2[i])
             continue;
           break;
         case MATCH_LT:
-          if (value >= state.tdata1[i])
+          if (value >= state.tdata2[i])
             continue;
           break;
         case MATCH_MASK_LOW:
           {
-            reg_t mask = state.tdata1[i] >> (xlen/2);
-            if ((value & mask) != (state.tdata1[i] & mask))
+            reg_t mask = state.tdata2[i] >> (xlen/2);
+            if ((value & mask) != (state.tdata2[i] & mask))
               continue;
           }
           break;
         case MATCH_MASK_HIGH:
           {
-            reg_t mask = state.tdata1[i] >> (xlen/2);
-            if (((value >> (xlen/2)) & mask) != (state.tdata1[i] & mask))
+            reg_t mask = state.tdata2[i] >> (xlen/2);
+            if (((value >> (xlen/2)) & mask) != (state.tdata2[i] & mask))
               continue;
           }
           break;
       }
 
-      if (!state.mcontrol[i].chain)
+      if (!state.mcontrol[i].chain) {
         return i;
+      }
       chain_ok = true;
     }
     return -1;