def systemCall(self, args, instruction_decoded, **named_args): """args:list -> True""" self.log.buffer('systemCall called', level.FINER) system_call = SystemCall() try: if args[0][:3] == 'DIR': a = int(args[0][3:], 16) result = a except: a = args[0] result = self._register.get_value(a) self.log.buffer('args 0:{0}'.format(a), level.FINEST) system_call.service(result) return True
def __init__(self, pipeline, flags, **objects): # These are the objects which provide data for calculations. self._memory = objects['memory'].get_memory() self._registers = objects['registers'].get_registers() self._api = objects['api'].get_api_reference(self) self._isa = objects['instructions'] # System provides Signals self.system_call = SystemCall() # This data is used in calculations. self._size = self._isa.getSize() self._pc = self._registers.get_pc() self._word_space = self._memory.get_word_spacing() # Pipeline is a stack for storing instructions and data relating # to them. self._pipeline = [] self._pipeline_stages = pipeline self._pipeline_flags = flags # Special flags control some aspects of the processor's behaviour. self.__special_flags = {} # These fields store data for the dubugger. self._breakpoints = [] self._debug = False # This is a list of observers. self.listeners = []
class Pipelined(BaseProcessor): """Pipelined CPU Implementation""" def __init__(self, pipeline, flags, **objects): # These are the objects which provide data for calculations. self._memory = objects['memory'].get_memory() self._registers = objects['registers'].get_registers() self._api = objects['api'].get_api_reference(self) self._isa = objects['instructions'] # System provides Signals self.system_call = SystemCall() # This data is used in calculations. self._size = self._isa.getSize() self._pc = self._registers.get_pc() self._word_space = self._memory.get_word_spacing() # Pipeline is a stack for storing instructions and data relating # to them. self._pipeline = [] self._pipeline_stages = pipeline self._pipeline_flags = flags # Special flags control some aspects of the processor's behaviour. self.__special_flags = {} # These fields store data for the dubugger. self._breakpoints = [] self._debug = False # This is a list of observers. self.listeners = [] def cycle(self): self._log.buffer(self, 'beginning a cycle', level.FINER) # Denotes that incrementation has taken place this cycle. # This is initially false. self.__special_flags['increment'] = False try: for stage in self._pipeline_stages: self._log.buffer(self, 'entering {0} stage'.format(stage), level.FINEST) # A little string transformation to help avoid accidents. stagecall = '_' + stage + '_coordinator' try: # Dispatch to one of the instance's methods. call = getattr(self, stagecall) call(self._pipeline_stages.index(stage)) except AttributeError, e: self._log.buffer(self, 'no such pipeline stage: {:}' .format(stage), level.ERROR) raise e except ArithmeticError: self.system_call.service(16435935) except RegisterReferenceException: self.system_call.service(16435936) except IndexError, e: # Routine, particularly for first cycles. self._log.buffer(self, '{0} found nothing in the pipeline' .format(stage), level.FINEST) self._log.buffer(self, 'leaving {0} stage'.format(stage), level.FINEST)