Working test_add
authorMichael Nolan <mtnolan2640@gmail.com>
Sat, 4 Apr 2020 20:40:32 +0000 (16:40 -0400)
committerMichael Nolan <mtnolan2640@gmail.com>
Sat, 4 Apr 2020 20:54:21 +0000 (16:54 -0400)
src/soc/decoder/isa/caller.py
src/soc/decoder/isa/test_caller.py

index a75dc3fa7e4a127e273d1fa981d6967f6a693c8c..24ce2a63e05b5a53144ed3ba0a6350a60dd1d396 100644 (file)
@@ -78,6 +78,10 @@ class ISACaller:
     def memassign(self, ea, sz, val):
         self.mem.memassign(ea, sz, val)
 
+    def prep_namespace(self):
+        si = yield self.decoder.SI
+        self.namespace.SI = SelectableInt(si, bits=16)
+
     def call(self, name):
         function, read_regs, uninit_regs, write_regs = self.instrs[name]
         input_names = create_args(read_regs | uninit_regs)
@@ -86,12 +90,17 @@ class ISACaller:
         inputs = []
         for name in input_names:
             regnum = yield getattr(self.decoder, name)
-            print(regnum)
+            print('reading reg %d' % regnum)
             inputs.append(self.gpr(regnum))
         print(inputs)
         results = function(self, *inputs)
         print(results)
 
+        output_names = create_args(write_regs)
+        for name, output in zip(output_names, results):
+            regnum = yield getattr(self.decoder, name)
+            print('writing reg %d' % regnum)
+            self.gpr[regnum] = output
 
 
 def inject():
index b958795c147f3ca5267e67a252eb58534a867948..fb227396bfeb8da0b771ca4708293032ae3ac16f 100644 (file)
@@ -80,11 +80,13 @@ class DecoderTestCase(FHDLTestCase):
         initial_regs[3] = 0x1234
         initial_regs[2] = 0x4321
         with Program(lst) as program:
-            self.run_test_program(program, initial_regs)
+            sim = self.run_test_program(program, initial_regs)
+            self.assertEqual(sim.gpr(1), SelectableInt(0x5555, 64))
 
     def run_test_program(self, prog, initial_regs):
         simulator = self.run_tst(prog, initial_regs)
         print(simulator.gpr)
+        return simulator
 
 if __name__ == "__main__":
     unittest.main()