Docsity

CPU Design & Computer Arithmetic, Study notes of Computer Architecture and Organization

Toggle sidebar
bg1
CO&A UNIT 2 Page 1
UNIT II
SYLLABUS: CPU DESIGN
Instruction Cycle. Memory: Reference Instructions- Input โ€“ Output and Interrupt ,
Addressing Modes, DATA Transfer and Manipulation, Program Control
COMPUTER ARITHMETIC:
Addition and Subtraction, Multiplication Algorithms, Division Algorithms, Floating โ€“
Point Arithmetic Operations, Decimal Arithmetic Unit, Decimal Arithmetic Operations.
INSTRUCTION CYCLE:
๏ƒ˜ The program consists of a sequence of instructions. The program is executed in the
computer by going through a cycle for each instruction. each instruction cycle in turn is
subdivided in to a sequence of sub cycles or phrases.
๏ƒ˜ Instruction cycle consists of following phrases
1. Fetch an instruction from memory
2. Decode the instruction
3. Read the effective address the memory if the instructions has an indirect address
4. Execute the instructions
This process continues indefinitely unless halt instruction is encountered.
FETCH AND DECODE:
๏ƒ˜ The program counter PC is loaded with address of the first instruction in the program. The
sequence counter SC is cleared to 0, providing a decoded timing signal To.
๏ƒ˜ After each clock pulse, SC is incremented by one. So that the timing signals go through a
sequence TO,T1,T2 and so on
Ex: T0 : AR๏ƒŸPC
T1 : IR:๏ƒŸM[AR], PC๏ƒŸPC+1
T2 : D0โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ..D7 ๏ƒŸDecode IR(12-14), AR๏ƒŸIR(0-11), I๏ƒŸIR(15)
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47

Partial preview of the text

Download CPU Design & Computer Arithmetic and more Study notes Computer Architecture and Organization in PDF only on Docsity!

UNIT II

SYLLABUS: CPU DESIGN

Instruction Cycle. Memory: Reference Instructions- Input โ€“ Output and Interrupt , Addressing Modes, DATA Transfer and Manipulation, Program Control COMPUTER ARITHMETIC : Addition and Subtraction, Multiplication Algorithms, Division Algorithms, Floating โ€“ Point Arithmetic Operations, Decimal Arithmetic Unit, Decimal Arithmetic Operations. INSTRUCTION CYCLE: ๏ƒ˜ The program consists of a sequence of instructions. The program is executed in the computer by going through a cycle for each instruction. each instruction cycle in turn is subdivided in to a sequence of sub cycles or phrases. ๏ƒ˜ Instruction cycle consists of following phrases

  1. Fetch an instruction from memory
  2. Decode the instruction
  3. Read the effective address the memory if the instructions has an indirect address
  4. Execute the instructions This process continues indefinitely unless halt instruction is encountered. FETCH AND DECODE: ๏ƒ˜ The program counter PC is loaded with address of the first instruction in the program. The sequence counter SC is cleared to 0, providing a decoded timing signal To. ๏ƒ˜ After each clock pulse, SC is incremented by one. So that the timing signals go through a sequence TO,T1,T 2 and so on Ex: T 0 : AR๏ƒŸPC T 1 : IR:๏ƒŸM[AR], PC๏ƒŸPC+ T 2 : D 0 โ€ฆโ€ฆโ€ฆโ€ฆโ€ฆ..D 7 ๏ƒŸDecode IR(12-14), AR๏ƒŸIR(0-11), I๏ƒŸIR(15)

๏ƒ˜ At time To, AR is connected to the address inputs of memory, it is necessary to transfer the address from PC to AR during the clock transition associated with timing signal T 0. ๏ƒ˜ The instruction read from memory is then placed in the instruction register with the clock transition associated with timing signal T 1. At the same time, it is incremented by one to prepare it for the address of the next instruction in the program. ๏ƒ˜ At the time T 2 , the operation code in IR is decoded, the indirect bit is transferred to flip flop I and the address part of the instructions is transferred to AR. ๏ƒ˜ Note that SC is incremented after each clock pulse to produce the sequence T0,T 1

D 7 I^1 T 3 = r (common to all register reference instructions) IR (i) = Bi [bit in IR (0- 1 1) that specifies the operation] The control function is distinguished by one of the bits in IR(0-11). By assigning the symbol Bi to bit i of IR, all control functions can be simply denoted by rBi. Ex: The instruction CLA has hexadecimal code 7800=0111 1000 00000 0000. The first bit is a zero which is equivalent to I^1. The next three bits constitute the operation code and are recognized from decoder output D 7. Bit 11 in IR is 1 & is recognized from B 11. The control function which initiates the micro operation for this instruction is D 7 I^1 T 3 B 11 =rB 11

