Computer Organization and Architecture Notes

UNIT-I: Syllabus

  • Digital Computers:
    • Introduction
    • Block diagram of a digital computer
    • Definition of Computer Organization, Computer Design, & Computer Architecture
  • Register Transfer Language & Micro operations:
    • Register Transfer Language
    • Register Transfer Bus & Memory Transfers
    • Arithmetic micro operations
    • Logic micro operations
    • Shift micro-operations
    • Arithmetic logic shift unit
  • Basic Computer Organization and Design:
    • Instruction codes
    • Computer registers
    • Computer Instructions
    • Timing and control
    • Instruction cycle
    • Memory Reference Instructions
    • Input-output and Interrupt

CS304 PC: Computer Organization & Architecture

  • Course Objectives:
    1. Introduce computer organization of basic digital computer architectural concepts.
    2. Begin with basic organization, design, & programming of a simple digital computer & introduces simple register transfer language to specify various computer operations.
    3. Topics include computer arithmetic, instruction set design, microprogrammed control unit, pipelining of vector processing, memory organization, I/O systems, & multiprocessors.
  • Course Outcomes:
    1. Understand the basics of instruction sets & their impact on processor design.
    2. Demonstrate an understanding of the design of the functional Units of a digital computer system.
    3. Evaluate cost performance & design trade-offs in designing & constructing a computer processor, including memory.
    4. Design a pipeline for consistent execution of instructions with minimum hazards.
    5. Recognize & manipulate representations of numbers stored in digital computers.

UNIT-I Principles of Digital Computers

  • Computer Definition:
    • An electronic device capable of:
      • Accepting data
      • Processing data according to given instructions
      • Storing data
      • Presenting and communicating data over networks
  • Two broad classes of computers based on input data:
    1. Analog computers
    2. Digital computers
  • Analog Computers:
    • Electronic devices capable of accepting data in analog or time-varying form for processing.
  • Digital Computers:
    • A digital system that performs various computational tasks.
    • An electronic device capable of accepting data in digital form for processing.
    • Uses the binary number system, which has two digits: 0 and 1.
      • A binary digit is called a bit.
      • Information is represented in digital computers in groups of bits.
  • Computer System Functional Entities:
    • Hardware
    • Software

Computer Hardware and Software

  • Hardware:
    • Electronic components & electro-mechanical devices that comprise the physical entity of the device.
    • Major parts:
      • CPU (Central Processing Unit)
      • RAM (Random Access Memory)
      • I/O (Input-Output) devices
  • Software:
    • Instructions & data that the computer manipulates to perform various data-processing tasks.
    • Program: A sequence of instructions for the computer.
    • Database: Data that is manipulated by the program.
  • Block diagram of a digital computer components:
    • CPU
    • RAM
    • I/O devices

Computer Hardware Details

  • Hardware Parts:
    1. CPU (Central Processing Unit):
      • Arithmetic and Logic Unit (ALU) for manipulating data
      • Registers for storing data
      • Control circuits for fetching and executing instructions
    2. RAM (Random Access Memory):
      • Storage for instructions & data.
      • Any location in memory can be accessed at random within a fixed interval of time.
    3. Input & Output Processor (IOP):
      • Electronic circuits for communicating and controlling the transfer of information between the computer and the outside world.
      • Input & output devices include keyboards, printers, terminals, magnetic disk drives, & other devices.
  • Computer Organization:
    • Concerned with how the hardware components operate & are connected to form the computer system.

Computer Design and Architecture

  • Computer Design:
    • Concerned with the hardware design of the computer.
    • Determines what hardware should be used and how the parts should be connected.
  • Computer Architecture:
    • Concerned with the structure and behavior of the computer as seen by the user.
    • Specifies the various functional modules such as processors, memories, & structuring them together into a computer system.
  • Register Transfer Language and Micro operations:

