CPU INSTRUCTION CYCLE
an instruction cycle consists of two steps:
(i) the CPU fetches an instruction from main memory, and (ii) the CPU executes the instruction
types of actions by cpu
* Transfer of data between CPU and memory (i.e. read from memory,and write to memory). • Transfer of data between CPU and some I/O devices (e.g. read from a device, write to a device). • Data processing (i.e. arithmetic and logical operations on data). • Control: An instruction may specify that the sequence of execution be altered. For example, an instruction I1at address 149 may tell the CPU to execute an instruction stored at address 182. When I1is executed, the PC will be set to 182. Thus, on the next instruction cycle, the CPU will fetch the instruction at address 182, rather than the instruction at address 1
Reading from memory
1. The address of the required cell is put in the MAR. 2. The MAR is connected to the address bus, so the address - a set of electrical signals 1s and 0s - is put onto the address bus. 3. The read/write line in the control bus is set to indicate a READoperation. 4. The required cell in main memory is activated, so the content of the cell - an instruction or datum - is put on the data bus. 5. The MBR is connected to the data bus, so the instruction/datum is stored in the MBR.
when pc increment
After the next instruction is fetched and executed, the processor increments the PC, so that the PC will contain the address of the next instruction in the sequence
control unit functions in case of reading from memory
In Step 1, the control unit sends a control signal that opens the gates between the PC and the MAR, allowing the content of the PC into the MAR. In Step 2, a control signal is sent that opens the gates between the MAR and the data bus, allowing the content of the MAR onto the data bus. In Step 3, a READ signal is put on the control bus. In Step 4, the control unit just waits for main memory to react and to put the data on the data bus. In Step 5, the control unit send a control signal that opens the gates, allowing the content of the data bus to be stored in the MBR
cpu interprets action
The CPU interprets the instruction and performs the required action.
where fetched instruction loaded
The fetched instruction is loaded into the instruction register (IR).
Instruction format components
an op-code • one or more operands
The program counter (PC) is used for this purpose
contains the address of the instruction to be fetched next
The op-code
indicates what operation is to be performed
CPU runs the program by
repeatedly performing an instruction cycle
An operand
specifies the thing that is to be operated on. An operand is often an address of a cell where some real datum (number, letter, character, colour, sound pitch, etc.) is stored
example of pc function and its increment
suppose that the PC is set to location 300.5 The CPU will next fetch the instruction at cell 300. When this instruction is fetched and executed, the CPU will fetch and execute instructions stored in cells 301, 302, 303 and so on.6
INSTRUCTION CYCLE mechanism
the CPU fetches an instruction from main memory and then executes it. It then fetches the next instruction and executes it. The CPU repeatedly does this, until it encounters an instruction that halts the computer (or when an unrecoverable error occurs, or the computer is turned off).
an instruction cycle in this simplest case
the fetch-execute cycle
A more detailed instruction cycle six stages
• Fetch instruction (FI): read the next expected instruction into a buffer. • Decode instruction (DI): determine the op-code and the operand. • Calculate operand (CO): calculate the address of the real operand. • Fetch operand (FO): fetch the real operand from main memory. • Execute instruction (EI): perform the indicated operation and store the result in a register. • Write operand (WO): store the result in main memory.
Writing to memory
• The address of the required cell is put in the MAR. • The data to be written are put in the MBR. • The MAR is connected to the address bus, so the address - a set of electrical signals 1s and 0s - is put on to the address bus. • The MBR is connected to the data bus, so the datum - a set of electrical signals 1s and 0s - is put on the data bus. • The read/write line in the control bus is set to indicate a WRITE operation. • The required cell is activated, and the datum on the data bus is written into the cell.