MEMORY REFERENCE INSTRUCTIONS:

๏ƒ˜ The decoded output Di for i=0, 1, 2, 3, 4, 5, 6 from the operation decoder that belongs to each instruction is included in the table. ๏ƒ˜ The effective address of the instruction is in the address register AR and was placed there during timing signal T 2 when I=0 or during timing signal T 3 when I=1. ๏ƒ˜ The execution of the memory reference instructions starts with timing signal T 4. AND to AC: This is an instruction that performs the AND logic operation on pairs of bits in AC and the memory word specified by the effective address. The result of the operation is transferred to AC. ADD TO AC : This instruction adds the content of the memory word specified by the effective address to the value of AC. The sum is transferred into AC and the output carry Cout is

INPUT-OUTPUT AND INTERRUPT:

Instructions and data stored in memory must come from some input device. Computational results must be transmitted to the user through some output device. Commercial computers include many types of input and output devices. ๏ƒ˜ The terminal sends and receives serial information. Each quantity of information has 8 bits of an alphanumeric code. ๏ƒ˜ The serial information from the keyboard is shifted into the input register INPR. The serial information for the printer is stored in the output register OUTR. These two registers communicate with a communication interface serially and with the AC in parallel.

๏ƒ˜ The INP instruction transfers the input information from INPR into the 8 low-order bits of AC and also clears the input flag to 0. ๏ƒ˜ The OUT instruction transfers the 8 LSBs of AC into the output register OUTR and clears the output flag to 0. ๏ƒ˜ If the flag is 1, the branch instruction is skipped and an input or output instruction is executed. ๏ƒ˜ The last two instructions are set and clear an interrupt enable flip flop IEN. PROGRAM INTERRUPT: ๏ƒ˜ When IEN is cleared to 0, the flags cannot interrupt the computer. ๏ƒ˜ When IEN is set to 1, the computer can be interrupted. ๏ƒ˜ An interrupt flip-flop R is included in the computer. When R=0, the computer goes through an instruction cycle. ๏ƒ˜ During the execute phase of the instruction cycle IEN is checked by the control. If it is 0, it indicates that the programmer does not want to use the interrupt, So control continues with the next instruction cycle. If IEN is 1, control checks the flag bits, If both flags are 0, it indicates that neither the input nor the output registers are ready for transfer of information.

๏ƒ˜ In this case, control continues with the next instruction cycle. If either flag is set to 1 while IEN=1, flip flop R is set to 1. ๏ƒ˜ At the end of the execute phase, control checks the value of R, and if it is equal to 1, it goes to an interrupt cycle instead of an instruction cycle. ๏ƒ˜ The interrupt cycle is a hardware implementation of a branch and save return address operation. The return address available in PC is stored in a specific location where it can be found later when the program return to the instruction at which it was interrupted. This location may be a processor register, a memory stack, or a specific memory location.

INTERRUPT CYCLE:

The interrupt cycle is initiated after the last execute phase if the interrupt flip-flop R is equal to 1. This flip-flop is set to 1 if IEN=1and either FGI or FGO are equal to 1. This can happen with any clock transition except when timing signals To, T 1 orT 2 are active. The condition for setting flip-flop R to 1can be expressed as The symbol โ€˜+โ€™ indicates logic OR operation between FGI and FGO. This is AND with IEN and Toโ€™ T1โ€™ T2โ€™. The interrupt cycle stores the return address (available in PC) into memory location 0, branches to memory location 1, and clears IEN, R & SC too. This can be done with the following sequence of micro operations ๏ƒ˜ During the first timing signal AR is cleared to 0,and the content of PC is transferred to the temporary register TR. ๏ƒ˜ With the second timing signal, the return address is stored in memory at location 0 and PC is closed to 0. ๏ƒ˜ The third timing signal increments PC to 1, clears IEN and R and control goes back to To by clearing SC to 0.

ADDRESSING MODES:

