Chapter 1: Computer Organization 1.1) Introduction 1.2) Central Processing Unit (CPU) 1.3) Computer Memory System 1.4) Input/Output Unit 1.5) I/O Techniques 1.6) Peripherals (I/O Devices) 1.1) Introduction Main Computer Components A computer consists of 3 main computer components: 1. Central Processing Unit (CPU) Controls computer operations and performs data processing functions; often simply referred to as processor 2. Main Memory (MM) Temporarily stores data and instructions that are being executed or will be executed by the CPU 3. Input/Output Unit (I/O U) - Connects the user and the computer through peripherals and controls the peripherals These components communicate with each other to perform a task. The collection of paths connecting the various modules is called the interconnection structure. The design of this structure will depend on the exchanges that must be made between modules. 2 1. Peripheral s Central Processing Unit Computer Systems Interconnection Input Output Communication lines 3 Main Memory A line or pathway that connects the 3 main computer components is called BUS. There are three types of bus that work together: i Data Bus ii Used to transfer data/instructions from one component to another Address Bus iii Used to transfer the destination address of the data that is inside the Data Bus Control Bus Used to transfer signals that control data and address in Data Bus and Address Bus A bus consists of multiple communication pathways, or lines and each line is capable of transmitting signals representing binary 1 and binary 0. For example, an 8-bit unit of data can be transmitted over 8 data bus lines. Generally, there are 4 ways to connect the 3 components with the I/O module acting as the control point : i I/O to CPU MM CPU I/O U 4 ii I/O to MM CPU MM I/O U iii I/O to Central Switch CPU Central Switch MM I/O U iv I/O to Bus CPU MM System Bus 5 I/O U The most common interconnection structure is I/O to bus or known as bus interconnection. The followings are three types of bus interconnection: i. Bus Interconnection Scheme ii. Traditional Bus Architecture iii. High-Performance Architecture 6 7 The basic computer function is to execute programs, which includes: o Data Processing o Data Storage o Data Movement o Control There are 3 main computer components, i.e. CPU, MM and I/O U that are interdependent when performing their respective tasks. CPU will perform the processing tasks based on the instructions given by programs The instructions are stored in MM and the CPU will fetch and execute them one at a time until all of them are completed. Generally, computers use Stored Program Concept to perform their tasks. This concept was introduced by John Von Newmann (1945) Stored Program Concept 2. Data and instructions that will be executed are stored in memory 3. The content of the memory is addressed according to their position Instructions are executed sequentially based on their position in the memory (except for branch instructions) 8 1.2) Central Processing Unit (CPU) Its function is to control the operation of the computer and performs its data processing functions. Can be divided into three main components: i. Control Unit (CU) Controls the movement of data and instructions into and out of the CPU and control the operation of the ALU and the computer as a whole. ii. Arithmetic Logic Unit (ALU) iii. Performs computer data processing functions Registers As a temporary storage in CPU Also known as high speed memory Its function is to temporarily hold data and instructions that are taken from other components (example MM, I/O U, cache etc) to be processed in the CPU. The registers in the processor perform two roles: o User-visible registers – enable the machine- or assembly language programmer to minimize main memory references by optimizing use of registers. (will be discussed in chapter 6 – 8) o Control and status registers – used by the control unit to control the operation of the processor and by privileged, operating system program to control the execution of program. (eg: PC, MAR, MBR and IR) 9 Structure – The CPU CPU Computer I/O Registers System Bus Internal CPU Interconnection CPU Memory Control Unit 10 Arithmetic and Logic Unit The Control Unit CPU ALU Registers Internal CPU Bus Control Unit CONTROL UNIT Sequencing Logic Control unit Registers and Decoders Control Memory 11 12 The function of computers is to execute programs. Programs comprise a set of instructions and data that is stored in the main memory. Every instruction will be taken and executed by the CPU one by one until all of them are executed. The process of executing a single instruction is called Instruction Cycle which can be divided into: i. Fetch Cycle - read the next instruction from MM into the CPU. ii. Execute Cycle - interpret the opcode and perform the indicated operation. 13 Fetch Cycle The process of fetching an instruction from MM into the CPU 4 registers are involved: o PC (Program Counter) Contains the address of the instruction that has to be fetched and executed o MAR (Memory Address Register) A register that connected to the MM through the address bus The content in PC will be transferred into the MAR and then to the address and to the location in MM that pointed by the address given. o MBR (Memory Buffer Register) A register that connected to the MM through the data bus Used to hold instruction or data taken from the MM or data that will be moved into the MM or other computer components after being processed by the CPU. o IR (Instruction Register) Used to hold instruction (operation code) before it is being decoded by the Instruction Decoder inside the control unit. Generally the process in the Fetch Cycle can be depicted by: MAR ← PC MBA ← M (MAR) PC ← PC + 1 IR ← (MBR) 14 Execute Cycle The process of executing the instruction that has been fetched earlier The followings are steps that are involve in execute cycle: i. Instruction decoding (to determine the operation that has to be performed by the CPU) ii. Operand (data) fetching iii. Data Processing iv. Store Result The sequences of operations that happen in execution cycle differ according to the type of instruction. 2 1 X ALU 3 (Data ) (Data) MM Example: R1 CPU ADD R1, X This instruction adds the content in the R1 register with the content in the MM at location X and the result is stored in the R1 register, i.e.: R1 ← R1 + M (X) (Observe the diagram above) Before the addition operation is performed in the ALU, the required data is taken and moved into a register in the CPU The data in R1 is already in the CPU (R1 is one of the registers in CPU) The addition operation is performed in ALU and the result is stored in the R1 register The process which takes place in the Execution Cycle for instruction ADD R1,X can be depicted by: MAR ← IR (address X) MBR ← M (MAR) R1 ← R1 + MBR 15 16 1.3) Computer Memory System Generally, computer memory system can be divided into 2 categories: i. Internal memory ii. External/Secondary Memory 17 Internal Memory There are 3 types of internal memory: a) Registers (in the CPU) b) Cache c) Main Memory (RAM & ROM) Information stored in internal memory can be accessed with greater speed by the CPU compared to external memory. Internal memories are volatile, only with exception to ROM External Memory Memories that are separated from the main computer components Information contained in external memory can be accessed by the CPU through the I/O Unit. Used to store information or program that has already or has yet to be executed by the CPU Instances of external memory are hard disks, diskettes, CD-ROM, etc All external memory are non-volatile Main Memory Central Storage of the computer. Used to store instructions and data that are being executed (run) They are built based on Semiconductor Integrated Circuits Basically, they are divided into RAM and ROM RAM Acronym for Random Access Memory Information in RAM can be read and modified (write) Used to store programs and user data that is being executed (run) A kind of volatile memory, i.e. the content in RAM will be wiped out if electricity supply is interrupted. 18 There are 2 types of RAM: 1. Static RAM (SRAM) Made from flip-flop Disadvantages : expensive, small storage capacity in a chip Advantages : easier to use and faster access time (read and write cycle) 2. Dynamic RAM (DRAM) Made from capacitors Disadvantages : slower access time, harder to use because capacitors need to be charge for a certain amount of time Advantages: cheaper, bigger storage capacity in a chip A few improvements has been done on DRAM to improve its performance (access time) with different method and names such as EDRAM, CDRAM, SDRAM, RDRAM etc Following is a block diagram for a unit (chip) RAM that has 2k word and the length of each word is n bit n input line (from data bus) k address line (from bus address) RAM (2k x n) From control bus read write n bit n output line (to data bus) 19 2k word ROM Acronym for Read Only Memory Information in ROM can only be read (cannot be written or modified) Used to store permanent programs like bootstrap loader, i.e. a program used to start the operation of a computer when the computer is turned on There are various kinds of ROM, among them are PROM, EPROM and EEPROM. The difference is the ability to change data in them using specific methods and equipments The following is a block diagram of a ROM with the size of 2k x n (2k word and the length of each word is n bit) k address line (from address bus) n data line (from data bus) 2k word n bit Note: Why don’t ROM chips have read-write pins? 20 Cache Memory A small and fast memory that situated between the CPU and the MM (conceptually, not physically). Reduces the difference of time of the memory cycle and the CPU processing time. The memory cycle time is the time used to fetch an instruction or data from the main memory until it is usable. With the technology available today, the processing time of the CPU is faster than the memory cycle time by far. Hence, a memory, which was called Cache, was introduced and it was situated between the CPU and the MM. The method used for cache manufacturing rendered its memory cycle time far faster than that of the main memory but its cost was exorbitant. We would like the size of the cache to be small enough so that the overall average cost per bit is close to that of main memory alone and large enough so that the overall average access time is close to that of the cache alone. What is the ideal size for the cache?????? How does cache work? CPU CACHE: divided into a few slots MM: divided into a few blocks or lines (block size = slot size) When the CPU needs certain data or instruction, it will refer to the cache memory first. If it is in cache, then data access will be fast. Otherwise, it will have to be fetched from the MM and the data block that contains the required data or instruction 21 will be moved into the Cache Memory with the hope that the next instruction/data required by the CPU is contained in the block. Because there are fewer cache lines than main memory blocks, an algorithm is needed for mapping main memory blocks into cache lines/slots. Three techniques can be used: direct, associative and set-associative. Once the cache has been filled, when a new block is brought into the cache, one of the existing blocks must be replaced. A replacement algorithm is needed. What types of algorithm??????? 22 Word Transfer CPU Block Transfer Main Memory Cache Cache and Main Memory Address Buffer Processor Control Cache Control Data Buffe r Data Typical Cache Organization 23 System Bus Address START Access the block that contains RA in the MM Receive address RA from the CPU Prepare a Cache slot for this MM block Block contains RA in Cache? Nope Yup Send word RA to the CPU Access word RA and send to the CPU Move the MM block into the Cache slot STOP Read Cache Operation External Memory Also known as secondary memory Used to store information (program and data) that has not or has already been processed by the computer system Consists of secondary storage devices such as discs and tapes where information contained in them are accessed by the CPU through the I/O unit. The most commonly used today: disk 24 Disk The 2 most popular types: 1. Magnetic Disk 2. Optical Disk Magnetic Disk There are 2 kinds, i.e. hard disk and floppy disk. A round platter made from metal or plastic and shrouded with magnetic coating Sector Track Intersector gap Consists of tracks and sectors Track: 500 – 2000 tracks/surface Sector: 10 – 100 sector/track (fixed or varied) Data are moved into/taken out from the disk in block size (sector/track) The amount of data in every track is same => data density varies There are 2 types of read/write heads: Fixed head: One head per track Movable head: One head for all tracks Disks are inserted into the disk drive. There are 2 types of disk: Movable disk: can be inserted and taken out from the disk drive, such as the floppy disk. Fixed disk: cannot be taken out from the disk drive, for instance hard disk. 25 1.4) Input/Output Unit Input and output operations are very important in a computer system. They enable the user to communicate with the computer. These operations are performed using peripherals such disk drive, keyboard, mouse, printer, monitor etc Every peripheral has different operation The data format and word length in the peripheral also differs with the internals computer system. The data transfer rate of peripherals is far slower compared to that of the main memory or the CPU. I/O Unit is needed to coordinate the difference stated above. Address Line System Bus Data Line Control Line I/O Module Connects to peripheral devices General Module of I/O 26 Interface to System Bus Data Line Interface to External Device External Device Interface Logic Data Register Status/Control Register . . . Address Line Control Line I/O Logic External Device Interface Logic . . . Block Diagram for I/O Module Control from I/O Module Data Status Control Data (bits) to and from I/O Module Status to I/O Module Control Logic Buffer Transducer Data to and from the environment Block Diagram for External Devices 27 Data Status Control 1.5) I/O Techniques I/O Operations – the operation of inserting or extracting data to/from the computer system I/O Techniques refers to how I/O operations are executed. There are 3 ways to perform the I/O operations (I/O Techniques): 1. Programmed I/O 2. Interrupt-Driven I/O 3. Direct Memory Access (DMA) Forward the read instruction to the I/O Module CPU Read the I/O Module status Not ready Check Status I/O I/O CPU Error Situation Ready Read word from I/O Module I/O CPU Write word to memory CPU No Done ? Yes Next Instruction 1. Programmed Input/Output 28 Memory Forward the read instruction to the I/O Module CPU I/O Perform other Read I/O Module status I/O Check Status Interrupt CPU Error Situation Ready Read word from I/O Module I/O CPU Write word into memory CPU No Done ? Yes Next Instruction 2. Interrupt Driven Input/Output 29 Memory tasks Forward the read instruction to the I/O Module CPU DMA Perform other tasks Interrupt Read DMA module status DMA CPU Next Instruction 3. Direct Memory Access Diagram 1, 2 and 3 above are flow charts that depicts the execution of the 3 stated I/O techniques 30 1.6) Peripherals OR External Devices Connected to the computer system through I/O unit Can broadly classify into three categories: 1. Human readable Suitable for communicating with the computer user Example: VDT, printer etc. 2. Machine readable Suitable for communicating with equipment Example: disk drive, tape drive etc. 3. Communication Suitable for communicating with remote device Example: modem etc. Based on usage, peripherals can be divided into: 1. Input Device Devices used to accept input only Example: keyboard, mouse etc 2. Output Device Devices used only to provide output Example: printer, VDT etc 3. Input and Output Devices Can be used to accept input and provide output Example: touch screen, disk drive etc 31