Sunteți pe pagina 1din 25

Why Study Computer Organization and Architecture?

The IEEE/ACM Computer Curricula 2001 [JTF01], prepared by the Joint Task Force on Computing Curricula of the IEEE (Institute of Electrical and Electronics Engineers) Computer Society and ACM (Association for Computing Machinery), lists computer architecture as one of the core subjects that should be in the curriculum of all students in computer science and computer engineering. The report says the following: The computer lies at the heart of computing. Without it most of the computing disciplines today would be a branch of theoretical mathematics. To be a professional in any field of computing today, one should not regard the computer as just a black box that executes programs by magic. All students of computing should acquire some understanding and appreciation of a computer systems functional components, their characteristics, their performance, and their interactions. There are practical implications as well. Students need to understand computer architecture in order to structure a program so that it runs more efficiently on a real machine. In selecting a system to use, they should be able to understand the tradeoff among various components, such as CPU clock speed vs. memory size. 1. Suppose a graduate enters the industry and is asked the most cost-effective computer for use throughout a large organization. An understating of the implications of spending more for various alternatives, such as larger cache or a higher processor clock rate, is essential to making the decision. 2. Many processors are not used in PCs or servers but in embedded systems. A designer may program a processor in C that is embedded in some real-time or large system, such as an intelligent automobile electronics controller. Debugging the system may require the use of a logic analyzer that displays the relationship between interrupt requests from engine sensors and machine-level code.

3. Concepts used in computer architecture find application in other courses. In particular, the way in which the computer provides architectural support for programming languages and operating system facilities reinforces concepts from those areas.

Representation of Basic Information The basic functional units of computer are made of electronics circuit and it works with electrical signal. We provide input to the computer in form of electrical signal and get the output in form of electrical signal. There are two basic types of electrical signals, namely, analog and digital. The analog signals are continuous in nature and digital signals are discrete in nature. The electronic device that works with continuous signals is known as analog device and the electronic device that works with discrete signals is known as digital device. In present days most of the computers are digital in nature and we will deal with Digital Computer in this course. Computer is a digital device, which works on two levels of signal. We say these two levels of signal as High and Low. The High-level signal basically corresponds to some high-level signal (say 5 Volt or 12 Volt) and Low-level signal basically corresponds to Low-level signal (say 0 Volt). This is one convention, which is known as positive logic. There are others convention also like negative logic. Since Computer is a digital electronic device, we have to deal with two kinds of electrical signals. But while designing a new computer system or understanding the working principle of computer, it is always difficult to write or work with 0V or 5V. To make it convenient for understanding, we use some logical value, say, LOW (L) - will represent 0V and HIGH (H) - will represent 5V Computer is used to solve mainly numerical problems. Again it is not convenient to work with symbolic representation. For that purpose we move to numeric representation. In this convention, we use 0 to represent LOW and 1 to represent HIGH. 0 1 means means LOW HIGH

To know about the working principle of computer, we use two numeric symbols only namely 0 and 1. All the functionalities of computer can be captured with 0 and 1 and its theoretical background corresponds to two valued boolean algebra. With the symbol 0 and 1, we have a mathematical system, which is knows as binary number system. Basically binary number system is used to represent the information and manipulation of information in computer. This information is basically strings of 0s and 1s. The smallest unit of information that is represented in computer is known as Bit ( Binary Digit ), which is either 0 or 1. Four bits together is known as Nibble, and Eight bits together is known as Byte.

Computer technology has made incredible improvement in the past half century. In the early part of computer evolution, there were no stored-program computer, the computational power was less and on the top of it the size of the computer was a very huge one. Today, a personal computer has more computational power, more main memory,more disk storage, smaller in size and it is available in effordable cost. This rapid rate of improvement has come both from advances in the technology used to build computers and from innovation in computer design. In this course we will mainly deal with the innovation in computer design. The task that the computer designer handles is a complex one: Determine what attributes are important for a new machine, then design a machine to maximize performance while staying within cost constraints. This task has many aspects, including instruction set design, functional organization, logic design, and imple mentation. While looking for the task for computer design, both the terms computer organization and computer architecture come into picture. It is difficult to give precise definition for the terms Computer Organization and Computer Architecture. But while describing computer system, we come across these terms, and in literature, computer scientists try to make a distinction between these two terms. Computer architecture refers to those parameters of a computer system that are visible to a programmer or those parameters that have a direct impact on the logical execution of a program. Examples of architectural attributes include the instruction set, the number of bits used to represent different data types, I/O mechanisms, and techniques for addressing memory. Computer organization refers to the operational units and their interconnections that realize the architectural specifications. Examples of organizational attributes include those hardware details transparent to the programmer, such as control signals, interfaces between the computer and peripherals, and the memory technology used.

