Advertisement

computer function in computer organization


Computer Function

  • The basic function performed by the computer is the execution of a program.
  • A program consists of a set of instructions stored in memory.
  • The processor does the actual work by executing instructions specified in the program.
  • Instruction processing consists of two steps:
  • The processor reads (fetches) instructions from memory one at a time and executes each instruction. (and repeats the fetch cycle)
  • Program execution consists of repeating the steps of instruction fetch and instruction execution. (until the last line of the code)
  • The instruction execution may involve several operations and depends on the nature of the instruction.

Instruction Cycle

The processing required for a single instruction is called an instruction cycle.
Instruction cycle two steps are referred to as the:
1) Fetch cycle 2) Execute cycle
  • Fetch cycle is the process by which a computer retrieves a program instruction from its memory. 
  • Then it determines what actions the instruction dictates, and carries out those actions called execute cycle.
computer organization and architecture

1. Fetch Cycle

  • At the beginning of each instruction cycle, the processor fetches an instruction from memory.
  • A register called the Program Counter (PC) holds the address of the instruction to be fetched next.
  • The processor fetches the instruction from memory location pointed to by PC unless program flow control is altered by a jump instruction.
  • The processor always increments the PC after each instruction fetch, so that it will fetch the next instruction in sequence.
  • The Next instruction is the instruction located at the next higher memory address.

Fetch Example

  • For example, consider a computer in which each instruction occupies one 16-bit word of memory.
  • Assume that the program counter (PC) is set to memory location 300, where the location address (300) refers to a 16-bit word.
  • The processor will next fetch the instruction at location 300.
  • On succeeding instruction cycles, it will fetch instructions from locations 301, 302, 303, and so on.

2. Execute Cycle

  • In ‘Instruction Fetch’ we load the ‘PC (program counter)’ memory location value into the ‘IR (instruction register)’ and increments the PC.
  • The fetched instruction is loaded into a register in the processor known as the Instruction Register (IR).
  • The instruction contains the bits (opcode) that specify the action the processor is to take.
  • The processor interprets the instruction (matches the opcode from its instruction set) and performs the required action.

General Categories of Functions Specified by Computer Instructions

An instruction execution may involve a combination of these actions:
Processor-memory: Data may be transferred from processor to memory or from memory to processor. E.g. move instruction.
Processor-I/O: Data may be transferred to or from a peripheral device by transferring between the processor and an I/O module.
Data processing: The processor may perform some arithmetic or logic operation on data. E.g. Add, Sub, Mul, Div etc.
Control: An instruction may specify that the sequence of execution is altered. E.g. Jump instruction.

Execute Example

  • For example, the processor may fetch an instruction from memory location 149.
  • The location 149 specifies the next instruction to be from location 182. (Jump instruction).
  • The processor will remember this fact by setting the program counter to 182.
  • Thus, on the next fetch cycle, the instruction will be fetched from location 182 rather than 150.

Example of a Hypothetical Machine

  • This machine includes the characteristics listed in Figure next slide.
  • The processor contains a single data register, called an accumulator (AC).  Both instruction and data are 16 bits long.
  • Thus, the memory is organized using 16-bit words.
  • The instruction format provides 4 bits for the opcode so that there can be as many as 24 = 16 different opcodes.
  • And up to 212 = 4096(4K) words of memory can be directly addressed.

Characteristics of a Hypothetical Machine