Chapter 7. Processor

The processor is a device that can execute a sequence of instructions stored in memory. These instructions may require the use of registers (small amounts of internal memory). They may also require reading from and writing to memory.

The periodicity of instruction execution is controlled by a clock telling to the processor when to perform a cycle. A cycle a part of an instruction : decoding the instruction, fetching data from memory, writing to memory and so on. The number of cycles for an instruction depends on its complexity.

The processor can also react to some external signals like reset signal and interrupt request. These signals are usually emitted by peripherals.

So, a processor has three interactions with outside world :

In Vinace, processors are represented by classes deriving from CProcessor class.

To create a new processor, a child class must be created and the following methods have to be implemented :

Constructor: the CProcessor constructor takes two parameters : the memory to be linked to the processor and a number of signals. The child class constructor should call the CProcessor constructor with a given number of signals. This is the number of different possible signals. For example, for a processor having only a reset signal, this number is 1.

reset(): this method is supposed to reset the processor state. It is called once when the processor is instantiated. It is the child class responsibility to connect any reset signal to this method.

process_instruction(): this method is supposed to process the next instruction. It is called by cycle() once the cycles of the previous instruction have been finished. process_instruction() should increase the cycles member of the amount of cycles corresponding to the instruction.

process_signals(): this method is supposed to process signals. It is called by cycle(). It should return false if a signal has been processed and true if there was no signal to process. In that case, cycle() calls then process_instruction.