Register Transfer Language (RTL)

  • Digital system design uses a modular approach.
  • Modules are constructed from digital components like registers, decoders, and control logic.
  • Modules are interconnected with common data & control paths to form a digital computer system.
  • Micro operations:
    • Operations are executed on data stored in registers.
    • The result of the operation may replace the previous binary information of a register or may be transferred to another register.
  • Examples of micro operations: shift, count, clear, etc.
  • Internal hardware organization of a digital computer is defined by specifying:
    1. The set of registers it contains and their function.
    2. The sequence of microoperations performed on the binary information stored in the registers.
    3. The control that initiates the sequence of micro-operations.
  • Register Transfer Language:
    • Symbolic notation used to describe the micro-operation transfers among registers.
    • A system for expressing in symbolic form the micro operation sequences among the registers of a digital Module.

Register Transfer Details

  • Computer registers are defined by capital letters to denote the function of the register.
  • Memory Address Register (MAR):
    • The register that holds an address for a memory unit.
  • Other register designations:
    • PC (Program Counter)
    • IR (Instruction Register)
    • R1 (Processor register)
  • Information transfer from one register to another is designated in symbolic form by means of a replacement operator.
  • R2R1R2 \leftarrow R1:
    • Denotes a transfer of the content of register R1 into register R2.
  • Control function:
    • A Boolean variable that is equal to '1' or '0'.
  • P:R2R1P: R2 \leftarrow R1
    • If (P=1)(P=1) then (R2R1)(R2 \leftarrow R1)
    • The transfer operation is executed by the hardware only if P=1P=1.

Control Circuit and Bus Transfers

  • Control Circuit:
    • Includes a control function PP, registers R1R1 and R2R2, and a clock.
  • Bus and Memory Transfers:
    • A more efficient way for transferring information between registers in a multiple-register configuration is a common bus system.
    • Bus structure: A set of common lines, one for each bit of a register, through which binary Information is transferred one at a time.
    • One way of constructing a common bus system is with multiplexers.

Bus System with Multiplexers

  • Multiplexers are used to construct a common bus system.
  • Selection lines s<em>1s<em>1 and s</em>0s</em>0 are connected to the selection inputs of all four multiplexers.
  • Selection lines choose the four bits of one register & transfer them into a 4-line common bus.
  • When S<em>1S</em>0=00S<em>1S</em>0 = 00, the '0' data inputs of all four multiplexers are selected & applied to the outputs that form the bus.

Three-State Bus Buffers

  • A bus system can be constructed with three-state gates instead of multiplexers.
  • Three-State Gate:
    • A digital circuit that exhibits three states.
    • Two states are signal equivalents to logic 1 or 0 like a conventional gate.
    • The third state is a high-impedance state.
  • High-Impedance State:
    • Behaves like an open circuit.
    • The output is disconnected and does not have a logic significance.
  • Three-state gates may perform any logic function such as AND or NAND; however, the most commonly used in the design of a bus system is the buffer gate.
  • Normal input A, control input C.
    • Output Y=AY = A if C=1C = 1
    • High Impedance if C=0C = 0

Memory Transfer Operations

  • The operation of a memory circuit is to transfer information from a memory word to the outside world.
    • This transfer is called a read operation.
  • The transfer of new information to be stored into the memory is called a write operation.
  • Read:
    • DRM[AR]DR \leftarrow M[AR]
      • DR = Data Register
      • AR = Address Register
      • M = Memory
  • Write:
    • M[AR]R1M[AR] \leftarrow R1
      • R1R1 = Register

Arithmetic Micro-operations

  • A micro operation is an operation performed with the data stored in registers.
  • These are classified into 4 categories:
    1. Register transfer Micro operation: Transfers binary information from one register to another.
    2. Arithmetic micro-operations: Perform arithmetic operations on numeric data stored in registers.
    3. Logic micro-operations: Perform bit manipulation operations on non-numeric data stored in registers.
    4. Shift micro operations: Perform shift operations on data stored in registers.
  • Add Micro operation:
    • R3R1+R2R3 \leftarrow R1 + R2
  • Subtract Microoperation:
    • R3R1+R2+1R3 \leftarrow R1 + \overline{R2} + 1
      • R2R2 is the symbol for the 1's complement of R2R2.
    • R3R1R2R3 \leftarrow R1 - R2