Basic Computer Model and different units of Computer The model of a computer can be described by four basic units in high level abstraction which is shown in figure 1.1. These basic units are:

Central Processor Unit Input Unit Output Unit Memory Unit


CPU O/P Devices

I/O Devices

Memory

Basic Computer Model and different units of Computer A. Central Processor Unit (CPU) : Central processor unit consists of two basic blocks :
o o

The program control unit has a set of registers and control circuit to generate control signals. The execution unit or data processing unit contains a set of registers for storing data and an Arithmatic and Logic Unit (ALU) for execution of arithmatic and logical operations.

In addition, CPU may have some additional registers for temporary storage of data. B. Input Unit : With the help of input unit data from outside can be supplied to the computer. Program or data is read into main storage from input device or secondary storage under the control of CPU input instruction. Example of input devices: Keyboard, Mouse, Hard disk, Floppy disk, CD-ROM drive etc. C. Output Unit : With the help of output unit computer results can be provided to the user or it can be stored in stograge device permanently for future use. Output data from main storage go to output device under the control of CPU output instructions.

Example of output devices: Printer, Monitor, Plotter, Hard Disk, Floppy Disk etc. D. Memory Unit : Memory unit is used to store the data and program. CPU can work with the information stored in memory unit. This memory unit is termed as primary memory or main memory module. These are basically semi conductor memories. There are two types of semiconductor memories Volatile Memory : RAM (Random Access Memory). Non-Volatile Memory : ROM (Read only Memory), PROM (Programmable ROM) EPROM (Erasable PROM), EEPROM (Electrically Erasable PROM). Secondary Memory : There is another kind of storage device, apart from primary or main memory, which is known as secondary memory. Secondary memories are non volatile memory and it is used for permanent storage of data and program. Example of secondary memories: ---------------These are magnetic devices, is optical device is semiconductor memory.

Hard Disk, Floppy Disk, Magenetic Tape CD-ROM Thumb drive (or pen drive)

The von Neumann architecture and is based on three key concepts: Data and instructions are stored in a single readwrite memory. The contents of this memory are addressable by location, without regard to the type of data contained there. Execution occurs in a sequential fashion (unless explicitly modified) from one instruction to the next.

A computer can be programmed by using a small set of basic logic components that store binary data and perform arithmetic and logical operations on data. If a particular computation is to be performed, a configuration of logic components designed specifically for that computation could be constructed. Programming in hardware is termed a hardwired program. This customized hardware system accepts data and produces results. This customized hardware system is not very flexible because for each new program, this customized hardware must be rewired. As an alternative, construct a general-purpose configuration of arithmetic and logic functions. This set of hardware will perform various functions on data depending on control signals applied to the hardware. This general-purpose hardware system accepts data and control signals and

produces results. For each new program, the programmer merely needs to supply a new set of control signals. How shall control signals be supplied? The entire program is actually a sequence of steps. At each step, some arithmetic or logic operation is performed on some data. For each step, a new set of control signals is needed. Simply provide a unique code for each possible set of control signals, and add to the general-purpose hardware a segment that can accept a code and generate control signals. Programming is now much easier. Instead of rewiring the hardware for each new program, simply provide a new sequence of codes. Each code is, in effect, an instruction, and part of the hardware interprets each instruction and generates control signals. To distinguish this new method of programming, a sequence of codes or instructions is called software. CPU combination of the instruction interpreter (control unit) and the general purpose arithmetic and logic functions (ALU) Input/Output module used to enter data and instructions and to report results Main memory module used to store both data and instructions Shown below are these top-level components and basic interaction between them:

The CPU exchanges data with memory. The CPU typically makes use of two internal registers: a memory address register (MAR), which specifies the address in memory for the next read or write, and a memory buffer register (MBR), which contains the data to be written into memory or receives the data read from memory. Similarly, an I/O address register (I/OAR) specifies a particular I/O device. An I/O buffer register (I/OBR) is used for the exchange of data between an I/O module and the CPU. A

memory module consists of a set of locations, defined by sequentially numbered addresses. Each location contains a binary number that can be interpreted as either an instruction or data. An I/O module transfers data from external devices to CPU and memory, and vise versa. It contains internal buffers for temporarily holding these data until they can be sent on.

