diff cpu_dsl.py @ 2716:033d8d4308e3

Fix enough issues in uPD78K/II core so that LaserActive firmware regularly polls front-panel button state
author Michael Pavone <pavone@retrodev.com>
date Sat, 12 Jul 2025 22:25:20 -0700
parents d30e7f605ff8
children 4f88822e6a5d
line wrap: on
line diff
--- a/cpu_dsl.py	Fri Jul 11 10:55:33 2025 -0700
+++ b/cpu_dsl.py	Sat Jul 12 22:25:20 2025 -0700
@@ -2462,6 +2462,8 @@
 	info = {}
 	line_num = 0
 	cur_object = None
+	usedInstNames = set()
+	usedBitPatterns = set()
 	for line in f:
 		line_num += 1
 		line,_,comment = line.partition('#')
@@ -2530,7 +2532,15 @@
 						else:
 							fields[char] = (curbit, 1)
 					curbit -= 1
-				cur_object = Instruction(value, fields, name.strip())
+				name = name.strip()
+				if name in usedInstNames:
+					raise Exception(f'Instruction name {name} was already used!')
+				usedInstNames.add(name)
+				pattern = (table, bitpattern)
+				if pattern in usedBitPatterns:
+					raise Exception(f'Pattern {pattern} was already defined')
+				usedBitPatterns.add(pattern)
+				cur_object = Instruction(value, fields, name)
 				instructions.setdefault(table, []).append(cur_object)
 			elif line.strip() == 'regs':
 				if registers is None: