diff cpu_dsl.py @ 1883:9ab5184811ea

Implement interrupts in call dispatch mode in CPU DSL
author Michael Pavone <pavone@retrodev.com>
date Sat, 21 Sep 2019 10:48:10 -0700
parents 0c1491818f4b
children 1dae90605199
line wrap: on
line diff
--- a/cpu_dsl.py	Tue Sep 17 21:04:17 2019 -0700
+++ b/cpu_dsl.py	Sat Sep 21 10:48:10 2019 -0700
@@ -1593,7 +1593,12 @@
 			pieces.append('\n\t{sync}(context, target_cycle);'.format(sync=self.sync_cycle))
 			pieces.append('\n\twhile (context->cycles < target_cycle)')
 			pieces.append('\n\t{')
-			#TODO: Handle interrupts in call dispatch mode
+			if self.interrupt in self.subroutines:
+				pieces.append('\n\t\tif (context->cycles >= context->sync_cycle) {')
+				self.meta = {}
+				self.temp = {}
+				self.subroutines[self.interrupt].inline(self, [], pieces, otype, None)
+				pieces.append('\n\t\t}')
 			self.meta = {}
 			self.temp = {}
 			self.subroutines[self.body].inline(self, [], pieces, otype, None)