Chapter 2: Computer Organization PDF
Document Details
Uploaded by AdroitEinsteinium
My School
2012
IBO
Tags
Summary
This document is a chapter from a computer science textbook, focusing on computer organization and computer architecture. It explains concepts like the input, process, output, and storage model, accompanied by examples. The chapter also touches on the fundamental unit of computer systems, the bit and introduces the concept of the computer CPU.
Full Transcript
## Chapter 2: Computer Organization ### Topic 2: Computer Organization **Topic 2 Computer organization** **Computer Architecture** 2.1.1 The central processing unit (CPU) and its elements * **Exit skills:** Students should be able to: * Define the terms CPU, ALU, CU, MAR, MDR, Address Bus,...
## Chapter 2: Computer Organization ### Topic 2: Computer Organization **Topic 2 Computer organization** **Computer Architecture** 2.1.1 The central processing unit (CPU) and its elements * **Exit skills:** Students should be able to: * Define the terms CPU, ALU, CU, MAR, MDR, Address Bus, and Data Bus * Develop a diagram of the CPU showing connections between the elements mentioned above. Computer systems consist of hardware and software components and follow the concept of the input, process, output, and storage model. This means that a computer system takes in some data as input, processes it in a manner that we have requested and outputs the result in some way. During the processing phase, other data may be needed apart from the inputted. This data will exist in the storage of the computer system and will be used during the processing phase. Furthermore, any new information that may arise from the processing phase may also be saved in the storage. **Example 2.1:** Imagine that we have a digital camera which is a sort of computer system. In order to take a picture the system, follows the input, process, output, and storage model. * The input is the pressing of the shutter button to notify the system that we want to take a photograph. * The process that the computer system performs is to capture the light through the camera lens and transform it to create a digital image. This transformation requires instructions that exist in the storage. These instructions are loaded and used by the processing phase. * Finally, the output is the digital image that we view on the monitor screen of the camera. This output is also saved on the storage (memory). The input, process, and output model is shown in Figure 2.1, outlining the relationship between the components of a computer system. More specifically, a computer system accepts data or instructions as input from an input device (from a keyboard, a sensor, a digital camera button etc.). Data or instructions are then processed by the computer system. It may be the case that other data or instructions, apart from the input, are necessary during processing. These exist in the storage and may be loaded and used. Finally, the computer system outputs the processed data into information that we can see and use (using a monitor, speakers, a printout, etc.). This output is also saved on the storage (memory). Data or instructions that are processed by a computer system in the process phase of the input, process, output, and storage model are processed by the central processing unit (CPU). The CPU is a hardware component of a computer system and can perform basic arithmetic, logical or input/output operations, in order to process data from input devices into useful information. The CPU is the "brain" of a computer system and can process data very quickly but can only process data by following instructions - it cannot think for itself. The CPU can also be referred to as the processor or chip. A block diagram can be created to represent the elements that compromise it. This block diagram is shown in Figure 2.2. The CPU functions in the process phase of the input, process, output, and storage model. It retrieves and saves data and information from and to the storage, which is the primary memory of the computer system. Any data or information that is to be saved on or retrieved from some storage medium (ex. hard disk, CD, DVD, floppy disk, USB stick) first has to pass through the primary memory in order to be accessed by the CPU. As such, the CPU can retrieve data only from the input or primary memory of the computer system. **The CPU contains the:** * Control unit (CU) * Arithmetic logic unit (ALU) * Memory address register (MAR) * Memory data register (MDR) The control unit (CU) is responsible for the operation of the CPU. It controls the retrieval of instructions from the primary memory as well as the sequence of their execution. The arithmetic logic unit (ALU) performs all the basic arithmetic, logical or input/output operations. The CU is responsible for providing the ALU with the data that needs to be processed as well as the instructions of how the data should be processed. As shown in Figure 2.2 the primary memory used as storage contains two types of memory - **The terms bit (b), Byte (B) and their multiples** Computer systems are binary systems. That means that all the data and instructions that are stored in a computer system are stored in sequences of binary digits that can take only two possible values, 1 and 0. Thus a binary digit (bit) is the basic unit of information in computer systems and can have only two values either 1 or 0. Eight bits form a byte. 1 Byte = 8 bits A bit is denoted by the small letter b, whereas a byte is denoted by the capital letter B. Thus, 1B = 8b. One byte can store a single character (ex. the letter A). In a 64 bit computer each memory location holds 64 bits. A 64 bit Memory (Address) Bus transfers 64 bits at any one time (which are the contents of a memory location in a 64 bit computer system). In computer systems we describe everything in bits and bytes. As such, they are used to denote file sizes stored on memory or disks (ex. a 12MB file) or even connection speeds (ex. 50Mbps); however, since files can become quite large and connection speeds quite fast, multiples of bits and bytes are used. The following table depicts the prefixes that can be used to denote multiples of bits and bytes. | Term | Size in binary system | Size approximation | |---|---|---| | Kilo (K) | 1,024 | 1,000 | | Mega (M) | 1,024<sup>2</sup> | 1,000,000 | | Giga (G) | 1,024<sup>3</sup> | 1,000,000,000 | | Tera (T) | 1,024<sup>4</sup> | 1,000,000,000,000 | In the decimal system, one kilometer is 1,000 meters. However, since computer systems are binary, a "Kilo" is 1,024. Since these two values are close there is a tendency to use multiples of 1,000 instead of 1,024 in the binary system as well. It is important not to mix the meaning of bits and bytes and their multiples. For example, the values of 12Mb (twelve mega bit) and 12MB (twelve mega bytes) are different. 12 Mb = 12 * 1,024<sup>2</sup> bits whereas 12 MB = 12 * 1,024<sup>2</sup> Bytes Since 1 Byte is equal to 8 bits, 12MB is an amount 8 times greater than 12Mb. The random access memory (RAM) and the read only memory (ROM). * The RAM stores the executing program instructions as well as any data that is needed. Instructions and data in the RAM are stored in unique memory locations and every such location has an address as well as content. The content is where the instructions and data reside, whereas the memory location is used by the CU to find, retrieve and access the data in order to send it to the ALU for processing. * Similar to the RAM, the ROM holds instructions and data in unique memory locations. Every such location has an address as well as content. Unlike the RAM however, the ROM is used to store permanent instructions and data that cannot be changed and are used to boot and operate the computer. As such, nothing can be altered in the ROM. ## Example 2.2: **Question:** In order to move from higher prefixes to lower prefixes, we multiply by 1,024. For example, if a file has a size of 2GBs the file size in KBs will be 2 * 1,024 * 1,024. We multiply 2 by 1024 in order to get the file size in MBs and then multiply by 1,024 again to get the file size in KBs. **2GBs = 2* 1,024 MBs = 2,048 MBs = 2,048 * 1,024 KBs = 2,097,152 KBs** **Question:** In order to move from lower prefixes to higher prefixes, we divide by 1,024. For example, if a file has a size of 2KBs the file size in GBs will be (2 / 1,024) / 1,024. We divide 2 by 1,024 in order to get the file size in MBs and then divide by 1,024 again to get the file size in GBs. **2KBs = 2/1,024 MBs = 0.001953125 MBs = 0.001953125 / 1,024 GBs = 0.0000019073486328125 GBs** The CU contains various registers. In general, a register is a small storage location that can hold data, usually a multiple of 8 bits. For example, a 64 bit computer has 64 bit registers. The size of the register in bytes is known as a word. For example, the 64 bit register holds 64 bits = 8 * 8 bits and since 1 byte is equal to 8 bits, 64 bits = 8 Bytes. Thus, a 64 bit computer system has a word size of 8 bytes. This means that each memory location will hold 64 bits (or 8 Bytes). The basic registers in the CU are the memory address register (MAR) and the memory data register (MDR). * The MAR holds the memory address of the data to be used by the ALU, so that the ALU can fetch the corresponding content from the memory and process it accordingly. The MAR may also hold the memory address of where data that has been processed will need to be stored. In order for the MAR to communicate with the primary memory, a connection is necessary. This connection is accomplished by the Memory (Address) Bus. * The MDR holds the data that is to be used by the ALU and then saved to the RAM. The MDR is closely related to the MAR, since whichever memory address location the MAR is holding, the corresponding data will be loaded onto the MDR for processing by the ALU. After the processing has taken place, the ALU places the result onto the MDR and the data is copied to the memory address location in RAM specified by the MAR. The connection between the RAM and the MDR is accomplished by the Data Bus. ## Example 2.3: * **Question:** Describe the function of the data bus found in a PC. * **Answer:** It carries data to the MDR and then to the ALU from memory and from ALU to the MDR and then to memory. ## Example 2.4: * **Question:** Outline the function of the ALU (arithmetic logic unit). * **Answer:** The ALU performs arithmetical and logical operations. It performs various calculations and comparisons using various logic gates. ### 2.1.2 RAM and ROM * **Exit skills:** Students should be able to: * Explain the use of primary memory. * Define the terms RAM and ROM. * Explain the differences between RAM and ROM. The primary memory is the only storage that is directly accessible by the CPU. At any point in time, the primary memory may hold both data and instructions that are currently running on the computer system. These data and instructions are stored in the primary memory as binary machine code (i.e. a series of 0s and 1s). As depicted in Figure 2.2 the primary memory consists of two types of memory: * Random Access Memory (RAM) * Read Only Memory (ROM) * RAM is a general-purpose storage area meaning that the data stored can be over-written. This allows data and instructions to be loaded for execution and use whenever they are necessary. However, RAM is volatile, which means that whenever power is lost the contents of its memory are wiped (ex. if an unsaved document with changes is open when the power is lost, all the changes that had been made will be lost). * On the other hand, ROM is used to store instructions and data and cannot be over-written. This means that the instructions that are embedded in ROM cannot be changed, even if power is lost, and as such is considered non-volatile memory. ROM is used to store programs and instructions that do not need to be updated or change (ex. the start-up instructions of the operating system). ## Example 2.5: * **Question:** Identify some differences between ROM and RAM found in a PC. * **Answer:** * ROM cannot be written to, but RAM can be written to. * ROM holds the (BIOS) Basic Input / Output System, but RAM holds the programs running and the data used. * ROM is much smaller than RAM. * ROM is non-volatile (permanent), but RAM is volatile. ### 2.1.3 The cache memory * **Exit skills:** Students should be able to: * Define cache memory. * Explain the function of cache memory. * Describe various types of cache memory. RAM has two main types: * Dynamic RAM (DRAM) * Static RAM (SRAM) SRAM is faster but more expensive than DRAM, and as such DRAM is preferred for the main RAM of a computer system. However, a small amount of SRAM is placed between the main RAM and the processor and it is called cache (Figure 2.3). As such, cache is a smaller and faster RAM (SRAM) that temporarily stores instructions and data so that the processor does not need to access the slower main memory (DRAM). Cache holds the information from the RAM that is most actively used, and accessed most frequently. The computer system will run faster as the slower main memory will need to be accessed less frequently. When the processor needs to read from the main memory, it first checks if a copy of the data exists in the cache. If so, the processor reads from the cache, instead of reading from main memory. This action speeds up the process. If the data to be read do not exist in the cache, the data are first copied to the cache and then used. When the processor needs to write to the main memory it does so through cache memory. ### 2.1.4 The machine instruction cycle * **Exit skills:** Students should be able to: * Define Machine instruction cycle. * Describe machine instruction cycle. * Explain the use of data bus and address bus during the machine instruction cycle. Computer programs are stored in the primary memory as a series of instructions in machine code. These instructions, as well as any other necessary data, have to be moved from the primary memory and into the CPU in order for the computer program to operate. In order for that to happen, specific steps are followed. The following functions are carried out by the CPU in order to run a computer program: 1. **Fetch instruction from primary memory to control unit** The CPU is responsible for knowing which instruction it needs to take from the primary memory in order to operate correctly. To do that it sends the appropriate address through the memory (address) bus to the primary memory. The instruction that resides in the specific address is then copied into the data bus and sent to the control unit (CU). 2. **Decode instruction in control unit** The instruction that has been received by th CU is then decoded. Decoding an instruction allows the CPU to be aware of any additional data that are necessary for the execution of the instruction. Any required data that need to be loaded from the primary memory in order for the instruction to be executable are then fetched. The addresses of these data are placed into the memory (address) bus and the data from these addresses are received by the CPU through the data bus. 3. **Execute instruction** The CPU executes the instruction using the necessary data that have been loaded and calculates a result. Depending on the result, additional data may be needed. These data are fetched from the primary memory for further calculations. As before, the addresses of these data are placed into the memory (address) bus and the data from these addresses are received by the CPU through the data bus. 4. **Store result of execution and check for next instruction** After executing the instruction and computing the result the CPU then stores the result in the primary memory. To do so, it specifies the address where the result will reside in the primary memory, using the memory (address) bus and sends the data through the data bus. The CPU then checks for the next instruction and repeats the steps described above by fetching, decoding, executing and finally storing the result. The four steps presented above describe the machine Instruction cycle. ## Example 2.7: * **Question:** What is an instruction cycle? * **Answer:** It is the basic operation cycle of a computer, taking place in a definite time period, during which one instruction is fetched from memory and executed. It typically consists of four stages: fetch, decode, executer and store. ### 2.1.5 Persistent storage and secondary memory * **Exit skills:** Students should be able to: * Define persistent storage. * Explain the need for persistent storage. * Define virtual memory. * Explain the use of virtual memory. As described in section 2.1.2 the primary memory of a computer system consists of both random access memory (RAM) and read only memory (ROM). The primary memory is the only storage that is directly accessible by the CPU, meaning that any data that is stored elsewhere needs to first be copied onto the RAM, since the ROM cannot be written to but only read from, in order to be used by the CPU. RAM however is volatile, meaning that whenever power is lost the contents of the memory are wiped. Furthermore, RAM is a relatively fast memory but has only a restricted capacity to hold data. As instructions and data are saved onto the RAM, the RAM will inevitably become full at some point. At that point some instructions or data from the RAM will need to be moved in order to make space for new instructions or data. This is where secondary memory comes into play. Secondary memory (a.k.a. secondary or auxiliary storage) is a relatively slow memory that may be written to (just like the RAM) but is also non-volatile (just like the ROM); meaning that the contents of the memory are not wiped if power is lost but are persistent. That is why secondary memory is also known as persistent storage. Furthermore, secondary memory has a relatively high capacity to hold data compared to the primary memory. When the computer starts-up the RAM is empty. Instructions and data (such as the operating system) need to be copied into the RAM in order for the computer system to run. In most computer systems these are copied from the secondary memory. Secondary memory is thus what provides persistent storage to computer systems. This is very important since if secondary memory did not exist a computer system would be unable to store instructions and data persistently. Whenever it shut down all the contents of the only existing primary memory would be lost. Without the availability of secondary memory only ROM, would be able to store programs and instructions. That would mean that since ROM cannot be over-written, a computer would only be able to perform fixed operations and any user data would have to be re-inputted every time the user wished to use them. This would be acceptable for devices such as simple calculators, but imagine a mobile telephone user, who would have to re-enter the names and telephone numbers every time the mobile telephone was powered on. Such a system would be very hard or impossible to use as the user would have to remember all the telephone numbers or carry an address book everywhere! Since data is very important, if not critical, for computer systems to function correctly, the loss of data would be detrimental. As such, computer systems that need to hold persistent data and not have data loss cannot function properly just with primary memory. Figure 2.4 depicts the way that the CPU, primary and secondary memories are connected. The CPU can only access the volatile primary memory that is relatively fast but moderate in capacity. The primary memory is connected to the non-volatile secondary memory that is relatively slower but has a higher capacity to hold data. ## Example 2.8: **Question:** Imagine that we have a computer system that has a primary memory of 4GBs. When the system is off the volatile primary memory is empty. When the system is turned on various programs are loaded into the memory (including the operating system) in order for the computer system to run correctly. Say that these programs need 2GBs of primary memory. There are only 2GBs of primary memory left for any other programs we might use. **Question:** Imagine that we need to design a new logo for our school. We run a web browser so as to look for other logos and get some ideas. Assume the web browser needs around 500MBs (0.5GBs) of primary memory in order to run. There are only 1.5GBs of primary memory left for any other programs we might use. **Question:** After we look at a few other logos, we decide on an idea for our logo and we also run a graphic design program that will allow us to create the logo. However, we decide to keep the web browser running so as to look at the other logos as we go along. Assume the graphic design program needs around 1GB of primary memory in order to run. There are only 500MBs (0.5GBs) of primary memory left for any other programs we might use. **Question:** While designing our logo in our graphic design program, we decide that a 3D sphere would look great. In order to create the 3D sphere, we would need to run a 3D modeling program. Assume this program needs around 1GB of primary memory in order to run. However, we only have 500MBs (0.5GBs) of primary memory left. **Question:** If secondary memory did not exist, we would not be able to run the 3D modeling program without closing some of the other programs in order to release some primary memory. However, the secondary memory allows us to run all these programs concurrently and seamlessly. Since there is not enough space in the primary memory to load the 3D modeling program, some other program loaded by the user (either the web browser or the graphic design program) is copied into secondary memory, this making space for the 3D modeling program to be loaded into primary memory. Whenever the program that was moved into the secondary memory is needed, some-other program in the primary memory is copied to the secondary memory. The first program is again copied back into the primary memory and is ready to be used by the user. The process described above is called Virtual memory and can be defined as the use of secondary memory as if it was primary memory. As depicted in the example, secondary memory is required to hold information that may not be needed all of the time or may be too large to fit as a whole in primary memory (virtual memory). This makes secondary memory a necessity in most computer systems. There are a number of different secondary memory (storage) devices. The main ones are listed below: * Hard drive (a.k.a. hard disk) * CD-RW, DVD-RW * USB Flash drive * Secure Digital (SD) or Compact Flash (CF) card * Zip disk * Floppy disk * Magnetic tape As secondary memory is obviously crucial to computer systems it becomes apparent that advances in the technology surrounding secondary memory are beneficial to computer systems as a whole. New technologies appear and existing ones strive to become more efficient, robust, and faster, as well as to hold more data than before. As the modern world is characterized by an increasing amount of computer systems, masses of data are produced continuously which have to be stored somewhere. All these data have to be stored in non-volatile secondary (storage) memory. As such, the need for such memory is ever-increasing. ## Example 2.9: * **Question:** State some differences between primary and secondary memory. * **Answer:** * Most computers are equipped with a smaller amount of primary memory and a larger amount of secondary memory. * Primary memory is volatile, which means it does not retain data when the power is turned off. * Primary memory is more expensive compared to secondary memory. * Primary memory is much faster than secondary memory. * Primary memory is directly accessed by the CPU. * Secondary memory is not directly accessible by the CPU. * Secondary memory is non-volatile, which means it retains data when the power is turned off. ### 2.1.6 Functions of an operating system * **Exit skills:** Students should be able to: * Define operating system. * Explain the main functions of an OS. An operating system (OS) is a set of software that controls the computer's hardware resources and provides services for computer programs. It is a very important part of a computer system since it acts as an intermediary between software applications (i.e. programs) and the computer hardware.