Computer Function
The basic function performed by a computer is execution of a program, which consists of a set of instructions stored in memory. The processor does the actual work by executing instructions specified in the program. In the simplest form, instruction processing consists of two steps: the processor reads (fetches) instructions from memory one at a time and executes each instruction. The processing required for a single instruction is called an instruction cycle. An instruction cycle is shown below:

Program execution halts only if the machine is turned off, some sort of unrecoverable error occurs, or a program instruction that halts the computer is encountered. Instruction Fetch and Execute The processor fetches an instruction from memory program counter (PC) register holds the address of the instruction to be fetched next The processor increments the PC after each instruction fetch so that it will fetch the next instruction in the sequence unless told otherwise The fetched instruction is loaded into the instruction register (IR) in the processor the instruction contains bits that specify the action the processor will take The processor interprets the instruction and performs the required action In general, these actions fall into four categories: Processor-memory data transferred to or from the processor to memory Processor-I/O data transferred to or from a peripheral device by transferring between the processor and an I/O module Data processing the processor performs some arithmetic or logic operation on data Control an instruction may specify that the sequence of execution be altered An instruction execution may involve a combination of these actions. Characteristics of some Hypothetical Machine: Word size: 16 bits numbered (msb) 0 through 15 (lsb) Instruction format: 0 3 opcode 4 15 address

16 opcodes 4096 words Integer format: 0 sign bit 1 15 magnitude Program counter (PC) = address of instruction Instructions register (IR) = instruction being executed Accumulator (AC) = temporary storage 0001 (1 Hex) = load AC from memory 0010 (2 Hex) = store AC to memory 0101 (5 Hex) = add to AC from memory This figure below illustrates a partial program execution, showing the relevant portions of memory and processor registers. Adds the contents at addresses 940 and 941 and stores the result at address 941.

1. The PC contains 300. This instruction is loaded into the IR and the PC is incremented. Note that this process involves the use of a MAR and MBR. For simplicity, these intermediate registers are ignored. 2. The first 4 bit in the IR indicate that the AC is to be loaded. The remaining 12 bits specify the address from which data are to be loaded. 3. The next instruction is fetched from location 301 and the PC is incremented. 4. The old contents of the AC and the contents of location 941 are added and the result is stored in the AC. 5. The next instruction is fetched from location 302 and the PC is incremented. 6. The contents of the AC are stored in location 941. The execution cycle for a particular instruction may involve more than one reference to memory. An instruction may specify an I/O operation instead of a memory reference.

The state diagram below shows a more detailed look at the instruction cycle:

For any given instruction cycle, some state may be null and other may be visited more than once. These states can be described as follows: Instructions address calculation (iac): determine the address of the next instruction to be executed. Usually this involves adding a fixed number to the address of the previous instruction. Instruction fetch (if): read instruction from memory into the processor. Instruction operation decoding (iod): analyze instruction to determine type of operation to be performed and operand(s) to be used. Operand address calculation (oac): if the operation involves reference to an operand in memory or available via I/O, then determine the address of the operand. Operand fetch (of): fetch the operand from memory or read it in from I/O. Data operation (do): perform the operation indicated in the instruction. Operand store (os): write the result into memory or out to I/O.

Interrupts
Interrupts are a mechanism by which other modules (I/O, memory) may interrupt the normal processing of the processor. Common classes of interrupts: Program Generated by some condition that occurs as a result of an instruction execution, such as arithmetic overflow, division by zero, attempt to execute an illegal machine instruction, or reference outside a users allowed memory space. Timer Generated by a timer within the processor. This allows the operating system to perform certain functions on a regular basis.

I/O Generated by an I/O controller, to signal normal completion of an operation or to signal a variety of error conditions. Hardware failure Generated by a failure such as power failure or memory parity error. Interrupts are provided as a way to improve processing efficiency. For example, most external devices are much slower than the processor. Suppose that the processor is transferring data to a printer. After each write operation, the processor must pause and remain idle until the printer catches up. The length of this pause may be on the order of many hundreds or even thousands on instruction cycles that do not involve memory. Clearly, this is wasteful use of the processor.

The user program performs a series of WRITE calls interleaved with processing. Code segments 1, 2, and 3 refer to sequences of instructions that do not involve I/O. The WRITE calls are to an I/O program that is a system utility and that will perform the actual I/O operation. The I/O program consists of three sections: Instructions, labeled 4, to prepare for the actual I/O operations. The actual I/O command. Without interrupts the program would have to wait for the I/O device to perform the requested function. Instructions, labeled 5, to complete the operation.

