sorting out trap fastregs
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 4 Jul 2020 17:44:23 +0000 (18:44 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 4 Jul 2020 17:44:23 +0000 (18:44 +0100)
src/soc/decoder/isa/caller.py
src/soc/decoder/power_decoder2.py
src/soc/fu/test/common.py

index a57194bec41ab28490d0df91d75362b7f62d88f8..17e9ed94078e43d02e61efbea57e682d50be96d6 100644 (file)
@@ -211,7 +211,10 @@ class SPR(dict):
         if key in self:
             res = dict.__getitem__(self, key)
         else:
-            info = spr_dict[key]
+            if isinstance(key, int):
+                info = spr_dict[key]
+            else:
+                info = spr_byname[key]
             dict.__setitem__(self, key, SelectableInt(0, info.length))
             res = dict.__getitem__(self, key)
         print ("spr returning", key, res)
index aa9fcaecae14b6bf38099e153dd9bf0aa0276fdb..1830c5f73e91b47a691c3c8d45bb97182ac7e1b0 100644 (file)
@@ -312,6 +312,11 @@ class DecodeOut(Elaboratable):
             comb += self.fast_out.data.eq(FastRegs.SRR0) # constant: SRR0
             comb += self.fast_out.ok.eq(1)
 
+        # TRAP fast1 = SRR0
+        with m.If(op.internal_op == InternalOp.OP_TRAP):
+            comb += self.fast_out.data.eq(FastRegs.SRR0) # constant: SRR0
+            comb += self.fast_out.ok.eq(1)
+
         return m
 
 
@@ -351,6 +356,11 @@ class DecodeOut2(Elaboratable):
                 comb += self.fast_out.data.eq(FastRegs.SRR1) # constant: SRR1
                 comb += self.fast_out.ok.eq(1)
 
+        # TRAP fast2 = SRR1
+        with m.If(op.internal_op == InternalOp.OP_TRAP):
+            comb += self.fast_out.data.eq(FastRegs.SRR1) # constant: SRR1
+            comb += self.fast_out.ok.eq(1)
+
         return m
 
 
@@ -587,7 +597,7 @@ class PowerDecode2(Elaboratable):
         comb += e.read_fast1.eq(dec_a.fast_out)
         comb += e.read_fast2.eq(dec_b.fast_out)
         comb += e.write_fast1.eq(dec_o.fast_out)
-        comb += e.write_fast1.eq(dec_o2.fast_out)
+        comb += e.write_fast2.eq(dec_o2.fast_out)
 
         comb += e.read_cr1.eq(dec_cr_in.cr_bitfield)
         comb += e.read_cr2.eq(dec_cr_in.cr_bitfield_b)
index bd0e948effb75d9c37cb63103b87679bdb25e1b3..1143e8958fc642ebbd7de80299b3c7f9f149e9ba 100644 (file)
@@ -257,16 +257,16 @@ class ALUHelpers:
         if ok:
             spr_num = yield dec2.e.write_fast2.data
             spr_num = fast_reg_to_spr(spr_num)
-            spr_name = spr_dict[spr_num]
-            res['fast2'] = sim.spr[spr_name]
+            spr_name = spr_dict[spr_num].SPR
+            res['fast2'] = sim.spr[spr_name].value
 
     def get_wr_fast_spr1(res, sim, dec2):
         ok = yield dec2.e.write_fast1.ok
         if ok:
             spr_num = yield dec2.e.write_fast1.data
             spr_num = fast_reg_to_spr(spr_num)
-            spr_name = spr_dict[spr_num]
-            res['fast1'] = sim.spr[spr_name]
+            spr_name = spr_dict[spr_num].SPR
+            res['fast1'] = sim.spr[spr_name].value
 
     def get_wr_sim_xer_ca(res, sim, dec2):
         cry_out = yield dec2.e.output_carry