changeset 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 62e8a8833e39
children b5549258b98b
files cpu_dsl.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
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)