Because the I/O operation may take a relatively long time to complete, the I/O program is hung up waiting for the operation to complete; hence, the user program is stopped at the point of the WRITE call for a considerable time period.

Interrupts and the Instruction Cycle With interrupts, the processor can be engaged in executing other instructions while an I/O operation is in progress. From the point of view of the user program, an interrupt is just an interruption of the normal sequence of execution. Shown below: To accommodate interrupts, an interrupt cycle is added to the instruction cycle as shown in the figure below:

To accommodate interrupts, an interrupt cycle is added to the instruction cycle as shown in the figure below:

In the interrupt cycle, the processor checks to see if any interrupts have occurred, indicated by the presence of an interrupt signal. If an interrupt is pending, the processor does the following: Suspends execution of the current program being executed and saves its context. It saves the address of the next instruction to be executed along with any other relevant data. Sets the PC to the starting address of an interrupt handling routine. Processes the interrupt. Restores the context of interrupted program and continues.

It is clear that there is some overhead involved in this process. Extra instructions must be executed (in the interrupt handler) to determine the nature of the interrupt and to decide on the appropriate action. Nevertheless, because of the relatively large amount of time that would be wasted by waiting on the I/O operation, the processor can be employed much more efficiently with the use of interrupts.

The timing diagrams above show the gain in efficiency from using interrupts. Shown below is the revised instruction cycle state diagram that includes interrupt cycle processing.

Multiple Interrupts The discussion so far has focused on the occurrence of a single interrupt. What if multiple interrupts occur? Two approaches can be taken when dealing with multiple interrupts: Disable interrupts while an interrupt is being processed o Processor ignores additional interrupts o Additional interrupts remain pending and are checked after current interrupt has been processed o Additional interrupts are handled in the order in which they occurred Define priorities for interrupts o Low priority interrupts can be interrupted by high priority interrupts o Low priority interrupt is returned to after high priority interrupt has been processed

Figure (a) above disable interrupts and figure (b) above prioritized interrupts.

The figure above shows the timing sequence of a system with three I/O devices: a printer, a disk, and a communications line, with increasing priorities of 2, 4, and 5, respectively. I/O Function Thus far, the discussion has focused on the operation of the computer as controlled by the processor, primarily focusing on the interaction of processor and memory. The discussion has only alluded to the role of the I/O component. An I/O module can exchange data directly with the processor. Just as the processor can initiate a read of write with memory, designating the address of a specific location, the processor can also read or write data to an I/O module. In this latter case, the processor identified a specific device that is controlled by a particular I/O module. In some cases, it is desirable to allow I/O exchanges to occur directly with memory. In such a case, the processor grants to an I/O module the authority to read from or write to memory, so that the I/O-memory transfer can occur without tying up the processor. During such a transfer, the I/O module issues read or write commands to memory, relieving the processor of responsibility for the exchange. This operation is known as direct memory access (DMA)

Interconnections Structures
A computer consists of a set of components or modules (processor, memory, I/O) that communicate with each other. A computer is a network of modules. There must be paths for connecting these modules. The collection of paths connecting the various modules is called the interconnection structure. Memory o Consists of N words of equal length. Typically memory is specified a N X M, Where 2N is the number of words and M is the word length, in number of bits. o Each word assigned a unique numerical address (0, 1, , N-1) o A word of data can be read or written

o Operation specified by control signals o Location specified by address signals

I/O Module
o o o o Similar to memory from computers viewpoint Consists of M external device ports (0, 1, , M-1) External data paths for input and output Sends interrupt signal to the processor

CPU Module o Reads in instructions and data o Writes out data after processing o Uses control signals to control overall operation of the system o Receives interrupt signals

The preceding list defines the data to be exchanged. The interconnection structure must support the following types of transfers: Memory to processor: processor reads an instruction or a unit of data from memory. Processor to memory: processor writes a unit of data to memory. I/O to processor: processor reads data from an I/O device via an I/O module. Processor to I/O: processor sends data to the I/O device via an I/O module. I/O to or from memory: an I/O module is allowed to exchange data directly with memory, without going through the processor, using direct memory access (DMA). Over the years, a number of interconnection structures have been tried. By far the most common is the bus and various multiple-bus structures.

Bus Interconnection
A bus is a communication pathway connecting two or more devices. Multiple devices can be connected to the same bus at the same time. Typically, a bus consists of multiple communication pathways, or lines. Each line is capable of transmitting signals representing binary 1 or binary 0. A bus that connects major computer components (processor, memory, I/O) is called a system bus. Bus Structure Typically, a bus consists of 50 to hundreds of separate lines. On any bus the lines are grouped into three main function groups: data, address, and control. There may also be power distribution lines for attached modules.