The addressing mode specifies a rule for interpreting or modifying the address field of the instruction before the operand is actually referenced. Computers use addressing mode techniques for the purpose of accommodating one or both of the following precisions.

  1. To give programming versatility to the user by providing such facilities as pointers to memory, counters for loop control, indexing of data, and program relocation.
  2. To reduce the number of bits in the addressing field of the instruction. These are two modes that needs no address field at all. These are the implied and immediate modes. Implied mode: ๏ƒ˜ The instruction โ€œcomplement accumulatorโ€ is an implied mode instruction because the operand in the accumulator register is implied in the definition of instruction. ๏ƒ˜ All Register-reference instructions that use an accumulator are implied-mode instructions. Zero address instructions in a stack organized computer are implied mode instructions since the operands are implied to be on top of the stack. Mode field: This field is used to locate the operands needed for the operation. There may or may not be an address field in the instruction. If there is an address field. It may designate a memory address or a process register. There are two modes that need no address field at all (implied and immediate). Immediate mode: Immediate mode instructions are useful for initializing registers to a constant value. Example: MOVE A, # The above instruction copies operand 20 in the register A. the sign # infront of the value of an operand is used to indicate that this value is an immediate operand. Register mode: The operand is the contents of processor register, the name of the register is specified in the instruction.

Relative addressing mode: This addressing mode is commonly used to specify the target address in the branch instructions. Example: JNZ BACK This instruction causes program execution to go to the branch target location identified by the name BACK, if the branch condition is satisfied. The branch target location can be determined by specifying it an offset from the current value of the program counter. Indexed addressing mode: The effective address of the operand is generated by adding a constant value to the contents of a register. EXAMPLE: MOVE 20 (R1), R The above instruction loads the contents of register R2 into the memory location whose location whose address is calculated by addition of the contents of register R1 and constant value 20. DATA TRANSFER AND MANIPULATION: Most computer instructions can be classified into three categories:

  1. Data Transfer Instructions
  2. Data manipulation Instructions
  3. Program control Instructions DATA TRANSFER INSTRUCTION: ๏ƒ˜ Data Transfer instructions cause transfer data from one location to another without changing the binary information content. ๏ƒ˜ The most common transfers are between memory and processor registers between processor registers and input or output, and between the processor registers themselves.

LOAD: The load instruction has been used mostly to designate a transfer from memory to a processor register, usually an accumulator. Store : The store instruction designates a transfer from a processor to memory. Move : The move instruction has been used in computer with multiple CPU registers to designate a transfer from one register to another. It has also been used for data transfers between CPU registers and memory or between two memory words. EXCHANGE: The exchange instruction swaps information between two registers or a registers and a memory word. INPUT-OUTPUT: The input and output instructions transfer data among processor registers and input or output terminals. PUSH-POP: The push-pop instructions transfer data between processor registers and a memory stack.

Logical and bit manipulation: ๏ƒ˜ There are three bit manipulation operations possible: a selected bit can be cleared to 0, or can be set to 1, or can be complemented. ๏ƒ˜ The AND Instruction is used to clear a bit or a selected group of bits of an operand. For any Boolean variable x, the relationships x b0 = 0 and x b1=x dictate that a binary value ANDed with a 0 produces a 0; but the variable does not change in value when ANDed with a 1. ๏ƒ˜ The OR instruction is used to set a bit or a selected group of bits of an operand. For any Boolean variable x, the relationships x+1=1 and x+0=x dictate that a binary variable ORed with a 1 produces a 1; but the variable does not change when ORed with a 0. ๏ƒ˜ The XOR instruction is used to selectively complement bits of an operand. This is because of the boolean relationships x 1=x and x 0=x.

Shift Instructions: ๏ƒ˜ Shifts are operations in which the bits of a word are moved to the left or right. The bit shifted in at the end of the word determines the type of shift used. Shift instructions may specify either logical shifts , arithmetic shifts , or rotate type operations. In either case the shift may be to the right or the left ๏ƒ˜ The logical shift inserts 0 to the end position. The end position is the left more bit for shift right and the right most bit position for the shift left. ๏ƒ˜ The Rotate instructions produce a circular shift. Bits shifted out at one end of the word are not lost as in a logical Shift but are circulated back into the other end. ๏ƒ˜ To rotate through carry instruction treats a carry bit as an extension of the register whose word is being rotated. ๏ƒ˜ A rotate left through carry instruction carry instruction treats the carry bit into the right most bit position of the register, transfers the left most bit position into the carry, and at the same time, shifts the entire register to the left. ๏ƒ˜ The arithmetic shift right instruction must preserve the sign bit in left most position. The sign bit is shifted to right together with the rest of the number, but the sign bit itself remains unchanged. ๏ƒ˜ The arithmetic Shift left inserts 0 to the end position and itself it is identical to the logical shift โ€“ left.