Arithmetic Micro Operations Summary

Symbolic DesignationDescription
R3R1+R2R3 \leftarrow R1 + R2R1 plus R2 transferred to R3
R3R1R2R3 \leftarrow R1 -R2Contents of R1 minus R2 transferred to R3
R2R2R2 \leftarrow \overline{R2}Complement the contents of R2 (1's complement)
R2R2+1R2 \leftarrow \overline{R2} + 12's complement the contents of R2 (negate)
R1R1+1R1 \leftarrow R1 + 1Increment the contents of R1 by one
R1R11R1 \leftarrow R1 - 1Decrement the contents of R1 by one

Binary Adder Circuit

  • The digital circuit that forms the arithmetic sum of two bits & a previous carry is called a full-adder.
  • The digital circuit that generates the arithmetic sum of two binary numbers of any length is called a binary adder.
  • A 4-bit binary adder is implemented using four full adders (FA) in cascade:
    • Inputs: A<em>0,B</em>0,A<em>1,B</em>1,A<em>2,B</em>2,A<em>3,B</em>3,C0A<em>0, B</em>0, A<em>1, B</em>1, A<em>2, B</em>2, A<em>3, B</em>3, C_0
    • Outputs: S<em>0,S</em>1,S<em>2,S</em>3,C4S<em>0, S</em>1, S<em>2, S</em>3, C_4

Adder-Subtractor Circuit

  • Addition & subtraction operations can be combined into one common circuit by including Ex-OR gates with each full-adder.
  • The mode input M controls the operation:
    • When M=0M = 0, the circuit is an adder.
    • When M=1M = 1, the circuit is a subtractor.
  • Each Ex-OR gate receives input M & one of the inputs of B.
    • When M=0M = 0, we have B0=BB \oplus 0 = B. The full-adders receive the value of B, the input carry is '0', & the circuit performs A plus B.
    • When M=1M = 1, we have B1=BB \oplus 1 = \overline{B} and C0=1C_0 = 1. The inputs of B are all complemented, and 1 is added through the input carry.
    • The circuit performs the operation A + 2's complement of B.

Binary Incrementer

  • The increment microoperation adds one to a number in a register.
  • Example:
    • If a 4-bit register has a binary value 0110, it will become 0111 after it's incremented.
  • This microoperation is easily implemented with a binary counter.
  • Every time the count enable is active, the clock pulse transition increments the contents of the register by one.
  • A 4-bit binary incrementer can be implemented using half adders (HA).

Arithmetic Circuit

  • The basic component of an arithmetic circuit is a parallel adder.
  • By controlling the data inputs to the adder, it's possible to obtain different types of arithmetic operations.
  • The output of the binary adder is calculated from the following arithmetic sum:
    • D=A+Y+CinD = A + Y + C_{in}

Arithmetic Circuit Function Table

Select S1S_1Select S0S_0CinC_{in}Input YYOutput D=A+Y+CinD = A + Y + C_{in}Micro operation
000BBD=A+BD = A + BAdd
001BBD=A+B+1D = A + B + 1Add with carry
010B\overline{B}D=A+BD = A + \overline{B}Subtract with borrow
011B\overline{B}D=A+B+1D = A + \overline{B} + 1Subtract
1000D=AD = ATransfer A
1010D=A+1D = A + 1Increment A
1101D=A1D = A - 1Decrement A
1111D=AD = ATransfer A

Logic Micro Operations

  • Logic micro operations specify binary operations for strings of bits stored in registers.
  • These operations consider each bit separately & treat them as binary variables.
  • Example:
    • P:R1R1R2P: R1 \leftarrow R1 \land R2
    • R1R1 content: 1010
    • R2R2 content: 1100
    • R1R1 content after P: 1000

Boolean Functions and Logic Micro-operations

Boolean FunctionMicro-operationName
F0=0F_0 = 0ClearClear
F1=xyF_1 = xyAND
F2=xyF_2 = xy'
F3=xF_3 = xTransfer ATransfer A
F4=xyF_4 = x'y
F5=yF_5 = yTransfer BTransfer B
F6=xyF_6 = x \oplus yEx-OR
F7=x+yF_7 = x + yOR
F8=(x+y)F_8 = (x + y)'NOR
F9=(xy)F_9 = (x \oplus y)'Ex-NOR
F10=yF_{10} = y'Complement B
F11=x+yF_{11} = x+y'
F12=xF_{12} = x'Complement A
F13=x+yF_{13} = x'+y
F14=(xy)F_{14} = (xy)'NAND
F15=1F_{15} = 1Set to all 1's
  • Although there are 16 logic micro operations, most computers use only four - AND, OR, XOR & complement - from which all others can be derived.

Logic Circuit

  • Logic Diagram
    • Multiplexer with select inputs S<em>1S<em>1, S</em>0S</em>0, and enable input EE
  • Functional Table for One Stage of Logic Circuit:
    • S<em>1,S</em>0S<em>1, S</em>0 | Output E=E= | Operation
    • 0 0 | ABA \land B | AND
    • 0 1 | ABA \lor B | OR
    • 1 0 | ABA \oplus B | XOR
    • 1 1 | A\overline{A} | Complement

Shift Micro operations

  • Used for serial transfer of data.
  • Also used in conjunction with arithmetic, logic, and other data-processing operations.
  • The contents of a register can be shifted to the left or the right.
  • During shift-left operation, the serial input transfers a bit into the rightmost position.
  • During shift-right operation, the serial input transfers a bit into the leftmost position.
  • Logical Shift:
    • Transfers 0 through the serial input.
    • Symbols shl and shr are used for logical shift left & shift right microoperations.
  • Examples:
    • R1shlR1R1 \leftarrow shl R1
    • R2shrR2R2 \leftarrow shr R2

Circular Shift (Rotate)

  • Circular Shift (rotate):
    • Circulates the bits of the register around the two ends without loss of information.
  • Arithmetic Shift:
    • Shifts a signed binary number to the left or right.
    • Arithmetic shift-left multiplies a signed binary number by 2.
    • Arithmetic right shift divides the number by 2.
  • Shift Micro Operations Summary:
    • RshlRR \leftarrow shl R (Shift left register R)
    • RshrRR \leftarrow shr R (Shift Right register R)
    • RcilRR \leftarrow cil R (Circular Shift left Register R)
    • RcirRR \leftarrow cir R (Circulas Shift Right Register R)
    • RashlRR \leftarrow ashl R (Arithmetic shift left R)
    • RashrRR \leftarrow ashr R (Arithmetic shift Right R)

Combinational Circuit Shifter

  • 4-bit combinational circuit shifter
    • Select: 0 for shift right (down), 1 for shift left (up)
    • Inputs: I<em>R,A</em>0,A<em>1,A</em>2,A3I<em>R, A</em>0, A<em>1, A</em>2, A_3
    • Outputs: H<em>0,H</em>1,H<em>2,H</em>3H<em>0, H</em>1, H<em>2, H</em>3
  • Functional Table:
    • Select (S) | H<em>0H<em>0 | H</em>1H</em>1 | H<em>2H<em>2 | H</em>3H</em>3
    • 0 | I<em>RI<em>R | A</em>0A</em>0 | A<em>1A<em>1 | A</em>2A</em>2
    • 1 | A<em>1A<em>1 | A</em>2A</em>2 | A<em>3A<em>3 | I</em>LI</em>L

Arithmetic Logic Shift Unit

  • Instead of having individual registers performing the microoperations directly, computer systems employ a number of storage registers connected to a common operational Unit called an ALU.
  • ALU performs an operation & the result is then transferred to a destination register.
  • The operations through ALU are performed in one-clock pulse period.
  • Shift microoperations are often performed in a separate unit, but sometimes the shift unit is made part of the overall ALU.

Basic Computer Organization and Design

  • A computer instruction is a binary code that specifies a sequence of micro operations for the computer.
  • A computer reads each instruction from memory and places it in a control register.
  • The control then interprets the instruction & proceeds to execute it by issuing a sequence of micro operations.

Instruction Codes

  • An instruction code is a group of bits that instruct the computer to perform a specific task.
  • It's usually divided into parts, each having its own interpretation.
    • Operation code (opcode)
    • Operands.
  • Operation Code (Opcode):
    • A group of bits that define each operation, such as add, subtract, multiply, shift & complement.
    • Must consist of at least 'm' bits for a given 2m2^m distinct operations.
    • The Control Unit decodes the Opcode & do the required operation.
  • Operands:
    • The operation must be performed on some data stored in processor registers or in memory.
  • Each computer has its own particular instruction code format.

Instruction Code Formats

  • The opcode specifies the operation to be performed, and the address specifies the address of the instruction (or data).
  • The Basic computer has three instruction code formats.
  • The opcode part of the instruction contains three bits, and the meaning of the remaining bits depends on the operation code (op code).
  • The three Instruction code formats are:
    1. Memory - Reference Instruction
    2. Register - Reference
    3. Input/output Reference
  • The Instruction format will have opcode & address part.
  • Address will be of three types:
    1. Immediate
    2. Direct Address
    3. Indirect Address

Addressing Modes - Immediate and Direct

  • Immediate Address:
    • The address bits of an instruction code specify the actual operand
  • Direct Address:
    • The address of the location of the operand is given explicitly as a part of the instruction
  • Example:
    • MOVE A, 2000
    • Copies the contents of memory location 2000 into register A.
  • Accumulator (AC):
    • Computers that have a single-processor register usually assign to it the name accumulator (AC).
    • This is the special register where the result is accumulated and is commonly known as Ac.
  • Effective Address:
    • Generated by adding a constant value called offset to the contents of a register.
    • EA=Offset+REA = Offset + R
    • Offset = contents of Instruction Register

Addressing Mode - Indirect Address

  • Indirect Address:
    • When a part of the instruction specifies the address of the memory from where we get the address of the operand, the instruction is said to have an indirect addressing mode.
  • Computer Registers:
    • Computer instructions are normally stored in consecutive memory locations & are executed sequentially, one at a time.
    • The control reads an instruction from a specific address in memory & executes it.

Computer Registers for Basic Computer

  • List of Registers for the Basic computer:
SymbolNo. of bitsRegister NameFunction
DR16Data RegisterHolds Memory operand
AR12Address RegisterHolds Address for memory
AC16AccumulatorProcessor register
IR16Instruction RegisterHolds instruction code
PC12Program CounterHolds address of instruction
TR16Temporary RegisterHolds temporary data
INPR8Input RegisterHolds input character
OUTR8Output RegisterHolds output character
  • The memory circuit has a capacity of 4096 words of each word contains 16 bits.
  • 12 bits are needed to specify the address of a word in memory.
  • 3 bits for the operation part of the instruction & a bit to specify a direct or indirect address.

Basic Computer Registers Details

  • Memory Address Register (AR):
    • Has 12 bits.
    • Holds the address of memory for storage.
  • Program Counter (PC):
    • Has 12 bits.
    • Holds the address of the next instruction to be read from memory.
    • The PC goes through a counting sequence & causes the computer to read sequential instructions previously stored in memory.
  • INPR + OUTR (Input Register & Output Register):
    • Two registers used for I/O.
    • The input register receives an 8-bit character from an input device.
    • The output register holds an 8-bit character for an output device.
  • Instruction Register (IR):
    • Once an instruction is fetched from memory, it is stored in the Instruction register (IR).
    • The control Unit takes Instruction from this register, decodes & executes it by signals to the appropriate component of computer to carry out the task.

Accumulator, Data Register, and Temporary Register

  • Accumulator Register (AC):
    • Located inside the CPU.
    • Used during arithmetic & logical operations.
    • Stores data values fetched from main memory.
    • Holds the initial data, intermediate results, & final results of operations.
    • The final result is transferred to MM (Memory Module) through MBR (Memory Buffer Register).
  • Data Register (DR):
    • A register used in microcomputers to temporarily store data being transmitted to or from a peripheral device.
  • Temporary Register (TR):
    • Used for holding temporary data during processing.

Common Bus System

  • A collection of wires that carry some multi-bit information is known as a bus.
  • Its main purpose is to transfer Information from one system to another.
  • Registers connected to a 16-bit common bus:
    • DR, AC, IR, TR (16-bit registers)
    • AR, PC (12-bit registers)

Common Bus Operations and Control Signals

  • Load (LD):
    • Lines from the common bus are connected to the inputs of each register.
    • The particular register whose LD signal is enabled receives the data from the bus.
  • Increment (INR) & Clear (CLR):
    • The contents of a particular register are incremented when its INR signal is enabled & cleared when its CLR signal is enabled.
  • Memory Circuit:
    • The memory receives the 16-bit information from the bus when its write input is enabled.
    • The memory places its 16-bit information onto the bus when its read input is activated and S<em>2S</em>1S0=111S<em>2S</em>1S_0 = 111.
  • Address Register (AR):
    • This register specifies the address in memory for the next read or write operations.

Common Bus Register Operations

  • Program Counter (PC):
    • PC has 12 bits & it holds the address of the next instruction to be read from memory after the current instruction is executed.
    • When S<em>2S</em>1S0=010S<em>2S</em>1S_0 = 010, the PC receives or transfers the address from/to the bus when its input is enabled.
  • Data Register (DR):
    • This register contains the data to be written into memory or receives the data read from memory.
    • When S<em>2S</em>1S0=011S<em>2S</em>1S_0 = 011, the DR receives/ transfers data from/to the bus when its input is enabled.
  • Accumulator (AC):
    • The processor register Ac consists of 16 bits.
  • Instruction Register (IR):
    • To hold the instruction, processor executes, when S<em>2S</em>1S0=101S<em>2S</em>1S_0 = 101, the IR receives instruction code from bus when its input is enabled.
  • Temporary Register (TR):
    • This is a 16 bits register & provides temporary storage of variables or results
  • INPR (Input Register)
  • OUTR (Output Register)

Computer Instructions and Formats

  • Instruction Format:
    • An Instruction format or Instruction code is a group of bits used to perform a particular operation on the data stored in computer.
    • A processor fetches an instruction from memory & decodes the bits to execute the instruction.
  • Different computers may have their own instruction sets.
  • Instruction code is divided into two parts:
    • operation code
    • address of data
  • operation code consists group of bits to define an operation such as add, subtract, multiply etc.
  • In an instruction format:
    • 1st 12 bits (0-11) specify an address
    • Next 3 bits specify the addressing mode
    • left most bit specify the addressing mode I.
      • I=0I = 0 for direct address
      • I=1I=1 for Indirect address

Basic Computer Instruction Formats

  • Basic computer has three 16-bit instruction code formats:
    1. Memory Reference Instructions
    2. Register Reference
    3. Input / output
  • Memory Reference Instructions:
    • In memory reference instructions, first 12 bits (0-11) specify an address.
    • Next 3 bits specify operation code (oprocte).
    • Left most bit specifies the addressing mode I:
      • I=0I=0 for Direct address
      • I=1I=1 Indirect address

Memory Reference Instructions

  • Following are the Memory Reference Instructions:
SymbolI=0I=1Description
AND0xxx8xxxAND memory word to AC
ADD1XXX9×××ADD memory word to AC
CDA2xxxA xxxLOAD memory word to Ac
STA3xxxBXXXStore contents of Ac in memory
BUN4xxxCxxxBranch Unconditionally
BSA5XXXDxxxBranch & Save return Address
ISZ6xxxExxxIncrement & skip of Zero
  • Register Reference Instructions

Register and I/O Reference Instructions

  • Register Reference Instructions:

    • In this, 1st 12 bits (0-11) specify register operation.
    • The next 3 bits specify opcode.
  • Symbol code and Description

  • CLA: 7800 Clear Ac

  • CLE: 7400 clear E

  • CMA: 7200 complement Ac

  • CME: 7100 complement E

  • CIR: 7080 circulate right ACRE

  • CIL: 7040 circulate left ACFE

  • INC: 7020 increment AC

  • SPA: 7010 skip next instruction if Ac the +ve

  • SNA: 7008