Data lines o Path for moving data and instructions between modules. o Collectively are called the data bus. o Consists of: 8, 16, 32, 64, etc bits key factor in overall system performance Address lines o Identifies the source or destination of the data on the data bus. CPU needs to read an instruction or data from a given memory location. o Bus width determines the maximum possible memory capacity for the system. 8080 has 16 bit addresses giving access to 64K address

Control lines o Used to control the access to and the use of the data and address lines. o Transmits command and timing information between modules. Typical control lines include the following: Memory write: causes data on the bus to be written to the addressed memory location. Memory read: causes data from the addressed memory location to be placed on the bus. I/O write: causes data on the bus to be output to the addressed I/O port. I/O read: causes data from the addressed I/O port to be placed on the bus. Transfer ACK: indicates that data have been from or placed on the bus. Bus request: indicates that a module needs to gain control of the bus. Bus grant: indicates that a requesting module has been granted control of the bus. Interrupt request: indicates that an interrupt is pending. Interrupt ACK: indicates that the pending interrupt has been recognized. Clock: used to synchronize operations. Reset: initializes all modules.

What does a bus look like? Parallel lines on a circuit board. Ribbon cables. Strip connectors of a circuit board. o PCI, AGP, PCI Express, SCSI, etc Sets of wires.

Arithmetic and logic Unit (ALU) ALU is responsible to perform the operation in the computer. The basic operations are implemented in hardware level. ALU is having collection of two types of operations:

Arithmetic operations Logical operations

Consider an ALU having 4 arithmetic operations and 4 logical operation. To identify any one of these four logical operations or four arithmetic operations, two control lines are needed. Also to identify the any one of these two groups- arithmetic or logical, another control line is needed. So, with the help of three control lines, any one of these eight operations can be identified.

Consider an ALU is having four arithmetic operations. Addition, subtraction, multiplication and division. Also consider that the ALU is having four logical operations: OR, AND, NOT & EX-OR. We need three control lines to identify any one of these operations. The input combination of these control lines are shown below: Control line is used to identify the group: logical or arithmetic, ie : logical operation.

: arithmetic operation

Control lines and are used to identify any one of the four operations in a group. One possible combination is given here.

decode is used to decode the instruction. The block diagram of the ALU is shown in figure 2.1.

Figure 2.1: Block Diagram of the ALU The ALU has got two input registers named as A and B and one output storage register, named as C. It performs the operation as: C = A op B The input data are stored in A and B, and according to the operation specified in the control lines, the ALU perform the operation and put the result in register C.

As for example, if the contents of controls lines are, 000, then the decoder enables the addition operation and it activates the adder circuit and the addition operation is performed on the data that are available in storage register A and B . After the completion of the operation, the result is stored in register C. We should have some hardware implementations for basic operations. These basic operations can be used to implement some complicated operations which are not feasible to implement directly in hardware. There are several logic gates exists in digital logic circuit. These logic gates can be used to implement the logical operation. Some of the common logic gates are mentioned here. AND gate: The output is high if both the inputs are high. The AND gate and its truth table is shown in Figure 2.2.

Figure 2.2: AND gate and its truth table. OR gate: The output is high if any one of the input is high. The OR gate and its truth table is shown in Figure 2.3.

Figure 2.3: OR gate and its truth table. EX-OR gate: The output is high if either of the input is high. The EX-OR gate and its truth table is given in Figure 2.4.

Figure 2.4: EX-OR gate and its truth table. If we want to construct a circuit which will perform the AND operation on two 4-bit number, the implementation of the 4-bit AND operation is shown in the Figure-2.5.

Figure2.5: 4-bit AND operator

INTEGER REPRESENTATION
In the binary number system,1 arbitrary numbers can be represented with just the digits zero and one, the minus sign, and the period, or radix point. -1101.01012 = -13.312510 For purposes of computer storage and processing, however, we do not have the benefit of minus signs and periods. Only binary digits (0 and 1) may be used to represent numbers. If we are limited to nonnegative integers, the representation is straightforward. An 8-bit word can represent the numbers from 0 to 255, including 00000000 = 0 00000001 = 1 00101001 = 41 10000000 = 128 11111111 = 255 In general, if an n-bit sequence of binary digits an-1 an-2 .. a1a0 is interpreted as an unsigned integer A, its value is

A 2 i ai
i 0

n 1

S-ar putea să vă placă și