diff cpu_dsl.py @ 1621:ca158bc091f9

Implement program ROM reads
author Michael Pavone <pavone@retrodev.com>
date Sat, 06 Oct 2018 17:33:15 -0700
parents a172f97d873f
children 44d8c6e61ad4
line wrap: on
line diff
--- a/cpu_dsl.py	Thu Oct 04 19:12:56 2018 -0700
+++ b/cpu_dsl.py	Sat Oct 06 17:33:15 2018 -0700
@@ -676,11 +676,15 @@
 class Registers:
 	def __init__(self):
 		self.regs = {}
+		self.pointers = {}
 		self.regArrays = {}
 		self.regToArray = {}
 	
 	def addReg(self, name, size):
 		self.regs[name] = size
+		
+	def addPointer(self, name, size):
+		self.pointers[name] = size
 	
 	def addRegArray(self, name, size, regs):
 		self.regArrays[name] = (size, regs)
@@ -721,11 +725,16 @@
 		elif len(parts) > 2:
 			self.addRegArray(parts[0], int(parts[1]), parts[2:])
 		else:
-			self.addReg(parts[0], int(parts[1]))
+			if parts[1].startswith('ptr'):
+				self.addPointer(parts[0], int(parts[1][3:]))
+			else:
+				self.addReg(parts[0], int(parts[1]))
 		return self
 
 	def writeHeader(self, otype, hFile):
 		fieldList = []
+		for pointer in self.pointers:
+			hFile.write('\n\tuint{sz}_t *{nm};'.format(nm=pointer, sz=self.pointers[pointer]))
 		for reg in self.regs:
 			if not self.isRegArrayMember(reg):
 				fieldList.append((self.regs[reg], 1, reg))