This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:multiasm:cs:chapter_3_4 [2025/01/04 11:26] – ktokarz | en:multiasm:cs:chapter_3_4 [2025/12/02 11:05] (current) – [Execution unit] ktokarz | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ======Components of Processor: Registers, ALU, Bus Control, Instruction Decoder |
| - | It is not only the whole computer that can have a different architecture. This also touches processors. There are two main internal architectures of processors: CISC and RISC. CISC means Complex Instruction Set Computer while RISC stands | + | From our perspective, |
| - | Complex instructions mean that the typical single instruction | + | <figure procblock> |
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| - | Additionally, there are differences in the general-purpose registers. In CISC the number of registers | + | ===== Control unit ===== |
| - | < | + | The function of the control unit, also known as the instruction processor, is to fetch, decode and execute instructions. It also generates signals to the execution unit if the instruction being executed requires so. It is a synchronous and sequential unit. Synchronous |
| - | operation arg1, arg2 ; Example: arg1 = arg1 + arg2 | + | A typical control unit contains some essential elements: |
| - | </ | + | * Instruction register (IR). |
| - | In such a situation //arg1// is one of a source and also a destination - place for the result. It destroys the original | + | * Instruction decoder. |
| - | < | + | * Program counter (PC)/instruction pointer (IP). |
| - | operation arg1, arg2, arg3 ; Example: arg3 = arg1 + arg2 | + | * Stack pointer (SP). |
| - | </ | + | * Bus interface unit. |
| - | In such an approach two arguments are the source and the third one is the destination - original arguments | + | * Interrupt controller. |
| - | The table summarises the difference between CISC and RISC processors. | + | Elements of the control unit are shown in Fig {{ref> |
| - | ^ Feature | + | <figure controlunit> |
| - | | Instructions | + | {{ : |
| - | | Registers | + | < |
| - | | Number | + | </ |
| - | | Calculations | + | |
| - | | Addressing modes | Complex | + | The control unit executes instructions in a few steps: |
| - | | Non destroying | + | * Generates the address |
| - | | Examples | + | |
| + | * Decodes instructions. | ||
| + | * Generates signals to the execution unit or executes instructions internally. | ||
| + | |||
| + | In detail, the process looks as follows: | ||
| + | - The control unit takes the address of the instruction to be executed from a special | ||
| + | - Memory takes the code of instruction from the provided address and sends it to the processor using a data bus. | ||
| + | - The processor stores the instruction code in the instruction register and, based on the bit pattern, interprets what to do next. | ||
| + | - If the instruction requires the execution unit operation, the control unit generates signals to control it. In cooperation with the execution unit, it can also read data from or write data to the memory. | ||
| + | |||
| + | The control unit works according to the clock signal generator cycles known as main clock cycles. With every clock cycle, some internal operations are performed. One such operation is reading or writing the memory, which sometimes requires more than a single clock cycle. Single memory access is known as a machine cycle. As instruction execution sometimes requires more than one memory access and other actions, the execution of the whole instruction is named an instruction cycle. Summarising, | ||
| + | |||
| + | The control unit also accepts input signals from peripherals, | ||
| + | < | ||
| + | Although the stack pointer is not implemented in all modern processors, every processor has some mechanism for storing the returning address. | ||
| + | </ | ||
| + | ===== Execution unit ===== | ||
| + | |||
| + | An execution unit, also known as the data processor, executes | ||
| + | * Arithmetic logic unit (ALU). | ||
| + | * Accumulator and set of registers, | ||
| + | * Flags register, | ||
| + | * Temporal register. | ||
| + | |||
| + | The arithmetic logic unit (ALU) is the element that performs logical and arithmetical calculations. It uses data coming from registers, the accumulator or from memory. Data coming from memory for arithmetic and logic instructions is stored in the temporal register. The result of calculations is stored back in the accumulator, | ||
| + | Besides the result, ALU also returns some additional information about the calculations. It modifies the bits in the flag register, which comprises flags that are modified according to the results from arithmetic and logical operations. For example, if the result of the addition operation is too large to be stored in the resulting argument, the carry flag is set to indicate such a situation. | ||
| + | |||
| + | Typically, the flags register includes: | ||
| + | * Carry flag, set in case a carry or borrow occurs. | ||
| + | * Sign flag, indicating whether the result is negative. | ||
| + | * Zero flag, set in case the result is zero. | ||
| + | * Auxiliary Carry flag used in BCD operations. | ||
| + | * Parity flag, which indicates whether the result has an even number of ones. | ||
| + | |||
| + | The flags are used as conditions for decision-making instructions (like //if// statements in some high-level languages). | ||
| + | The flags register can also implement some control flags to enable/ | ||
| + | |||
| + | ===== Registers ===== | ||
| + | |||
| + | Registers are memory elements which are placed logically and physically very close to the arithmetic logic unit. It makes them the fastest memory in the whole computer. They are sometimes called scratch registers, and the set of registers is called the register file. | ||
| + | |||
| + | As we mentioned in the chapter about CISC and RISC processors, in CISC processors, registers are specialised, | ||
| + | |||
| + | <figure CISCexeunit> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | A typical RISC execution unit does not have a specialised accumulator register. It implements the set of scratch registers as shown in Fig {{ref> | ||
| + | |||
| + | <figure RISCexeunit> | ||
| + | {{ : | ||
| + | < | ||
| + | </ | ||