start to add in independent execution into ISACaller
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 17 Jun 2020 14:20:35 +0000 (15:20 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 17 Jun 2020 14:20:35 +0000 (15:20 +0100)
src/soc/decoder/isa/caller.py
src/soc/fu/compunits/test/test_compunit.py

index 77cb681599ccf58078906b7f6dfd9f5bad00e57c..504ab94a69e4960184a925e24e707f2de5e923d0 100644 (file)
@@ -214,7 +214,8 @@ class ISACaller:
     # respect_pc - tracks the program counter.  requires initial_insns
     def __init__(self, decoder2, regfile, initial_sprs=None, initial_cr=0,
                        initial_mem=None, initial_msr=0,
-                       initial_insns=None, respect_pc=False):
+                       initial_insns=None, respect_pc=False,
+                       disassembly=None):
 
         self.respect_pc = respect_pc
         if initial_sprs is None:
@@ -225,6 +226,7 @@ class ISACaller:
             initial_insns = {}
             assert self.respect_pc == False, "instructions required to honor pc"
 
+
         # "fake program counter" mode (for unit testing)
         if not respect_pc:
             if isinstance(initial_mem, tuple):
@@ -232,9 +234,15 @@ class ISACaller:
             else:
                 self.fake_pc = 0
 
+        # disassembly: we need this for now (not given from the decoder)
+        self.disassembly = {}
+        if disassembly:
+            for i, code in enumerate(disassembly):
+                self.disassembly[i*4 + self.fake_pc] = code
+
         self.gpr = GPR(decoder2, regfile)
         self.mem = Mem(row_bytes=8, initial_mem=initial_mem)
-        self.insns = Mem(row_bytes=4, initial_mem=initial_insns)
+        self.imem = Mem(row_bytes=4, initial_mem=initial_insns)
         self.pc = PC()
         self.spr = SPR(decoder2, initial_sprs)
         self.msr = SelectableInt(initial_msr, 64) # underlying reg
@@ -369,8 +377,6 @@ class ISACaller:
             so = so | ov
             self.spr['XER'][XER_bits['SO']] = so
 
-
-
     def handle_comparison(self, outputs):
         out = outputs[0]
         out = exts(out.value, out.bits)
@@ -385,6 +391,18 @@ class ISACaller:
         self.namespace['NIA'] = SelectableInt(pc_val, 64)
         self.pc.update(self.namespace)
 
+    def execute_one(self):
+        if self.respect_pc:
+            pc = self.pc.CIA.value
+        else:
+            pc = self.fake_pc
+            self.fake_pc += 4
+        ins = yield self.imem.ld(pc, 4, False)
+        yield self.pdecode2.dec.raw_opcode_in.eq(ins)
+        yield self.pdecode2.dec.bigendian.eq(0)  # little / big?
+        opname = code.split(' ')[0]
+        yield from call(opname)
+
     def call(self, name):
         # TODO, asmregs is from the spec, e.g. add RT,RA,RB
         # see http://bugs.libre-riscv.org/show_bug.cgi?id=282
index 749fdadf5d7a4c30d5cd2396f28495ae030e6bca..5b03e2da21fc3788dfbe35aceb3aaa0e8b970a96 100644 (file)
@@ -197,7 +197,7 @@ class TestRunner(FHDLTestCase):
                     ins, code = instructions[index]
                     yield simdec2.dec.raw_opcode_in.eq(ins)
 
-                    print("0x{:X}".format(ins & 0xffffffff))
+                    print("0x{:X} 0x{:X}".format(index*4, ins & 0xffffffff))
                     print(code)
 
                     # ask the decoder to decode this binary data (endian'd)