Question? Leave a message!

Computer Organization and Architecture Lecture Notes

lecture notes on computer organisation and architecture | pdf free download
HowdyNicolson Profile Pic
Published Date:09-07-2017
Website URL
Computer Organization and Architecture Study Material for MS-07/MCA/204 Directorate of Distance Education Guru Jambheshwar University of Science &Technology, HisarUnit 1 Principles of Computer Design Learning Objectives After completion of this unit, you should be able to : • describe software and hardware interaction layers in computer architecture • Describe central processing unit • Describe various machine language instructions • Describe various addressing modes • Describe various instruction types and Instruction cycle Introduction Copy from page-12, BSIT-301, PTU Software Software, or program enables a computer to perform specific tasks, as opposed to the physical components of the system (hardware). This includes application software such as a word processor, which enables a user to perform a task, and system software such as an operating system, which enables other software to run properly, by interfacing with hardware and with other software or custom software made to user specifications. Types of Software Practical computer systems divide software into three major classes: system software, programming software and application software, although the distinction is arbitrary, and often blurred. • System software helps run the computer hardware and computer system. It includes operating systems, device drivers, diagnostic tools, servers, windowing systems, utilities and more. The purpose of systems software is to insulate the applications programmer as much as possible from the details of the particular computer complex being used, especially memory and other hardware features, and such accessory devices as communications, printers, readers, displays, keyboards, etc. • Programming software usually provides tools to assist a programmer in writing computer programs and software using different programming languages in a more convenient way. The tools include text editors, compilers, interpreters, 1linkers, debuggers, and so on. An Integrated development environment (IDE) merges those tools into a software bundle, and a programmer may not need to type multiple commands for compiling, interpreter, debugging, tracing, and etc., because the IDE usually has an advanced graphical user interface, or GUI. • Application software allows end users to accomplish one or more specific (non- computer related) tasks. Typical applications include industrial automation, business software, educational software, medical software, databases, and computer games. Businesses are probably the biggest users of application software, but almost every field of human activity now uses some form of application software. It is used to automate all sorts of functions. Operation Computer software has to be "loaded" into the computer's storage (such as a hard drive, memory, or RAM). Once the software is loaded, the computer is able to execute the software. Computers operate by executing the computer program. This involves passing instructions from the application software, through the system software, to the hardware which ultimately receives the instruction as machine code. Each instruction causes the computer to carry out an operation moving data, carrying out a computation, or altering the control flow of instructions. Data movement is typically from one place in memory to another. Sometimes it involves moving data between memory and registers which enable high-speed data access in the CPU. Moving data, especially large amounts of it, can be costly. So, this is sometimes avoided by using "pointers" to data instead. Computations include simple operations such as incrementing the value of a variable data element. More complex computations may involve many operations and data elements together. Instructions may be performed sequentially, conditionally, or iteratively. Sequential instructions are those operations that are performed one after another. Conditional instructions are performed such that different sets of instructions execute depending on the value(s) of some data. In some languages this is known as an "if" statement. Iterative instructions are performed repetitively and may depend on some data value. This is sometimes called a "loop." Often, one instruction may "call" another set of instructions that are defined in some other program or module. When more than one computer processor is used, instructions may be executed simultaneously. A simple example of the way software operates is what happens when a user selects an entry such as "Copy" from a menu. In this case, a conditional instruction is executed to copy text from data in a 'document' area residing in memory, perhaps to an intermediate storage 2area known as a 'clipboard' data area. If a different menu entry such as "Paste" is chosen, the software may execute the instructions to copy the text from the clipboard data area to a specific location in the same or another document in memory. Depending on the application, even the example above could become complicated. The field of software engineering endeavors to manage the complexity of how software operates. This is especially true for software that operates in the context of a large or powerful computer system. Currently, almost the only limitations on the use of computer software in applications is the ingenuity of the designer/programmer. Consequently, large areas of activities (such as playing grand master level chess) formerly assumed to be incapable of software simulation are now routinely programmed. The only area that has so far proved reasonably secure from software simulation is the realm of human art— especially, pleasing music and literature. Kinds of software by operation: computer program as executable, source code or script, configuration. Hardware Computer hardware is the physical part of a computer, including the digital circuitry, as distinguished from the computer software that executes within the hardware. The hardware of a computer is infrequently changed, in comparison with software and data, which are "soft" in the sense that they are readily created, modified or erased on the computer. Firmware is a special type of software that rarely, if ever, needs to be changed and so is stored on hardware devices such as read-only memory (ROM) where it is not readily changed (and is therefore "firm" rather than just "soft"). Most computer hardware is not seen by normal users. It is in embedded systems in automobiles, microwave ovens, electrocardiograph machines, compact disc players, and other devices. Personal computers, the computer hardware familiar to most people, form only a small minority of computers (about 0.2% of all new computers produced in 2003). Personal computer hardware A typical pc consists of a case or chassis in desktop or tower shape and the following parts: 3 Typical Motherboard found in a computer • Motherboard or system board with slots for expansion cards and holding parts o Central processing unit (CPU) Computer fan - used to cool down the CPU o Random Access Memory (RAM) - for program execution and short term data storage, so the computer does not have to take the time to access the hard drive to find the file(s) it requires. More RAM will normally contribute to a faster PC. RAM is almost always removable as it sits in slots in the motherboard, attached with small clips. The RAM slots are normally located next to the CPU socket. o Basic Input-Output System (BIOS) or Extensible Firmware Interface (EFI) in some newer computers o Buses • Power supply - a case that holds a transformer, voltage control, and (usually) a cooling fan • Storage controllers of IDE, SATA, SCSI or other type, that control hard disk, floppy disk, CD-ROM and other drives; the controllers sit directly on the motherboard (on-board) or on expansion cards • Video display controller that produces the output for the computer display. This will either be built into the motherboard or attached in its own separate slot (PCI, PCI-E or AGP), requiring a Graphics Card. • Computer bus controllers (parallel, serial, USB, FireWire) to connect the computer to external peripheral devices such as printers or scanners • Some type of a removable media writer: o CD - the most common type of removable media, cheap but fragile. CD-ROM Drive CD Writer o DVD DVD-ROM Drive DVD Writer DVD-RAM Drive o Floppy disk o Zip drive o USB flash drive AKA a Pen Drive o Tape drive - mainly for backup and long-term storage • Internal storage - keeps data inside the computer for later use. o Hard disk - for medium-term storage of data. o Disk array controller • Sound card - translates signals from the system board into analog voltage levels, and has terminals to plug in speakers. 4• Networking - to connect the computer to the Internet and/or other computers o Modem - for dial-up connections o Network card - for DSL/Cable internet, and/or connecting to other computers. • Other peripherals In addition, hardware can include external components of a computer system. The following are either standard or very common. • Input devices o Text input devices Keyboard o Pointing devices Mouse Trackball o Gaming devices Joystick Game pad Game controller o Image, Video input devices Image scanner Webcam o Audio input devices Microphone • Output devices o Image, Video output devices Printer: Peripheral device that produces a hard copy. (Inkjet, Laser) Monitor: Device that takes signals and displays them. (CRT, LCD) o Audio output devices Speakers: A device that converts analog audio signals into the equivalent air vibrations in order to make audible sound. Headset: A device similar in functionality to that of a regular telephone handset but is worn on the head to keep the hands free. Student-Activity 1. What is computer Software? 2. What is computer Hardware? 3. List various Input and Output devices. 4. Describe various Audio Output devices. 5. What is the function of RAM 5Software-Hardware Interaction layers in Computer Architecture In computer engineering, computer architecture is the conceptual design and fundamental operational structure of a computer system. It is a blueprint and functional description of requirements (especially speeds and interconnections) and design implementations for the various parts of a computer — focusing largely on the way by which the central processing unit (CPU) performs internally and accesses addresses in memory. It may also be defined as the science and art of selecting and interconnecting hardware components to create computers that meet functional, performance and cost goals. "Architecture" therefore typically refers to the fixed internal structure of the CPU (i.e. electronic switches to represent logic gates) to perform logical operations, and may also include the built-in interface (i.e. opcodes) by which hardware resources (i.e. CPU, memory, and also motherboard, peripherals) may be used by the software. It is frequently confused with computer organization. But computer architecture is the abstract image of a computing system that is seen by a machine language (or assembly language) programmer, including the instruction set, memory address modes, processor registers, and address and data formats; whereas the computer organization is a lower level, more concrete, description of the system that involves how the constituent parts of the system are interconnected and how they interoperate in order to implement the architectural specification. 6 Fig : A typical vision of a computer architecture as a series of abstraction layers: hardware, firmware, assembler, kernel, operating system and applications Abstraction Layer An abstraction layer (or abstraction level) is a way of hiding the implementation details of a particular set of functionality. Perhaps the most well known software models which use layers of abstraction are the OSI 7 Layer model for computer protocols, OpenGL graphics drawing library, and the byte stream I/O model originated by Unix and adopted by MSDOS, Linux, and most other modern operating systems. In computer science, an abstraction level is a generalization of a model or algorithm, away from any specific implementation. These generalizations arise from broad similarities that are best encapsulated by models that express similarities present in various specific implementations. The simplification provided by a good abstraction layer allows for easy reuse by distilling a useful concept or metaphor so that situations where it may be accurately applied can be quickly recognized. A good abstraction will generalize that which can be made abstract; while allowing specificity where the abstraction breaks down and its successful application requires customization to each unique requirement or problem. Firmware 7In computing, firmware is software that is embedded in a hardware device. It is often provided on flash ROMs or as a binary image file that can be uploaded onto existing hardware by a user. Firmware is defined as: • the computer program in a read-only memory (ROM) integrated circuit (a hardware part number or other configuration identifier is usually used to represent the software); • the erasable programmable read-only memory (EPROM) chip, whose program may be modified by special external hardware, but not by a general purpose application program. • the electrically erasable programmable read-only memory (EEPROM) chip, whose program may be modified by special electrical external hardware (not the usual optical light), but not by a general purpose application program. Assembler An assembly language program is translated into the target computer's machine code by a utility program called an assembler.Typically a modern assembler creates object code by translating assembly instruction mnemonics into opcodes, and by resolving symbolic names for memory locations and other entities. The use of symbolic references is a key feature of assemblers, saving tedious calculations and manual address updates after program modifications. Kernel In computing, the kernel is the central component of most computer operating systems (OSs). Its responsibilities include managing the system's resources and the communication between hardware and software components. As a basic component of an operating system, a kernel provides the lowest-level abstraction layer for the resources (especially memory, processor and I/O devices) that applications must control to perform their function. It typically makes these facilities available to application processes through inter-process communication mechanisms and system calls. These tasks are done differently by different kernels, depending on their design and implementation. While monolithic kernels will try to achieve these goals by executing all the code in the same address space to increase the performance of the system, micro kernels run most of their services in user space, aiming to improve maintainability and 8modularity of the code base. A range of possibilities exists between these two extremes. Fig : A kernel connects the application software to the hardware of a computer. Operating System An operating system (OS) is a computer program that manages the hardware and software resources of a computer. At the foundation of all system software, an operating system performs basic tasks such as controlling and allocating memory, prioritizing system requests, controlling input and output devices, facilitating networking, and managing files. It also may provide a graphical user interface for higher level functions. It forms a platform for other software. Application Software Application software is a subclass of computer software that employs the capabilities of a computer directly to a task that the user wishes to perform. This should be contrasted with system software which is involved in integrating a computer's various capabilities, but typically does not directly apply them in the performance of tasks that benefit the user. In this context the term application refers to both the application software and its implementation. Central Processing Unit Copy introduction from page-66, BSIT-301, PTU 9Student Activity 1. Describe various software-hardware interaction layers in computer hardware. 2. Define CPU. Describe its various parts. Machine Language Instructions A computer executes machine language programs mechanically that is without understanding them or thinking about them simply because of the way it is physically put together. This is not an easy concept. A computer is a machine built of millions of tiny switches called transistors, which have the property that they can be wired together in such a way that an output from one switch can turn another switch on or off. As a computer computes, these switches turn each other on or off in a pattern determined both by the way they are wired together and by the program that the computer is executing. Machine language instructions are expressed as binary numbers. A binary number is made up of just two possible digits, zero and one. So, a machine language instruction is just a sequence of zeros and ones. Each particular sequence encodes some particular instruction. The data that the computer manipulates is also encoded as binary numbers. A computer can work directly with binary numbers because switches can readily represent such numbers: Turn the switch on to represent a one; turn it off to represent a zero. Machine language instructions are stored in memory as patterns of switches turned on or off. When a machine language instruction is loaded into the CPU, all that happens is that certain switches are turned on or off in the pattern that encodes that particular instruction. The CPU is built to respond to this pattern by executing the instruction it encodes; it does this simply because of the way all the other switches in the CPU are wired together. Addressing Modes Copy from page-66 to page-69, upto student activity, BSIT-301, PTU Instruction Types 10The type of instruction is recognized by the computer control from the four bits in position 12 through 15 of the instruction. If the three opcode bits in positions 12 through 14 are not equal to 111, the instruction is a memory reference type and the bit in the position 15 is taken as the addressing mode. If the bit is 1, the instruction is an input-output instruction. Only three bits of the instruction are used for the operation code. It may seem that the computer is restricted to a maximum of eight distinct operations. Since register reference and input output instructions use the remaining 12 bits as part of the total number of instruction chosen for the basic computer is equal to 25. Data Movement Instructions: Assembly Language Machine Language Example: Meaning: Instruction: Instruction: 1 000 0001 0 RR MMMMM LOAD REG MEM LOAD R2 13 R2 = M13 1 000 0010 0 RR STORE MEM REG STORE 8 R3 M8 = R3 MMMMM MOVE REG1 REG2 MOVE R2 R0 R2 = R0 1 001 0001 0000 RR RR Arithmetic and Logic Instructions: Machine Language Instruction: Example: Meaning: Instruction: ADD REG1 REG2 ADD R3 R2 1 010 0001 00 RR RR REG3 R1 RR SUB REG1 REG2 SUB R3 R1 R3 = R2 + R1 1 010 0010 00 RR RR REG3 R0 R3 = R1 - R0 RR AND REG1 REG2 AND R0 R3 R0 = R3 & R1 1 010 0011 00 RR RR REG3 R1 R2 = R2 R3 RR OR REG1 REG2 OR R2 R2 1 010 0100 00 RR RR REG3 R3 RR Branching Instructions: 11Machine Language Instruction: Example: Meaning: Instruction: PC = 10 BRANCH MEM BRANCH 10 PC = 2 IF ALU RESULT 0 000 0001 000 MMMMM BZERO MEM BZERO 2 IS ZERO 0 000 0010 000 MMMMM BNEG MEM BNEG 7 PC = 7 IF ALU RESULT 0 000 0011 000 MMMMM IS NEGATIVE Other Instructions: Machine Language Instruction: Example: Meaning: Instruction: NOP NOP Do nothing. 0000 0000 0000 0000 HALT HALT Halt the machine. 1111 1111 1111 1111 Student Activity 1. How will you express machine level instructions? 2. How does the computer control recognize the type of instruction? 3. Describe various types of machine level instructions. 4. Describe the addressing mode of computer instructions. Instruction Set Selection Copy from page-30, MCA-204, GJU (While designing …….. upto 4 points, before timing and control) Instructions on a RISC architecture are structured in a systematic way. They can be categorized into ALU operations, memory operations, and control operations. ALU operations always work on registers, and every register from the register set can be addressed by every ALU operation. Memory operations move values between the register set and memory. This structure makes instruction selection relatively easy, and the Java data types map 1:1 to the instruction architecture. The optimal selection of instructions is more complex on x86 than it is on Alpha for the following reasons: • Different addressing modes: Because a lot of operations exist in different addressing modes, unlike a RISC processor, the correct kind of instruction needs to be chosen in order to avoid any additional instructions for moving values. For example if the values for an addition operation are in a memory and in a register 12the instruction selection algorithm always picks an add instruction that adds a memory and a register location. • Limited set of registers per instruction: When picking the next instruction, the code generator always checks in which registers the current values are in and chooses the instruction appropriately. If the current register allocation doesn't fit to the instruction at all, values need to be moved. This scheme could be improved with more global analysis, but at the expense of a larger compile-time cost. • Efficient 64-bit operations: The Java bytecode contains 64-bit integer and floating-point operations that the x86 platform needs to support. For each of these bytecode operations the number of temporary registers and the amount of memory accesses need to be minimized. For example, the following code is one possible implementation of the add (64-bit integer addition) bytecode instruction. • mov 0x0(%esp,1),%eax • add 0x8(%esp,1),%eax • mov 0x4(%esp,1),%ecx • adc 0x10(%esp,1),%ecx Timing and control Copy from page-30, MCA-204, GJU Instruction Cycle Copy from page-63-64, Instruction Cycle, MCA-301, PTU Execution Cycle Copy from page-50 to 54, (Instruction Execution), BSIT-301, PTU Student Activity 1. Define an instruction cycle. Describe its various parts. 2. While designing the instruction set of a computer, what are the important things to be kept in mind? When is a set of instructions said to be complete? 3. Describe the execution cycle of an instruction. Summary • Our computer system consists of software and hardware. Software, or program enables a computer to perform specific tasks, as opposed to the physical components of the system (hardware). • Computer hardware is the physical part of a computer, including the digital circuitry, as distinguished from the computer software that executes within the hardware. • Computer architecture is defined as the science and art of selecting and interconnecting hardware components to create computers that meet functional, performance and cost goals. • A computer architecture is considered as a series of abstraction layers: hardware, firmware, assembler, kernel, operating system and applications • (copy summary from page-33, MCA-204, GJU) 13• A program has a sequence of instructions which gets executed through a cycle , called instruction cycle. The basic parts of and instruction cycle include fetch, decode, read the effective address from memory and execute. Keywords Copy the following from page-33, MCA-204, GJU • Instruction code • Computer register • System bus • External bus • Input/Output • Interrupt Copy the following from page-69, MCA-301, PTU • Common Bus • Fetch • Control Flow Chart Review Questions 1. Define software and hardware. 2. Describe the function of firmware. 3. What is the role of kernel. 4. What are applications? 5. Describe various machine language instructions. 6. Give different phases of instruction cycle. 7. What is the significance of instruction? 8. How are computer instructions identified. 9. What do you understand by the term instruction code? 10. Describe the time and control of instructions. Further Readings Copy from page-34, MCA-204, GJU 14Unit-2 Control Unit and Microprogramming Learning Objectives After completion of this unit, you should be able to : • describe control unit • describe data path and control path design • describe microprogramming • comparing microprogramming and hardwired control • comparing RISC and CISC architecture • Describe pipelining in CPU Design • Describe superscalar processors Introduction Copy from page-97-98, MCA-301, PTU Control Unit As the name suggests, a control unit is used to control something. In this case, the control unit provides instructions to the other CPU devices (previously listed) in a way that causes them to operate coherently to achieve some goal as shown in Fig. (2.1). Basically, there is one control unit, because two control units may cause conflict. The control unit of a simple CPU performs the FETCH / DECODE / EXECUTE / WRITEBACK von Neumann sequence. Figure 2.1: A general control unit. To describe how the CPU works we may describe what signals the control unit issues and when. Clearly these instructions are more complicated than those that the control unit receives as input. Thus the control unit must store the instructions within itself, perhaps using a memory or perhaps in the form of a complicated network. 15In either case, let us describe what the control unit does in terms of a program (for ease of understanding) called the micro-program, consisting naturally of micro-instructions. Let the micro-program be stored in a micro-memory. Figure 2.2: Micro-architectural view of the control unit. The control unit may not be micro-programmed, however we can still use micro-instructions to indicate what the control unit is doing. In this case we take a logical view of the control unit. The possible instructions are dictated by the architecture of the CPU. Different architectures allow for different instructions and this is a major concept to consider when examining CPU design and operation. We are not interested in design in this subject, but we concentrate on operation. Basic control unit operation You should recall that the basic operation of the CPU is described by the FETCH / DECODE / EXECUTE / WRITEBACK sequence. The control unit is used to implement this sequence using a micro-program. Of the following registers, the first two are a normally only available to the control unit. • Instruction Register, : Stores the number that represents the machine instruction the Control Unit is to execute. (note that this is not the micro- instruction) 16• Program Counter, : Stores the number that represents the address of the next instruction to execute (found in memory). • General Purpose Registers: Examples are , , , , , to store intermediate results of execution. Consider the example of a as shown in Fig. (2.3). The control unit is not shown. Figure 2.3: PDP8 micro-architecture. Modern computers are more complex, but the operation is essentially the same. First consider the micro-program executed by the Control Unit to provide the FETCH: 1. 2. 3. 17Note the first line may be written , but in this case the path is inferred from the diagram. The second line instructs the memory sub-system to retrieve the contents of the memory at address given by , the contents is put into . The third line does two things at the same time, moves the into the for DECODING and EXECUTING plus it instructs the to increase by 1, so as to point to the next instruction for execution. This increment instruction is available for some registers like the . The ALU does not have to be used in this case. Consider some more small examples of micro-programs which use the PDP8 micro-architecture. Example zero into the register: 1. Example the contents of the to the and put the result in the . 1. 2. Example the two's complement of . 1. 2. 18 Example the to obtain the next instruction. 1. 2. Where is previously defined. Function of Control Unit Copy from page-36, (third para after figure) The function of a Control unit in a digital system ……… upto page -37, Student activity- 1, MCA-204, GJU Data path and control path design A stored program computer consists of a processing unit and an attached memory system. Commands that instruct the processor to perform certain operations are placed in the memory along with the data items to be operated on. The processing unit consists of data-path and control. The data-path contains registers to hold data and functional units, such as arithmetic logic units and shifters, to operate on data. The control unit is little more than a finite state machine that sequences through its states to (1) fetch the next instruction from memory, (2) decode the instruction to interpret its meaning, and (3) execute the instruction by moving and/or operating on data in the registers and functional units of the data-path. The critical design issues for a data-path are how to "wire" the various components together to minimize hardware complexity and the number of control states to complete a typical operation. For control, the issue is how to organize the relatively complex "instruction interpretation" finite state machine. Microprogramming Copy from page-102 to page-111, upto student activity, MCA-301, PTU RISC Vs. CISC Copy overview of RISC/CISC from page-111 Reduced Instruction Set Computer (RISC) Copy section 4.3, page-38, MCA-204, GJU RISC Characteristics Copy from page-112, MCA-301, PTU 19