Unit - Ii 2.0) Introduction: Digital Logic and Computer Organization
Unit - Ii 2.0) Introduction: Digital Logic and Computer Organization
Unit - Ii 2.0) Introduction: Digital Logic and Computer Organization
0) Introduction
A computer is defined as an electronic data processing machine, which receives and stores a large volume of information in the form of symbols and digits and process them at high speed as per the instructions given and outputs the results with a predefined form.
2.1) Objectives
This chapter deals in detail about the basic structure, functional units, and operational concepts of a computer and memory management in computers. Basic Structure of a computer Software Operating System Memory Memory Organization Memory Unit Random Access Memory(RAM) CMOS Memory(Complementary Metal Oxide Semiconductor Memory) Serial Access Memory Cache Memory Virtual Memory Memory Management
2.2) Content
2.2.1. Basic Structure of a Computer Before a computer can perform any task, it has to be given a detailed set of instructions. This forms the INPUT based on which the computer will perform some PROCESS and gives the result as OUTPUT. This input-process-output (IPO) cycle is an essential concept for understanding the working of any computerized system. INPUT PROCESS OUTPUT The terms Hardware and Software are widely used in conjunction with computers. The hardware consists of the physical components and the software is the set of instructions that are needed to enable the hardware to perform a given set of tasks. The major hardware components of a computer are: Input Devices Output Devices
Page 46
Input Unit
Control Unit
Output Unit
Memory Unit
Figure 1.1: Organization of a computer Figure 4.1: Basic Organization of a computer 2.2.2. Functional Units The functional units of the computer can be divided into following: Input Unit Input Unit is that part of a computer through which the information is fed. The function of the input unit is to read the information contained in the program and transmit to the CPU. The media used for feeding any information may be of different forms depending on the facilities available and the requirements of the situation. To communicate with the computer an input device is needed, one such device is the keyboard. The data and the instruction required for the CPU are provided through the keyboard. The keyboard layout is similar to that of a typewriter with some additional keys. The additional keys are included to perform certain special functions such as loading programs, editing text or controlling the movement of the cursor (blinking indicator). They are classified as function keys, editing keys and cursor control keys. Each key when pressed produces an equivalent binary code, which is mapped into a table and the corresponding character is displayed based on the details in the table. Output Unit The output unit refers to the device used for the display of the processed results. The default output unit is the Monitor, which is also known as the Visual Display unit.
Page 47
Page 48
All these operations are part of the communication process between the processor and peripheral devices (including memory). To communicate with a peripheral (or a memory location), the processor needs to perform the following steps: Step 1: Identify the peripheral or the memory location (with its address). Step 2: Transfer data. Step 3: Provide timing or synchronization signals. The processor performs these functions using sets of communication lines called buses. There are three types of buses namely: the address bus, the data bus and the control bus. Address Bus The address bus is a group of sixteen lines generally identified as A0 to A15. The address bus is unidirectional: bits flow in one direction from the processor to peripheral
Page 49
Figure 4.2: The Bus Structure Data Bus The data bus is a group of eight lines used for data flow. These lines are bidirectional data flow in both directions between the processor and peripheral devices. The processor uses the data bus to perform the second function: transferring data. The eight data lines enable the processor to manipulate 8-bit data ranging from 00 to FF (28 = 256 numbers). The largest number that can appear on the data bus is 11111111 (25510). The data bus determines the word length and the register size of a microprocessor; thus the 8085/8080A microprocessor is called an 8-bit microprocessor. Microprocessors such as the Intel 8086, Zilog Z8000 and Motorola 68000 have sixteen data lines; thus they are known as 16-bit microprocessors. Page 50
Figure 4.3: Memory Read Operation To communicate with a memory for example, to read an instruction from a memory location the processor places the 16-bit address on the address bus. The address on the bus is decoded by an external logic circuit and the memory location is identified. The processor sends a pulse called Memory Read as the control signal. The pulse activates the memory chip and the contents of the memory location (8-bit data) are placed on the data bus and brought inside the microprocessor. Bus protocols For each bus there is a standard, which defines how devices communicate on the wires. On some systems the address and data signals may be multiplexed onto the same physical lines. Standard System Busses are: Page 51
Page 52
Page 53
Page 54
Page 55
Page 56
Page 57
Memory Cell Cells used to fabricate a random access memory are made (in current technology) with semiconductor flip-flops. Cells used in serial access memories of large size (tens of megabytes) are magnetic dipoles on movable magnetizable surfaces. Magnetic surface recording itself may be organized in different configurations such as hard disks, floppy disks and tapes. A memory cell may be defined as a device which can store a symbol selected from a set of symbols and may be characterized by the following properties: The number of stable states in which it can be placed. Whether a cell can store a symbol indefinitely even when power is turned off. Whether, after reading a symbol from a cell, the stored symbol is retained in the cell or disturbed. The time taken to read a symbol from a cell and the time to write a new symbol in it. Whether a symbol, once written, can only be read and not changed. The number of stable states in which a cell can be placed determines the number of distinct symbols it can store. Each stable state may be assigned to represent a symbol. Thus if a cell be placed in ten stable states, each state may be used to represent one symbol and so the cell can store a decimal digit. If a cell can be placed in only one out of two stable states, then it may be used to store a binary digit. If a symbol can be stored in a cell indefinitely without continuous supply or energy, it is known as a non-volatile cell. On the other hand, if the symbol stored in a cell disappears when no energy is supplied, it is known as a volatile cell. Normally, reading a symbol from a cell should leave it undisturbed. Such a cell is known as one where readout is non-destructive. If the symbol is erased, as a consequence of reading, the readout is said to be destructive. The time taken to read a symbol from a cell is called read-time and the time taken to write a symbol write-time. If in a memory cell, information is permanently written and can only be read, then it is known as a read-only cell. 2.2.7. Memory Organization Memory cells fabricated using current technology can be placed in one out of two stable states. These cells are called binary cells and each cell can store a binary digit. One of the two stable states is used to represent the binary 0 and the other the binary 1. Figure 4.4 depicts a storage cell. The cell has an input data line on which the symbol to be written is sent to the cell. In order to write this symbol in the cell, a write-control signal is sent to the cell via the write-line. If the content of a cell is to be read, a read-control signal is sent on the read-line and the content of the cell may be sensed on the output data line.
Page 58
Figure 4.4: Storage cell By appropriate variation in the interconnection of binary memory cell it is possible to organize different types of memories. The individual cells are non-volatile and reading is non-destructive. The simplest organization of a set of cells is shown in Figure 4.5. In this organization, three cells are interconnected in such a way that the write-control lines of all the cells are connected together. The read-control lines are also connected together. The bits to be written in each cell is fed to the appropriate input data lines. When the write-signal is applied to the write-control line, these bits are written in the individual cells. The previous content in cells are automatically erased when the new information is written. In order to read the contents of the cells, a read signal is applied to the common read-line. The contents of the cells appear on the respective output data lines. The contents of individual cells are not erased by the read-operation as reading from these cells is assumed to be non-destructive. This interconnection of cells is called a register. This register stores three bits.
Figure 4.5: 3-Bit Register A group of registers may be interconnected to form a memory. Consider a memory that stores four words of three bits each. In this organization, the input data lines of the first bit of all four register are connected together. Similarly, the input data lines of the second bits are connected together and those of the third are also connected together The output lines of each of the bits of the registers are also connected together. Thus there are four Page 59
Page 60
Figure 4.7: Defining access time and write time in a memory Assume that at time t0 the address from which data is to be retrieved is placed in MAR and at time the t1 required data is available in MDR. The elapsed time (t1 - t0) is known as the access time of the memory. The access time is usually slightly larger than the readtime of individual cells in the memory. If data is to be written in the memory, the data is placed in MDR and the address in MAR at time t2 and a write-signal is initiated. If the writing operation is completed at time t3 then the elapsed time (t3 - t2) is called the write time.
Page 61
Page 62
Page 63
Read-Write
Read-Only
ROM
PROM
EPROM
EAPROM
Figure 4.8: Memory classification Serial Access Memory Consider the organization of memory cells shown in figure 4.9. In this organization the output of a cell is the input to the next cell. A read-signal places the contents of each of the cells on the respective output lines. A write-signal following this read-signal will store these bits in the respective next cells. One read-write pair of signals would thus shift the contents of the cells right by one cell position and the bit stored in the rightmost cell appear on the output line. A sequence of read-write signals will serially shift the contents of the register. After three read-write (namely, shift) signals the output will be 0. As the bits stored in the cells appear serially (that is one after another) at the output, this memory is called a serial access memory. If the output of the shift register is connected to its input, each shift-signal will circularly shift the contents of the memory. A series of shift-signals will keep the contents of the memory circulating.
Read
0 Input
Output
Output =1 Write
Page 64
Page 65
Page 66
C P U
P h y s ic a l m e m o r y
p f
p a g e t a b le
Figure 4.10: Paging Hardware The hardware support for paging is illustrated in Figure 4.10. Every address generated by the CPU is divided into two parts: a page number (p) and a page offset (d). The page number is used as an index into a page table. The page table contains the base address of each page in physical memory. This base address is combined with the page offset to define the physical memory address that is sent to the memory unit. The paging model of memory is shown in Figure 4.11. The page size (like the frame size) is defined by the hardware. The size of a page is typically a power of 2 varying between 512 bytes and 8192 bytes per page, depending on the computer architecture. The selection of a power of 2 as a page size makes the
Page 67
P d m-n n Where p is an index into the page table and d is the displacement within the page. When we use a paging scheme, we have no external fragmentation: Any free frame can be allocated to a process that needs it. However, we may have some internal fragmentation. If Process size is independent of page size, we expect internal fragmentation to average one-half page per process. This consideration suggests that small page sizes are desirable. However, there is quite a bit of overhead involved in each page-table entry and this overhead is reduced as the size of the pages increase. Also, disk I/O is more efficient when the number of data being transferred is larger. frame numbers
page 0 page 1 page 2 page 3
0 1
1 4
0
page 0
1
3
2
7
2
page 2
3 page tables
3
page 1
logical memory
4 5
page 3
6 7 physical memory Figure 4.11: Paging model of logical and physical memory
Page 68
Page 69
____________ ____________________ |____________| | ____________________| Figure 4.13: A segmented virtual address When paged memory is used, each memory address issued by the user program is typically interpreted as a single integer by that program, but the hardware breaks the address into two fields. The most significant field is the page number, while the least significant field is the word (or byte) number within that page, as is shown in Figure 4.14. address --- user view _______________________________ |___________|___________________| page number system view address within page ---
Figure 4.14: A paged virtual address For example, a 16 bit virtual address may be broken into an 8-bit page number, selecting one of 256 addressable pages and an 8-bit specification of the byte desired from that page. Unlike segments, pages are all of the same size and user data and program structures are usually placed in memory without regard to how those structures are broken up into pages. Independently of whether paged or segmented memory is used, it is conventional to refer to pages and segments as components of the user's address space, as opposed to referring to them as units of storage in memory or on disk. Thus, a particular page or segment may reside in main memory at some times and on disk at other times. The place where the segment is stored does not change its identity and the segment may be moved from one place to another many times during the execution of a program. 2.2.11. Memory Management
Page 70
Page 71
Page 72
Technology Semiconductor RAM Semiconductor ROM Magnetic (Hard) disk Optical disk
Storage Type Access Method Alterability Electronic Electronic Magnetic Optical Random Random Semirandom Semirandom Semirandom Semirandom Read / Write Read only Read / Write Read only Read / Write Read / Write
Page 73
In creasin g size
P cesso ro r
In creasin g s peed
In creasing co p b st er it
Memory hierarchy is adopted to achieve good price/performance ratio. Techniques that automatically swaps program and data blocks between main memory and secondary storage device are called Virtual memory. The addresses that processor issuesto access either instruction or data are called virtual or logical addresses. The memory management unit translates virtual address into physical addresses The technique of getting the desired page in the main memory is called demand paging. To support demand paging and virtual memory processor has to access page table which is kept in the main memory. To avoid the access time and degradation of performance, a small portion of the page table is accommodated in the memory management unit. This portion is called Translation Lookaside Buffer(TLB)
Comparison between different Mapping techniques: No. Direct mapping Associative Mapping 1 Each block from the A block of data from main memory has main memory can be only one possible placed into any location in the cache block cache. position. 2 Needs only one comparison Cache hit ratio Needs comparison with all tag bits Cache hit ratio has Page 74
Set associative mapping A block of data from main memory can go into a particular block location of any direct-mapped cache. Needs number of comparisons equal to number of blocks per set. The effect of
2.5) Summary
The major hardware components of a computer are - Input Devices, Output Devices and Central Processing Unit (CPU) Input Unit is that part of a computer through which the information is fed. The output unit refers to the device used for the display of the processed results. The Memory Unit of the CPU is the section where the program and data are stored after they are read through the input unit. Page 75
The address bus is a group of sixteen lines generally identified as A 0 to A15. The address bus is unidirectional: bits flow in one direction from the processor to peripheral devices. The data bus is a group of eight lines used for data flow. These lines are bidirectional data flow in both directions between the processor and peripheral devices. The signals on the I/O Memory Bus can be divided into three categories - Address lines, Data lines and Control Signals. Memory cells fabricated using current technology can be placed in one out of two stable states. One of the two stable states is used to represent the binary 0 and the other the binary 1. There are many types of ROM available for microcomputers like Mask ROM, PROM, EPROM, EEPROM and EAPROM. There are two types of RAM used in PCs - Dynamic and Static RAM. Every cache has two sub-systems, a tag subsystem which holds the memory addresses and determines whether there is a match for a requested datum; a memory subsystem which holds and delivers the data.
2.8) Assignments
1. A set associative cache consists of 64 lines, or slots, divided into four line set. Main memory contains 4 K blocks of 128 words each. Show the format of main memory addresses.
Page 76
2.11) Keywords
RAM ROM Static RAM Dynamic RAM Memory hierarchy Direct mapping Set associative mapping Demand paging Cache Associative mapping Virtual memory Segmentation
Page 77