MicSim/components/caretaker.py
2018-08-31 20:18:08 +02:00

21 lines
630 B
Python

#!/usr/bin/python
class Caretaker:
def __init__(self):
self.objects=dict() # Create empty objects pool
# Add registers to pool
for reg in ["MAR","MDR", "PC", "MBR", "SP","LV","CPP","TOS","OPC","H"]:
self.objects[reg]=0
self.objects["RAM"]=None
def __getitem__(self,key): # TODO: Allow MBRU key and adapt its return value
return(self.objects[key])
def __setitem__(self,key,value):# TODO: Do special treatment for MBR (allow only 2^8 value)
# TODO: Force data to be at most 32 bits longs (Mic-1 architecture constraint)
self.objects[key]=value
def items(self):
return(self.objects.items())