Document Details

RemarkableSchrodinger

Uploaded by RemarkableSchrodinger

University of the Cordilleras

Tags

computer hardware computer generations technology history

Full Transcript

Chapter 1 Hardware Chapter 1 Hardware 1 Basic Configuration of Computers Various types of computers are extensively used around us. However, it has not even passed 100 years since the first computer was launc...

Chapter 1 Hardware Chapter 1 Hardware 1 Basic Configuration of Computers Various types of computers are extensively used around us. However, it has not even passed 100 years since the first computer was launched. Moreover, the basic configuration of computers has hardly changed since their initial launch. This chapter touches upon the history of computers from each generation and describes the five major units that form the basic configuration of a computer. 1 - 1 History of Computers Generations of computers are divided according to the logic gates they used. A computer consists of components known as logic gates, which correspond to the brain of the computer that is used in arithmetic operations. (1) 1st generation (1940s) The world’s first computer ENIAC was developed by J.W. Mauchly and J.P. Eckert in 1946. ENIAC used more than 18,000 vacuum tubes for its logic gates. Therefore, an enormous amount of heat was generated and the system consumed too much electricity for cooling, which even caused power outages. In those days, the computer was mainly used in ballistic calculations. However, it was necessary to replace circuit wiring according to the contents to be processed, and therefore, some people do not recognize it as a computer. It was EDSAC, developed by M.V. Wilkes in 1949, which eliminated the replacement of circuit wiring required in ENIAC. EDSAC was a computer that used a stored-program system. The stored-program system stores the contents to be processed as a program inside the computer and then runs it, and computers based on this system are also known as Neumann computers from the name of its inventor (J. Von Neumann). World’s first computer: ENIAC 13 (2) 2nd generation (1950s) While 1st generation computers were mainly used in military and research and development, UNIVAC I was launched as a commercial computer in 1951. In this generation of computers, semiconductors like transistors were used as logic gates. Semiconductors have intermediate electrical properties between conductors that pass electricity and insulators that do not pass electricity. Besides transistors, semiconductor devices include the diode (rectifying device), which only passes the electric current in one direction, and LED (Light Emitting Diode), which emits light when voltage is applied in the forward direction. Semiconductors are smaller than vacuum tubes, and their failure occurrence rate is low. Therefore, computers became compact, and their reliability increased. (3) 3rd generation (1960s) In this generation of computers, IC (Integrated Circuit) was used as a logic gate. IC implements the processing capacity of several-hundred transistors in a square silicon chip of a few millimeters, thanks to the advancement of semiconductor device technology. Computers became extremely compact and fast thanks to IC technology, and several manufacturers announced various types of computers. A typical example is IBM/360 developed by the IBM Corporation. This computer was a general-purpose computer that was capable of handling any kind of processing without any restrictions on the usage purposes. (4) 3.5th generation (1970s) In this generation, IC technology made further progress, and manufacturers began using LSI (Large Scale Integration) as logic gates. LSI has higher integration density than IC, which enabled computers to become even more compact and faster. Since computers became compact, this led to the development of control computers that are used in industrial devices and microprocessors that are used in home appliance products. Moreover, their high-speed technology led to the development of super computers that are very useful for high-speed operations in the area of scientific and engineering computations. Moreover, microcomputers were also launched as small computers for individual use. 14 Chapter 1 Hardware Super computer (5) 4th generation (1980s) Logic gate technology progressed further, and manufacturers began using VLSI (Very Large Scale Integration). Such exponential progress of hardware technology transformed the era of computers from “one computer in a company or facility” to “one computer per person.” Manufacturers started developing and selling PC (Personal Computers) for individuals, which formed the foundation of the present-day information society. Desktop computer Laptop computer In this era, the network environment was also developed, and it became common to use computers (servers) that provide services and terminals by connecting them through networks. In this usage, besides PCs, work stations that have higher performance than PCs were also used as terminals connected to networks. Moreover, the sizes of devices rapidly decreased with the development of the palm-sized PDA (Personal Digital Assistant) and smartphone; other personal digital assistants such as portable tablet terminals; and SoC (System on a Chip) and one chip microcomputers (single chip microcomputers) where functionality of computer is packed in one chip (LSI). (6) 5th generation (?) The progress of computer technology continues even today. For example, there is FPGA (Field Programmable Gate Array), which can be programmed after manufacture through 15 simulation of a design diagram. FPGA is slower than a dedicated LSI, and it is also expensive. However, as compared to implementing similar functions in software, FPGA devices are high-speed and low-cost devices, which is why they are used in home appliance products, etc. With the advancement of various technologies, computers increasingly became compact and high performance, and concentrated efforts were made so that even beginners could use them easily. Moreover, as the next generation computers, computers (e.g., computers with inference function) closer to people and more closely linked to society are being developed. Furthermore, as part of a recent trend, computers with a focus on energy conservation are also being developed. Power consumption of computers is expressed in units of Watts (W) just like general electrical appliances. Each of the components used in computers consumes power. Therefore, researchers are working on design technologies combining components that have low power consumption. 1 - 2 Five Major Units of Computers Computers are used in various fields, and there are various types of computers. However, the basic configuration elements are the same. This subsection describes the units that are used in computers. In order to explain the configuration elements of computers, a list is created for the functions that are required for computers. The easiest way to understand this is to think in terms of human action and behavior. If we think about human behavior in solving the problem “3+6= ”, it becomes as follows: 1) Look at the problem and memorize it. ↓ 2) Think about the meaning of “+”. …We know this is a sign that adds two values. ↓ 3) Memorize “9” as a result of adding “3” and “6”. ↓ Figure1-1 4) Write “9” in the answer sheet. Action and behavior of humans The five units of a computer perform this same action and behavior of humans. These units are called the five major units of a computer. 16 Chapter 1 Hardware 1) Input unit This is a unit that reads data to be processed by computer. 2) Output unit This is a unit that writes the processing results in a form that can be understood by humans. 3) Storage unit This is a unit that records data. There are main memory and auxiliary storage. 4) Arithmetic and logical unit This is a unit that performs arithmetic operations on data that is stored in the storage unit or makes a decision as per the instructions of the control unit. 5) Control unit This is a unit that interprets a command and gives instructions to the remaining four units. Below is an explanation of these units by using a specific example. When the arithmetic operation “3+6= ” is performed by a computer, a summary of the operation of each unit is as follows: 1) Enter “3+6” from the input unit, and store it in the storage unit. ↓ 2) Control unit decodes the meaning of “+”. As a result of decoding, it knows that “+” is a command for making addition. Therefore, it gives an instruction to the arithmetic and logical unit. ↓ 3) The arithmetic and logical unit fetches Figure 1-2 “3” and “6” from the storage unit, and Functioning of a computer performs the calculation. The result “9” is stored in the storage unit. ↓ 4) “9” is written from the storage unit to the output unit. Both input and output also operate on the basis of the instructions that are given by the control unit, which is not covered here. Therefore, the flow of data and control (instructions) between each unit is as shown in Figure 1-3 below. 17 Control unit Input unit Storage unit Output unit Arithmetic Control flow and logical Data flow unit Figure1-3 Flow of control and data in five major units In the storage unit, there is main memory and auxiliary storage. (In Figure 1-3, what is mentioned as the storage unit is main memory.) The differences between these two are described below. Main memory This unit can directly exchange data with the control unit and the arithmetic and logical unit, and it has a volatility characteristic (contents are lost if power supply is turned off). Auxiliary storage This unit stores data that cannot be accommodated in main memory, and it has a non-volatility characteristic (contents are not lost even if power supply is turned off). Moreover, the control unit and the arithmetic and logical unit are collectively referred to as the CPU (Central Processing Unit) or the processor. The input unit, the output unit, and 18 Chapter 1 Hardware the auxiliary storage outside the processor are also referred to as peripheral devices. Present-day computers use microprocessors (or MPU (Micro Processing Unit)), where CPU (processor) functions are consolidated into one LSI. Microprocessors are also used in home electrical appliances other than PCs. On the other hand, a semiconductor chip (LSI) where all required functions (system) including memory are integrated is referred to as SoC (System on a Chip). SoC has advantages such as high speed and low power consumption. However, it suffers from the disadvantage of high development risk. Therefore, it is also used in combination with SiP (System in a Package), which integrates multiple semiconductor chips into one package. Moreover, in a one chip microcomputer (single chip microcomputer) used in home electrical appliances, not only CPU and memory functions but also input and output functions are integrated into one semiconductor chip. In addition, there are co-processors that perform only specific processes for assisting the processor, and dedicated processors that are focused only on specific processes, unlike general purpose processors that perform various processes like in PCs. 19 2 Data Representation in Computers In order to make a computer work, it is necessary to store a program with a processing sequence and data to be processed inside the computer in advance. This section describes the methods of recording (representing) information inside computers. 2 - 1 Data Representation (1) Unit of representation Inside computers, data is recorded as electrical signals. Electric signals can basically represent only two states. Is electric current flowing? Is it not flowing? Is voltage high? Is it low? 0 and 1 are linked to these two states, and they are recorded and saved as data inside computers. In other words, data recorded by computers is represented with 0 or 1. The minimum unit that represents this 0 or 1 is called a bit. Various meanings are formed by combining 0 and 1 represented by this bit, and they are recorded as data. At this time, one unit formed by collecting 8 bits is called a byte. Figure 1-4 Bit and byte Moreover, there is a unit called word, which is formed by collecting more bits than in a byte. Word is the unit of processing inside computers, and there are 16 bits, 32 bits, 64 bits, etc. according to the model of computer used. Needless to say that if more bits can be processed at a time, then more information can be processed in a certain time. Therefore, the higher the number of bits in one word, the higher the processing speed of the computer. In most present-day computers, 1 word is 32 bits or 64 bits. 20 Chapter 1 Hardware (2) Information amount There are two types (0, 1) of information that can be represented with 1 bit, and the number of bit combinations is referred to as the information amount. The information amount that can be represented with 2 bits is of 4 types (00, 01, 10, 11), the information amount that can be represented with 3 bits is of 8 types (000, 001, 010, 011, 100, 101, 110, 111),... and so on. Figure1-5 Number of bits and information amount As shown in Figure 1-5, branches increase with the increase of every one bit used, and the information amount that can be represented keeps on doubling. In other words, the information amount that can be represented with n bits is of 2n types (2n shows the power of 2, and means multiplying 2 by itself n times). Using this concept, a summary of the information amount that can be represented with byte and word (16 bits) is given below. * Information amount of n bits = 2n types Information amount that can be represented with 1 byte (=8 bits) = 28 types = 256 types (00000000 through 11111111) Information amount that can be represented with 1 word (=16 bits) = 216 types = 65,536 types (0000000000000000 through 1111111111111111) 21 [Information amount in information theory] In the field of information theory, when event x occurs with occurrence probability (probability that a certain event occurs) P(x), the information amount that can be obtained is defined as I(x). According to this definition, the smaller P(x) is, the larger I(x) is; and the larger P(x) is, the smaller I(x) is. (This is easy to understand if the information amount is considered as the degree of surprise when an event occurs.) To explain the relation between bit and information amount, 1 bit represents the information of 0 or 1. In other words, the occurrence probability P(x) of event x, where either 0 or 1 appears, is 1/2, and so the information amount of occurrence probability 1/2 is 1 bit. Therefore, information amount n bit is an event with occurrence probability 1/2n; in other words, it means information of 2n types. (3) Prefix When data is handled, rather large numbers are handled as they are. However, it is very difficult to handle very large numbers or very small numbers without modification. Therefore, they are represented in combination with a prefix (auxiliary unit) representing a certain value. For example, even if a nurse holding a newborn baby says “He is a healthy baby boy of 3,000g,” no one would say “I lately got a little fat and became 75,000g.” Normally, one would say “75 kg.” This “k” is the prefix. “k” is a prefix that means the value “103”, and it can represent values like “75kg = 75×103g”. The readings and values of major prefixes are summarized in the table below. [Prefixes used for representing large numbers] Symbol Reading Decimal value Binary value k Kilo 103 210 M Mega 106 220 G Giga 109 230 T Tera 1012 240 P Peta 1015 250 22 Chapter 1 Hardware [Prefixes used for representing small numbers] Symbol Reading Decimal value m Milli 10−3 Μ Micro 10−6 n Nano 10−9 p Pico 10−12 Here, for prefixes that represent large numbers, binary values are also shown in the table. This is because inside computers, for representing information in binary form by using two numbers of 0 and 1, prefixes are also represented in binary form when numbers related to computers are represented (details of binary numbers are explained later). For examples, data like “1k calorie” is not related to computers. Therefore, it means 1k calorie = 1×103 calories = 1,000 calories. On other hand, data like “1k byte” is related to computers, and therefore it means 1k byte = 1×210 bytes = 1,024 bytes. However, it is almost equally related to “103≈210, 106≒220,...”, and therefore it is often treated as 1k byte = 1,000 bytes these days. Memorizing this relation helps when arithmetic calculation problems are solved. 2 - 2 Radix and Radix Conversion Decimal numbers that we normally use are numbers that are obtained by raising each digit to the power of 10 by using ten numbers from 0 through 9. (362.9)10 = 3×102 + 6×101 + 2×100 + 9×10−1 = (362.9)10 *10 in ( )10 shows that it is a decimal number. Here, the weight (10) of the decimal digit is called radix, and numbers represented with radix n are referred to as n-adic numbers. n-adic numbers are represented by using n numbers from 0 through (n−1) that are carried over when n is reached. (1) Binary numbers Binary numbers are represented by using two numbers 0 and 1 that are carried over when 2 is reached. The smallest unit of information handled inside computers is a bit, and only two numbers of 0 and 1 can be used. Therefore, computers use binary numbers that represent numerical values 23 with two numbers, 0 and 1. (101.1)2 = 1×22 + 0×21 + 1×20 + 1×2−1 = (5.5)10 * 2 in ( )2 shows that it is a binary number. Decimal numbers and their corresponding binary numbers are as shown below. Binary numbers can use only two numbers of 0 and 1 for one digit. Therefore, the number of digits quickly becomes large, compared with decimal numbers. Decimal numbers 0 1 2 3 4 5 6 7 8 9 10... Binary numbers 0 1 10 11 100 101 110 111 1000 1001 1010... Figure 1-6 Decimal numbers and corresponding binary numbers (2) Octal numbers Octal numbers are numerical values that are represented by using eight numbers from 0 through 7 and that are carried over when 8 is reached. (317.5)8 = 3×82 + 1×81 + 7×80 + 5×8−1 = (207.625)10 * 8 in ( )8 shows that it is an octal number Decimal numbers 0 1 2 3 4 5 6 7 8 9 10... Octal numbers 0 1 2 3 4 5 6 7 10 11 12... Figure 1-7 Decimal numbers and corresponding octal numbers (3) Hexadecimal numbers Hexadecimal numbers are numerical values that are represented by using sixteen numbers from 0 through 9, and A(10), B(11), C(12), D(13), E(14), and F(15) and that are carried over when 16 is reached. (1A6.E)16 = 1×162 + 10×161 + 6×160 + 14×16−1 = (422.875)10 * 16 in ( )16 shows that it is a hexadecimal number. 24 Chapter 1 Hardware Decimal numbers 0 1 2 3 4 5 6 7 8 9 10 Hexadecimal numbers 0 1 2 3 4 5 6 7 8 9 A 11 12 13 14 15 16 17 18 19 20... B C D E F 10 11 12 13 14... Figure 1-8 Decimal numbers and corresponding hexadecimal numbers (4) Relation between binary numbers, octal numbers, and hexadecimal numbers Binary numbers have an extremely large number of digits compared with decimal numbers. Although computers can handle binary numbers without problems, it is very difficult for a human being to understand when the internal status of computers is concerned. Therefore, octal numbers and hexadecimal numbers are used so that people can understand more easily. Octal numbers use the power of 8 (= 23) as the weight of each digit, and therefore the information of 3 digits of binary numbers corresponds to 1 digit of octal numbers. Binary number: (1011100.11101)2 ↓ (001 011 100. 111 010)2... Separate after every 3 digits with radix point as reference. ↓ (0 is supplemented in the parts that fall short of 3 digits.) Octal numbers: ( 1 3 4. 7 2 )8... Convert every 3 digits Hexadecimal numbers use the power of 16(= 24) as the weight of each digit, and therefore the information of 4 digits of binary numbers corresponds to 1 digit of hexadecimal numbers. Binary number: (1011100.11101)2 ↓ (0101 1100. 11100 1000)2... Separate after every 4 digits with radix point as reference. ↓ (0 is supplemented in the parts that fall short of 4 digits.) Hexadecimal number: ( 5 C. E 8 )16... Convert every 4 digits 25 (5) Radix conversion Radix conversion means changing the radix of a numerical value. It is also radix conversion to convert a binary number (radix 2) into an octal number (radix 8) or a hexadecimal number (radix 16). When radix has a constant (power) relation as in the case of binary numbers, octal numbers, and hexadecimal numbers, radix conversion can be done by consolidating multiple digits. However, when radix does not have a constant (power) relation as in the case of binary numbers and decimal numbers, it is necessary to convert through computation. 1) Radix conversion from a binary number into a decimal number Radix conversion from a binary number to a decimal number can be performed by adding the weight of each digit that is 1 in the binary number. (This is the same as adding the results that are obtained by multiplying the weight of each digit with the number (0 or 1) of each digit.) Example: Perform radix conversion of the binary number (1001101.101)2 into a decimal number. 2) Radix conversion from a decimal number into a binary number Radix conversion from a decimal number into a binary number is performed separately for the integer part and the fractional part. The integer part can be converted by repeatedly dividing by 2 until the quotient becomes 0, and then arranging the remainder of calculation results in sequence from the back. A fractional part can be converted by continuously multiplying by 2 until the fractional part in calculation results becomes 0, and then arranging the integer part of each calculation result in sequence from the front. 26 Chapter 1 Hardware Example: Perform radix conversion of the decimal number (77.625)10 into a binary number. A summary of radix conversion between decimal numbers and n-adic numbers is provided below. [Procedure of radix conversion from an n-adic number into a decimal number] Add all results obtained by multiplying the weight (power of n) of each digit by the number {from 0 through (n−1)} of each digit. [Procedure of radix conversion from a decimal number into an n-adic number] Integer part: Repeatedly divide by n until the quotient becomes 0, and then arrange the remainder of calculation results in sequence from the back. Radix part: Continuously multiply the radix part by n until the radix part in calculation results becomes 0, and then arrange the integer part of each calculation result in sequence from the front. For example, below is an example of radix conversion of the decimal number (67.6875)10 into an octal number. However, when the radix conversion from decimal to octal or hexadecimal is performed, it may be easier to convert from decimal to binary, and then convert the result into octal or hexadecimal. 27 Decimal number: (67.6875)10 = Binary number: (1000011.1011)2 = (001 000 011. 101 100)2 = Octal number: ( 1 0 3. 5 4 )8 [Fractional number that cannot be represented by the finite number of digits] When the fractional part of a decimal number is converted into an n-adic number, it gets into a loop as the fractional part of calculation results does not become 0, and it may not be converted into a finite fraction. For example, converting the decimal number (0.2)10 into a binary number gives the following. In this manner, when the results of radix conversion become an infinite fraction (or recurring fraction), numerical values are handled as approximate values inside the computer. 2 - 3 Representation Form of Data All data is represented with 0 or 1 inside computers. This representation form can be classified as follows: Figure 1-9 Representation Form of data 28 Chapter 1 Hardware 2-3-1 Character Data Inside computers, character data is represented with combinations of 0 and 1. In computers during the early stage of their development, 1 character was linked to a bit pattern of 8 bits (1 byte). Moreover, bit patterns linked to characters were referred to as character codes, with the six main character codes as described below. When data between computers is exchanged by using different character codes, character corruption (garbled characters) may occur where characters that are different from the original data are displayed. (1) ASCII code ASCII code is the character code defined by ANSI (American National Standards Institute) in 1962. It is composed of 8 bits, which include code bits (7 bits) that represent an alphabetic character or a number, and a parity bit (1 bit) that detects an error. Although it is used in PCs, it does not have any definitions concerning Japanese characters (e.g., kanji, kana). (2) ISO code ISO code is a 7-bit character code defined by the standardization agency ISO (International Organization for Standardization) on the basis of ASCII code in 1967. This character code forms the basis of character codes used in different countries all over the world. (3) JIS code JIS code is a character code that is deliberated by JISC (Japanese Industrial Standards Committee) on the basis of the Industrial Standardization Act for representing Japanese-specific characters based on the ISO code and is defined as JIS (Japanese Industrial Standards). 1) JIS 7-bit codes / JIS 8-bit codes (JIS X 0201) This character code can represent half-width katakana characters. Figure 1-10 shows the table of JIS 8-bit codes for reference. Here is how to use the table. Firstly, search in the table for the character to be represented with the code. Secondly, arrange columns (higher 4 bits) and rows (lower 4 bits) from top to bottom and left to right respectively. The arranged numbers form the character code of that character. 29 Example: Convert “JIS” into character code. Character Position in table Character code (Hexadecimal notation) J... 4th column 10th row : 0100 1010 (4A) I... 4th column 9th row : 0100 1001 (49) S... 5th column 3rd row : 0101 0011 (53) Figure 1-10 JIS 8-bit codes (JIS X 0201) 2) JIS kanji code (JIS X 0208) This is a character code for representing 1 hiragana or kanji character with 2 bytes (16 bits). 3) Shift JIS code This code system is formed by expanding JIS kanji code, and it is a character code that enables mixing of 1-byte characters and 2-byte characters without using a special switching code. (4) EBCDIC (Extended Binary Coded Decimal Interchange Code) EBCDIC is an 8-bit character code developed by the IBM Corporation of the United States. This code was originally developed by IBM for its own computers. However, 3rd generation (1960s) computers were mostly IBM computers, and therefore this code became industry standard (de facto standard) in the area of large computers. 30 Chapter 1 Hardware (5) Unicode Unicode is the character code that was developed and proposed by U.S.-based companies like Apple, IBM, and Microsoft as a 2-byte universal uniform code for smooth exchange of computer data. It supports characters of several countries such as alphabets, kanji and hiragana/katakana, Hangul characters, and Arabic letters. This was standardized by ISO as an international standard, and at present, UCS-2 (2 bytes) and UCS-4 (4 bytes) are defined. (6) EUC (Extended Unix Code) EUC (Extended Unix Code) is the character code that was defined by the AT&T Corporation for internationalization support of UNIX (an OS (Operating System), which is a software program for controlling computers). An alphanumeric character is represented with 1 byte, and a kanji or kana character is represented with 2 bytes. In this case, kanji characters are codes where the hexadecimal number “80” is added to JIS kanji code. Therefore, in the kanji part, the value of the most significant bit is “1”, and it is possible to differentiate single byte alphanumeric characters and kanji characters. Moreover, although it is not a character code, zoned decimal numbers are also classified as a code that represents character data (Details of zoned decimal numbers are explained in the next sub-subsection entitled “Numeric data”). 2-3-2 Numeric Data In broad terms, there are two methods for numeric representation inside computers. The first method is to represent numerical values with binary numbers, which is suitable for performing calculations inside computers. However, binary numbers are not easy for humans to use, and therefore there exits another method where decimal numbers are adopted to facilitate understanding for humans. (1) Decimal notation This is a numeric representation method of introducing the way of thinking about decimal numbers that are easy-to-understand for humans. In specific terms, BCD code (Binary-Coded Decimal code) where each digit of a decimal number is converted into a 4-bit binary number is used. 31 Example: Represent (2741)10 with binary-coded decimal code. Decimal numbers : 2 7 4 1 ↓ ↓ ↓ ↓ Binary-coded decimal code : 0010 0111 0100 0001 1) Zoned decimal number This is a format that represents 1 digit of a decimal number with 1 byte. A binary-coded decimal code is stored in the lower 4 bits of 1 byte corresponding to each digit, while zoned bits are stored in the higher 4 bits. However, a sign bit indicating a sign is stored in the higher 4 bits of the lowest digit. Zoned bits and sign bits differ depending on the character code used in computers. When EBCDIC is used, “1111 (F)” is stored in the zoned bit, while “1100 (C)” is stored as a sign bit if it is positive (+) and “1101 (D)” is stored as a sign bit if it is negative (−). On the other hand, when ASCII code or JIS code is used, “0011 (3)” is stored in the zoned bit. In most of the cases, the sign bit uses the same value as in the case of EBCDIC (it differs by manufacturer because there are no uniform definitions). Example: Represent (+672)10 and (−1905)10 with zoned decimal numbers (EBCDIC). 1111 0110 1111 0111 1100 0010 6 7 + 2 1111 0001 1111 1001 1111 0000 1101 0101 1 9 0 − 5 2) Packed decimal number This is a format that represents 2 digits of a decimal number with 1 byte. Each digit of a decimal number is represented with a binary-coded decimal code and this is the same as the zoned decimal number, however, it differs because the sign is shown with the lowest 4 bits, and when it falls short of a byte unit, 0 is inserted to make it a byte unit. 32 Chapter 1 Hardware Example: Represent (+672)10 and (−1905)10 with packed decimal numbers. 0110 0111 0010 1100 6 7 2 + 0000 0001 1001 0000 0101 1101 0 1 9 0 5 − If we compare zoned decimal numbers and packed decimal numbers, by packing after the omission of the zoned bits (higher 4 bits) of zoned decimal numbers, the packed decimal numbers can represent more information (digits) with fewer bytes. Moreover, it is called unpacking to represent packed decimal numbers by using zoned decimal numbers, and therefore the zoned decimal numbers are also referred to as unpacked decimal numbers. While zoned decimal numbers cannot be used in calculations, packed decimal numbers can be used in calculations. However, when decimal numbers from an input unit are entered, or when decimal numbers are sent to an output unit, it is preferable to use zoned decimal numbers because the unit (1-digit numerical value) of input/output and the unit (1 byte) of information correspond to each other. Therefore, conversion between zoned decimal numbers and packed decimal numbers is performed inside computers. Figure1-11 Conversion between zoned decimal numbers and packed decimal numbers inside computers (2) Binary notation Forms for representing numerical values as binary numbers that are easy to handle inside computers include fixed point numbers where the number of digits of integer part and fractional part are decided in advance, and floating point numbers where the position of radix point is changed according to the numerical value to be represented. 33 1) Fixed point numbers In this form of representation, numerical values are handled by fixing the radix point at a specific position. Generally, it is mostly used for handling integer numbers by fixing the position of the radix point in the least significant bit. ▲ (Position of radix point) In this form of representation, after numerical values are converted into binary numbers, they are used without modification according to the position of the radix point. Example: Represent (89)10 as an 8 bit fixed point number. (89)10=(1011001)2 ↓ 0 1 0 1 1 0 0 1 In fixed point numbers, methods of representing negative numbers (representation forms of negative numbers) are important. The two main methods are described below. A: Signed absolute value notation In this method, the most significant 1 bit is used as a sign bit, and 0 is stored in it if the numerical value is positive, while 1 is stored in it if the numerical value is negative. In the remaining bits, the binary bit string is stored as it is. Example: Represent (+89)10 and (−89)10 with an 8-bit fixed point number (signed absolute value). (89)10 = (1011001)2 (+89)10: 0 1 0 1 1 0 0 1 (−89)10: 1 1 0 1 1 0 0 1 B: Complement notation In this method, when a negative number is represented, the complement of the positive number is used. 34 Chapter 1 Hardware [Complement] By using a certain number as the reference value, the shortfall is shown with respect to this reference value. In n-adic number, there is a complement of n and a complement of n −1. Complement of n −1... Reference value is the maximum value that has the same number of digits. Complement of n... Reference value is the minimum value that has one more additional digit. The complement can be determined by subtracting from the reference value the number for which the complement is to be determined. Example 1: Determine the complement of decimal number (614)10 9’s complement 10’s complement 999 1000 − 614 − 614 385 386 Example 2: Determine the complement of binary number (01101101)2 1’s complement 2’s complement 11111111 100000000 − 01101101 − 01101101 10010010 10010011 Example: Represent (+89)10 and (−89)10 with an 8-bit fixed point number (2’s complement). (89)10 = (1011001)2 → 100000000 − 01011001 10100111 (+89)10: 0 1 0 1 1 0 0 1 (−89)10: 1 0 1 0 0 1 1 1 Generally, 2’s complement notation is often used in fixed point numbers for the following reasons. 35 1. Subtraction can be substituted for addition. When signed absolute values are used, addition or subtraction must be appropriately selected according to the first bit of each numerical value to be calculated. However, when 2’s complement is used, calculation can be performed without any selection. By using this, subtraction can be represented with addition. Example: Calculate “(15)10 − (10)10” as “(15)10 + (−10)10”. 1) Represent (−10)10 with 2’s complement. (10)10 = (1010)2 → 100000000 − 00001010 11110110 (−10)10: 1 1 1 1 0 1 1 0 2) Add (15)10 to (−10)10 represented as 2’s complement. (15)10 = (1111)2 (+15)10 0 0 0 0 1 1 1 1 00001111... (+15)10 + 11110110... (−10)10 1 00000101... (00000101)2 = (+5)10 ↑ * Discard the carry-over bit. By using this concept, a feature for subtraction is not required if computer has the feature for addition and the feature for calculating complement. Moreover, if multiplication is done with iterations of addition, and division is done with iterations of subtractions, four basic arithmetic operations (addition, subtraction, multiplication, division) can be done with addition only. 2. A wide range of numerical values can be represented. When signed absolute values are used, two types of 0s, namely (+0) and (−0), occur. However, there is only one type of 0 when 2’s complement is used. Since the information amount of identical numbers of bits is the same, 2’s complement enables the representation of a wider range of numerical values. 36 Chapter 1 Hardware Signed absolute value 2’s complement 01111111 +127 01111111 +127 01111110 +126 01111110 +126 : : : : 00000000 +0 00000000 0 10000000 −0 11111111 −1 : : 11111110 −126 10000001 −127 11111111 −127 10000000 −128 [Range of numerical values that can be represented with n bits (2’s complement)] From −2n−1 through +2n−1−1 2) Floating point numbers If the number of bits that can be used for representing numerical value is decided, the range of numerical values that can be represented with fixed point numbers is limited. Therefore, when a very large numerical value is handled, the number of bits should also be increased accordingly. However, in reality, the number of bits used for recording data cannot be increased infinitely. Therefore, floating point numbers are used to represent extremely large numbers or extremely small numbers below the radix point. Before the explanation of the representation of numbers inside computers, the mechanism of floating point numbers is explained by using decimal numbers. The case that there is the numerical value below is considered here. +456,000,000,000 For the ease of explanation, when 1 unit is used for recording a sign or one number, 13 units are required for recording this numerical value as it is. + 4 5 6 0 0 0 0 0 0 0 0 0 Here, if we convert the numerical value and then record only required information in the following manner, we can represent this numerical value with a total of 6 units. +456,000,000,000 = +0.456×1012 37 = (−1)0×0.456×1012 * (−1)0 = +1, (−1)1 = −1 Sign: Sign to show whether the numerical value is positive or negative 0 Fraction (mantissa): Numerical value to be placed after the radix 4 5 6 point Exponent: Power of 10 to be multiplied by fraction (mantissa) 1 2 This is the concept of floating point numbers. Using this concept, from extremely large numerical values to extremely small numerical values can be represented with the same number of digits. “10” in power of 10 used in representing exponent is called radix. Since a decimal number was used in this explanation, “10” was used as it is easy to understand in terms of moving the radix point. However, since binary numbers are used in computers, either “2” or “16” is used. [Basic form of floating point numbers] (−1)Sign × Fraction (mantissa) × RadixExponent In reality, the form of representation of floating point numbers used inside computers differs depending on the model. Here, we explain the single-precision floating point number (32-bit format) and double-precision floating point number (64-bit format) standardized as IEEE 754 format. A double-precision floating point number can handle a wider range of numerical values with higher precision. [Single-precision floating point number (32-bit format)] Sign Exponent Fraction (mantissa) (1 bit) (8 bits) (23 bits) [Double-precision floating point number (64-bit format)] Sign Exponent Fraction (mantissa) (1 bit) (11 bits) (52 bits) There are several forms of representation of information in each part of the floating point number format. Main forms of representation of each part are as follows: A: Sign (S) 38 Chapter 1 Hardware This is used for representing the sign of a numerical value. It is 0 for positive values, and 1 for negative values. B: Exponent (E) This is used for representing exponent with respect to radix. The two main representation methods below are used. 2’s complement: In this method, exponent is recorded as a binary number, and 2’s complement is used if it is negative (−). Excess method: This method records a value (i.e., biased value) that is obtained by adding a certain value to the exponent. The value (i.e., bias value) to be added is decided according to the number of bits of exponent. Below is an example of the excess method used with single-precision floating point numbers. Format of exponent Intended format Method name Number Information Bias value (Typical example) of bits amount Excess 127 IEEE 754 format 8 bits 256 types 127 Excess 64 IBM format 7 bits 128 types 64 C: Fraction (mantissa) (M) This is used for representing a numerical value after the radix point. In order to represent the part after the radix point, it is common to perform normalization. In this case, the integer part is either set to 0 or 1 (storing after the omission of 1 from the integer part). When the integer part is set to 0: 0.101101 → Store “101101” in fraction (mantissa) When the integer part is set to 1: 1.011010 → Store “011010” in fraction (mantissa) [Normalization] This operation is for maintaining the precision of numerical values by increasing digits that can be used in fraction (mantissa). In most cases, this is done by reducing extra 0s after the radix point. For example, in the case of the decimal number (0.000123456789)10 represented by using a 7-digit fraction (mantissa), if the 7-digit fraction is registered in fraction (mantissa) as is, the following result is obtained. 0 0 0 1 2 3 4 39 In contrast, if the 7-digit fraction is registered in fraction (mantissa) after normalization, the following result is obtained. Normalized form: 0.123456789×10−3 1 2 3 4 5 6 7 In other words, more digits can be represented if normalization is performed (the number of significant digits increases). Therefore, the precision of numerical values becomes high. Example: Express the decimal number (1234.625)10 with the single-precision floating point number (32 bits) of IEEE 754 format shown below. Sign (1 bit): Show a positive value with 0, and a negative value with 1. Exponent (8 bits): Show with excess 127 where radix is 2. Fraction (23 bits): Show with normalized expression where integer part is 1. 1) Convert the decimal number (1234.625)10 into a binary number. (1234.625)10 = (10011010010.101)2 2) Normalize the binary number determined in 1). Normalized form: +(1.0011010010101)2×210 3) Show exponent as a binary number (8 bits) of excess 127. Power of 10 → 10 + 127 = 137 → (10001001)2 4) Describe according to the form of representation. 0 10001001 00110100101010000000000 Sign (1 bit): 0 Exponent (8 bits): 10001001 Fraction (mantissa) (23 bits): 00110100101010000000000 40 Chapter 1 Hardware 2-3-3 Error Error refers to the difference between the actual value and the value represented inside the computer. When numerical values inside the computer are handled, we must pay attention to error. For example, when (0.1)10 is converted into a binary number, it is represented as follows: (0.1)10 = (0.00011001100110011...)2 The conversion result becomes a recurring fraction where “0011” is repeated an infinite number of times. However, since there is a limit for the number of bits that can be used for representing numerical values inside computers, the only option for storing in fraction (mantissa) is to store after the loop is cut in the middle. If it is 8 bits, only up to (0.00011001)2 can be stored. When this binary number is converted into a decimal number, (0.09765625)10 is obtained. In other words, this is different from the original numerical value (0.1)10 by only (0.00234375)10. This is error. (1) Rounding error Rounding error occurs when the part smaller than the least digit is rounded off, rounded up, or rounded down in order to represent the real number with the effective number of digits in the computer. When a decimal number is converted into a binary number, this kind of error occurs to represent the resulting binary number with the effective number of digits. As a measure against rounding error, there are methods such as minimizing the value of error as much as possible by changing single precision (32 bits) into double precision (64 bits). (2) Loss of trailing digits Loss of trailing digits is the error that occurs when an extremely small value is ignored at the time of computing two values: one absolute value is extremely large and the other is extremely small. Example: Calculate (0.10110011)2 × 210 + (0.11010001)2 × 2−10. 41 In order to minimize loss of trailing digits, when multiple numerical values are added with floating point radix numbers, it is necessary to take steps such as arranging all data in the ascending order of absolute value, and adding them in sequence from the top (smaller value). (3) Cancellation of significant digit Cancellation of significant digit is the error that occurs because of decline in the number of significant digits that can be trusted as numerical values when calculation is performed between almost equal numerical values. Example: Calculate (0.10110011)2 × 20 − (0.10110010)2 × 20. (4) Overflow, underflow Inside a computer, the range of numerical values that can be represented is already decided, because the limited number of bits is used for representing them. Flow is the error that occurs when the calculation results exceed this range of representation. When the calculation results exceed the maximum value of range of representation, it is referred to as overflow, and when it exceeds the minimum value, it is referred to as underflow. When it is simply referred to as “flow,” it mostly means overflow. Minimum value Maximum value Range of representation of numerical values ← ← [Underflow] ← ← → → [Overflow] → → Moreover, the following two indexes are used as the concept of evaluating these errors (whether precision is high or low). Absolute error: This is an index that evaluates on the basis of how large the actual error is. Absolute error = | True value − Computed value (including error) | 42 Chapter 1 Hardware Relative error: This is an index that evaluates on the basis of the proportion (ratio) of error with respect to true value. | True value − Computed value (including error) | Relative error = | True value | 2-3-4 Shift Operation Shift operation is the operation of shifting the position of bit to left or right. Shift operation is used in computation of numerical values, and in changing the position of bits. (1) Arithmetic shift Arithmetic shift is the shift operation used when numerical values are computed. It is mainly used in fixed point numbers that represent negative values in 2’s complement. [Rules of arithmetic shift] Do not shift the sign bit. Truncate extra bits that are shifted out as a result of the shift. Store the following bit in the empty bit position that is created as a result of the shift. In the case of left shift: 0 In the case of right shift: Same as the sign bit Example: Shift (22)10=(00010110)2 arithmetically left by 2 bits. Binary numbers have weight of power of 2 in each digit. Therefore, even for the same numeral 1, 1 as the second digit and 1 as the third digit have different meanings. 1 as second digit: (10)2 → 21 = 2 1 as third digit: (100)2 → 22 = 4 43 Because of this, computation rules of arithmetic shift can be summarized as follows: [Computation rules of arithmetic shift] With an arithmetic shift to left by n bits, the value becomes 2n times of the original number. With an arithmetic shift to right by n bits, the value becomes 2−n times of the original number. (It is the value that is obtained by dividing the original number by 2n) (2) Logical shift Logical shift is the shift operation used when the position of bits are changed. Its main difference from the arithmetic shift is that it does not treat the sign bit in a special manner. [Rules of logical shift] Shift (move) the sign bit as well. Truncate extra bits that are shifted out as a result of the shift. Store 0 in the empty bit position that is created as a result of shift. Example: Compare the results of 2-bit arithmetic shift right and 2-bit logical shift right for (−16)10 = (11110000)2. 1) Perform 2-bit arithmetic shift right. 2) Perform 2-bit logical shift right. 44 Chapter 1 Hardware Rotation shift (circular shift) is a type of logical shift. In rotation shift, the bits shifted out are circulated to the empty positions. Example: Perform 2-bit rotation shift right on (11010010)2. 45 3 Central Processing Unit and Main Memory Unit Data processing in computers takes place in the steps of “Input → Processing → Output.” Section 1 explained the CPU (Central Processing Unit) that handles “Processing” in this series of steps is composed of a control unit and an arithmetic and logical unit. This section describes more detailed operating principles of the CPU and the main memory unit that is closely related to the CPU. 3 - 1 Configuration of CPU In computers based on stored-program, programs (instructions) recorded in the main memory unit are read in the CPU one by one, and the control unit issues directions to each device on the basis of the contents of the instruction for processing. In order to carry out this operation, the CPU is composed of various devices and components. Figure 1-12 Components of CPU (1) Control unit Control unit is a unit that decodes the instruction to be executed and gives directions to each device. It is composed of a decoder (instruction decoder that interprets the instruction to be executed), etc. (2) Arithmetic and logical unit Arithmetic and logical unit is a unit that performs computations inside computers. It is composed of an ALU (Arithmetic and Logical Unit) that uses an adder for addition, a complementer for calculating complements, and such other components. 46 Chapter 1 Hardware (3) Register Register is a device used for temporarily storing various data inside the CPU. Different types of registers are available according to the type of data to be stored. The main registers (details of each register are explained later) are as follows: Instruction register It stores the instructions to be executed. It is composed of an instruction part and an address part. Instruction address register (program counter, program register) It stores the address (storing position in the main memory) of the instruction to be executed next. General register It is used for various purposes such as storing the data to be processed. Accumulator It stores the data for performing computations. It is sometimes also substituted with a general register. Base address register It stores the beginning address of a program. Index register It stores the index for address modification. Flag register It stores the information of a certain status (whether the results of computations are positive or negative, etc.). Depending on the status of this register, the next action, such as branch destination of the condition branch instruction, is decided. PSW (Program Status Word) It stores the running status of a program (value of program counter, value of flag register, etc.) (4) Clock generator Clock generator is a device for generating signals (clock signals) in order to synchronize and control the timing of operations between various devices inside computers. The speed of generating clock signals is shown with clock frequency, and MHz (Mega Hertz) (1 Million times in 1 second) is used as the unit. Usually, either the rising or falling edge of a signal is used as synchronization timing, and there is a technique called DDR (Double Data Rate) that uses both. 47 Figure 1-13 1 cycle of clock frequency (5) Bus Bus is the signal path for connecting various devices and registers, and transmitting data and control signals. Concerning the bus, there is a serial bus that sends data in the sequence of 1 bit each, and there is a parallel bus that simultaneously sends multiple bits. Performance of bus is decided by the access mode, such as the number of bits that can be sent in one clock signal (bus width) and clock signal, which is defined for each bus. [Classification according to connection point] 1) Internal bus (CPU internal bus) This is a bus used inside the CPU. 2) External bus (CPU external bus) This is a bus that connects the CPU and the external devices. The clock frequency of the external bus is generally different from that of the CPU. System bus: Collective term for the buses directly connected from CPU to outside Memory bus: Bus that is mainly connected to the main memory unit Input/output bus: Bus that is mainly connected to the input/output devices 3) Expansion bus This is a bus that connects the PC and the expansion cards. [Classification according to usage] 1) Address bus: Bus for specifying the reference address to the main memory unit 2) Control bus: Bus for giving directions to each device from the control unit 3) Data bus: Bus for exchanging data In conventional buses (Neumann architecture), the same bus was used for loading instructions and data. However, in modern-day computers, for loading instructions and data, Harvard architecture is used where independent buses are provided for loading instructions and data. The main buses presently used in PCs are shown below. Other than in PCs, various buses are used (there are also manufacturers’ specific buses). 48 Chapter 1 Hardware PCI (Peripheral Component Interconnect) This is an external bus specification defined by Intel Corporation, USA. PCI specification of bus width 32 bits, bus clock 33 MHz, and transfer rate of 133 megabytes/second is common. PCI Express (PCIe) This is an external bus specification defined by PCI-SIG to replace PCI. The transfer rate is 500 megabytes/second in full-duplex mode. The specification of "PCI Express x 16" where 16 transmitting lanes are contained is used as a replacement of the specification of AGP (Accelerated Graphics Port) that is used to connect graphics boards. 3 - 2 Main Memory Configuration 3-2-1 Memory Devices Memory devices are devices that configure main memory and registers. In particular, IC-based memory devices are referred to as semiconductor memory or IC memory. [Classification of memory devices] 1) MOS (Metal Oxide Semiconductor) type Although it has a high degree of integration and low power consumption, it is a semiconductor device with somewhat low operating speed. These days, CMOS (Complementary MOS) are most commonly used after improvements were made so that operating speed could be increased by transporting electrical charges by the use of free electrons and holes. 2) Bipolar type Although operating speed is high, this semiconductor device has a low degree of integration and power consumption is also large. A typical example of bipolar memory devices is a logic IC TTL (Transistor-Transistor Logic) composed of only bipolar transistors. (1) RAM (Random Access Memory) RAM is IC memory where reading and writing of data can be done freely. It is not suitable for storing data for a long time because it has a property (volatility) where data is cleared when the power is off. 49 SRAM (Static RAM) While its operating speed is high, it is expensive and it also has high power consumption. As for its memory mechanism, it uses a flip-flop circuit that continues to retain the preceding status, and electrical charge that records information can be retained as long as power is supplied. However, its disadvantages are a low degree of integration because of complex configuration of the circuit, and storage capacity that is smaller compared with DRAM. It is mainly used in registers or other memory devices. DRAM (Dynamic RAM) While its operating speed is somewhat slow, it uses a simple circuit where electrical charge is retained by condenser or capacitor. Therefore, the degree of integration is high, and large capacity memory can be easily created at low cost. However, electrical charge that records information is lost over time, and therefore it is necessary to rewrite (refresh) the information. Examples include SDRAM (Synchronous DRAM) or DDR SDRAM (Double Data Rate SDRAM) used in main memory, and RDRAM (Rambus DRAM) that uses Rambus technology in the external bus interface. (2) ROM (Read Only Memory) ROM is IC memory that can be used only for reading data. It has a property (non-volatility) where data is not lost even when the power is off. Mask ROM This is a type of ROM where users cannot write data. This memory is used to store programs or data in factories, and the information is used only for the purpose of reference. User programmable ROM This is a type of ROM where users can write data. On the bases of the writing methods and restrictions on the number of rewritable times, this is classified as follows: PROM (Programmable ROM): This is a type of ROM where user can write information only once. UV-EPROM (UltraViolet-Erasable PROM): This is a type of ROM where data can be rewritten after information is erased by irradiating ultraviolet rays. EEPROM (Electrically EPROM): This is a type of ROM where data can be rewritten after all or a part of information is electrically erased. It has limited life because of deterioration, and the number of rewritable times is restricted to a few tens of thousands of times to a few million times. 50 Chapter 1 Hardware Flash memory: This is semiconductor memory where data can be rewritten after data is erased in units of blocks through electrical operations. Flash memory is a type of EEPROM. Therefore, the number of rewritable timesis limited. However, it is used for various applications as a portable and convenient storage medium. 3-2-2 Components of Main Memory In broad terms, the main memory unit is composed of three components. Memory unit This contains memory cells (storage devices) that record data. Read/write feature This reads and writes data in the recording area (collection of memory cells). Address selection feature This interprets the specified address and selects the recording area of data. Figure 1-14 Components of main memory Access operation to main memory is done as follows: 51 [Access operation to main memory] 1) Through address bus, the specified address is handed over to the address selection feature. 2) The address selection feature decodes the specified address by using the address decoder, and selects the recording area to be accessed. (address selection operation) 3) The read/write feature reads and writes data in the selected recording area. When data is read, data that is read from the recording area is passed on to the CPU via data bus. When data is written, data that is transferred from the CPU via data bus is written in the recording area. 3-2-3 Capacity Expansion of Main Memory In the commercially available PCs, the capacity of main memory is fixed beforehand. Below are two methods of further expanding this capacity. Extended memory (additional memory) This is a type of memory added in the expansion slots provided for in desktop PCs so that devices and electronic boards (components) can be added. Examples include SIMM (Single In-line Memory Module) where DRAM memory chips are consolidated and mounted on a small board, and DIMM (Dual In-line Memory Module). Memory card This IC memory is used in capacity expansion of a notebook PC, and a typical example of this is a flash memory-based memory card. It is standardized by JEIDA (Japan Electronic Industry Development Association) and PCMCIA (Personal Computer Memory Card International Association). 3 - 3 Instruction and Addressing 3-3-1 Types and Configuration of Instructions The CPU reads the instructions that are stored in main memory one by one, and interprets and executes the instructions. Instructions the CPU can interpret are machine language instructions, which are represented with combinations of 0 and 1, and a programming language (i.e., language used to write the programs) that is used to write such instructions is called the machine language. 52 Chapter 1 Hardware Below are the main types of machine language instructions. Arithmetic operation instruction This is an instruction for performing arithmetic operations such as addition and subtraction. Logical operation instruction This is an instruction that performs logical operations such as logical product and logical sum operations. Transfer instruction This is an instruction that transfers data such as load and store. Comparison instruction This is an instruction that compares the magnitude relation between two values. Branch instruction This is an instruction that branches (jumps) the control on the basis of the value of a flag register. Shift instruction This is an instruction that performs shift operations such as arithmetic shift and logical shift. Input/output instruction This is an instruction that reads data from or write data to I/O devices. Moreover, the configuration of machine language instructions includes instructions recorded in 1 word (recording area corresponding to 1 address) of main memory (1-word instructions) and instructions recorded consecutively in multiple words (when recorded in 2 words, it is referred to as 2-word instructions). However, even if the length of instructions is different, there is a similarity in the sense that both of them are composed of an instruction part where the instruction code specifying the process to be executed is recorded, and an address part (or operand part) for specifying the address to be processed. Address part Instruction part (Operand part) Figure 1-15 Configuration of machine language instructions Based on the number of address parts (operand parts), they are also separately referred to as 0-address instruction, 1-address instruction, 2-address instruction, and 3-address instruction. 53 3-3-2 Execution Sequence of Instructions Figure 1-16 shows the general execution sequence of instructions. Here, the process until fetching the instruction is called the instruction fetching stage (fetch cycle), and the process until decoding and executing the instruction is called the instruction execution stage (execution cycle). Figure 1-16 Execution sequence of instructions Details of the processing sequence from “instruction fetching” until “computing” are explained in order by using the following figure. 54 Chapter 1 Hardware Figure 1-17 CPU and main memory (1) Instruction fetching In instruction fetching, on the basis of the directions given by the control unit, an instruction stored in the address shown by the instruction address register is fetched from main memory, and it is stored in the instruction register. After the instruction is fetched, instruction word length L (number of words where 1 instruction fetched is stored) is added to the instruction address register for fetching the next instruction. Figure 1-18 Instruction fetching (2) Instruction decoding In instruction decoding, the instruction part of the instruction fetched in the instruction register is decoded by the decoder (instruction decoder) of the control unit. 55 Figure 1-19 Instruction decoding (3) Effective address calculation/operand fetching In effective address calculation, the storage position (effective address) of data stored in main memory is determined from the address part of the instruction. (This is referred to as address modification) In operand fetching, the effective address calculated is sent to main memory, and the value or variable (operand) to be computed such as arithmetic operation instructions is read into the general register. There may not be any operand in some cases, depending on the type of instruction, and this process may be omitted in such cases. Figure 1-20 Effective address calculation and operand fetching (4) Computation (instruction execution) In computation (instruction execution), the arithmetic and logical unit executes the 56 Chapter 1 Hardware computation based on the decoded instruction. The operation result is recorded in the general register and written in main memory. Figure 1-21 Arithmetic operation (instruction execution) 3-3-3 Addressing Mode Addressing mode is the method of determining the effective address from the value recorded in the address part of instruction, and then fetching the operand. The addressing mode is classified into two methods: one is the method (address modification) of determining the effective address from the value of the address part of instruction and the other is the method of determining the operand from the effective address. (1) Method of determining effective address from the value of the address part (address modification) 1) Absolute addressing In this method, the value of the address part is used as the effective address as it is. 2) Index addressing In this method, the effective address is determined by adding the value of the index register to the value of the address part. A general register is also used as the index register, and it is necessary to specify which general register to use in such cases. 57 3) Base addressing In this method, the effective address is determined by adding the value of the base address register to the value of the address part. This means the relative position from the beginning of the program. 4) Relative addressing In this method, the effective address is determined by adding the value of the instruction address register (program counter) to the value of the address part. This means the relative position from the instruction being executed. (2) Method of determining operand from the effective address 1) Immediate addressing In this method, the effective address is used as it is as operand. Since it does not reference main memory, execution speed is somewhat faster than other addressing. Figure 1-22 Immediate addressing 58 Chapter 1 Hardware 2) Direct addressing In this method, the content (value) of main memory referenced by the effective address is used as operand. Generally, direct addressing where there is no description concerning address modification can be considered as absolute addressing, and it can be considered as direct addressing when only address modification is specified. Figure 1-23 Direct addressing 3) Indirect addressing In this method, the content (value) of main memory referenced by the effective address is used as the address of operand. Double (in the example shown in Figure 1-24, data stored in address 120 is fetched as operand), and triple indirect addressing is also possible. Figure 1-24 Indirect addressing 3-3-4 Interrupt Interrupt means executing a separate process (instruction) while a series of processes (instructions) are being executed. Instead of user mode (mode where there are restrictions on the use of CPU), which is normally used, the interrupt process is executed in privilege mode (mode where there are no restrictions on the use of CPU). 59 [Processing sequence of processor when interrupt has occurred] 1) Switch from user mode to privilege mode. 2) Save the values of various registers (program counter, etc.). 3) Decide the starting address of the interrupt process routine (interrupt program). 4) Execute the interrupt process routine. 5) After the execution of the interrupt process routine is complete, restore the values of various registers that are saved in step 2. 6) Switch from privilege mode to user mode, and restart the interrupted process. According to conditions that an interrupt occurs, this can be classified described below. Here, it is assumed that multiple interrupts may occur simultaneously, and therefore priority ranking is assigned to each interrupt. 1) External interrupt: This is an interrupt that occurs because of a reason not related to the process being executed. Timer interrupt This is an interrupt that occurs when the time measured in the timer, such as interval timer and watchdog timer, has exceeded the specified time (i.e., the timer has been timed-out). Input/output interrupt (input/output completion interrupt) This is an interrupt that occurs when an input/output operation has been completed. Machine check interrupt This is an interrupt that occurs because of a hardware malfunction, a power failure, or such other factor. Restart interrupt This is an interrupt that occurs when the user has pressed the external restart switch. 2) Internal interrupt: This is an interrupt that occurs because of the process being executed. This is also referred to as a trap. SVC (SuperVisor Call) interrupt This is an interrupt that occurs when supervisor (program that offers basic functions) is requested to invoke a process, such as when input/output instruction is used or storage protection exception happens. Program interrupt 60 Chapter 1 Hardware This is an interrupt that occurs by the error of a running program (e.g., divide-by-zero or overflow) 3 - 4 Circuit Configuration of ALU ALU (Arithmetic and Logical Unit) is a unit that performs arithmetic operations and logical operations. This unit is composed of various circuits. 3-4-1 Logic Circuit Logic circuit is a circuit that performs logical operations for logical processing of instructions by computers. Logical operations refer to arithmetic operations that have only two truth values of True (1) and False (0). [Main logical operations] 1) Logical product operation (AND) The output becomes True (1) when both input values are True (1), or else the output is False (0) (when either one is False (0)). 2) Logical sum operation (OR) The output becomes False (0) when both input values are False (0), or else the output is True (1) (when either one is True (1)). 3) Negation operation (NOT) The output becomes False (0) when the input value is True (1), and the output is True (1) when the input value is False (0). 4) Exclusive logical sum (Exclusive OR) operation (XOR or EOR) The output becomes False (0) when both input values are the same, and the output is True (1) when both input values are different. The table below summarizes the relations between input and output of the respective logical operation. This kind of table is referred to as a truth table. Input AND OR NOT XOR X Y (X AND Y) (X OR Y) (NOT X) (X XOR Y) True (1) True (1) True (1) True (1) False (0) False (0) True (1) False (0) False (0) True (1) False (0) True (1) False (0) True (1) False (0) True (1) True (1) True (1) False (0) False (0) False (0) False (0) True (1) False (0) 61 Besides “X AND Y”, AND is also expressed as “X Y” and “ X  Y ”; besides “X OR Y”, OR is also expressed as “X + Y” and “ X  Y ”; besides “NOT X”, NOT is also expressed as “ X ” and “¬X”; and besides “X XOR Y”, XOR is also expressed as “ X  Y ” and “ XY ”. (1) Sequential circuit Sequential circuit is a logic circuit where the output is decided on the basis of the input at that time and earlier status. Flip-flop circuit, which is one of the main sequential circuits, has two stable states, and it is used in storage cells of SRAM. Figure 1-25 shows the circuit diagram of a flip-flop for reference and the truth table. Circuit symbols used in Figure 1-25 are one of the methods of representing electronic circuits, and it is referred to as MIL (Military Specifications and Standards) symbols. S R X Y Comments 1 1 X Y No change 1 0 0 1 Reset 0 1 1 0 Set 0 0 - - (Non-allowed) Figure 1-25 Circuit diagram of flip-flop and truth table (2) Combination circuit Combination circuit is a logic circuit where the output is decided on the basis of the input at that time. There are various types of combination circuits, from basic circuits for implementing basic logical operations (logical product, logical sum, negation) to circuits formed by combining these basic circuits. 1) AND circuit This circuit performs logical product operation (AND). The truth table and MIL symbol of AND circuit are as shown below. X Y X AND Y 0 0 0 0 1 0 1 0 0 Figure 1-26 AND circuit 1 1 1 2) OR circuit This circuit performs logical sum operation (OR). The truth table and MIL symbol of OR 62 Chapter 1 Hardware circuit are as shown below. X Y X OR Y 0 0 0 0 1 1 1 0 1 Figure 1-27 OR circuit 1 1 1 3) NOT circuit This circuit performs negation operation (NOT). The truth table and MIL symbol of NOT circuit are as shown below. X NOT X 0 1 Figure 1-28 NOT circuit 1 0 4) NAND circuit This circuit performs negative logical product (negative AND) operation (NAND). NAND operation is the arithmetic operation that negates the results of AND operation. The truth table and MIL symbol of NAND circuit are as shown below. NAND circuit is formed by combining AND circuit and NOT circuit. X Y X NAND Y 0 0 1 0 1 1 1 0 1 Figure 1-29 NAND circuit 1 1 0 5) NOR circuit This circuit performs negative logical sum operation (NOR). NOR operation is the arithmetic operation that negates the results of OR operation. The truth table and MIL symbol of NOR circuit are as shown below. NOR circuit is formed by combining OR circuit and NOT circuit. X Y X NOR Y 0 0 1 0 1 0 1 0 0 Figure 1-30 NOR circuit 1 1 0 63 6) XOR circuit This circuit performs exclusive logical sum operation (XOR). The truth table and MIL symbol of XOR circuit are as shown below. X Y X XOR Y 0 0 0 0 1 1 1 0 1 Figure 1-31 XOR circuit 1 1 0 XOR circuit is also formed by combining the basic circuits. However, it cannot be formed with a combination of simple circuits as in the case of NAND circuits and NOR circuits. In such cases, it is called logical design (or circuit design) to think about the combination of basic circuits for achieving the targeted results (truth values). In logical design, logical expressions (logical functions) obtained from the truth tables are simplified using the rules of logical operations (logical laws), and the optimum combination of basic circuits is determined. (“Optimum” means that the design is performed in consideration of performance, efficiency, and cost. 64 Chapter 1 Hardware [Main logical laws] * AND operation is represented with ˄, OR operation is represented with ˅, and NOT operation is represented with ¬. Idempotent laws AA A AA A Commutative laws AB  BA AB  BA Associative laws A  (B  C)  (A  B)  C A  (B  C)  (A  B)  C Distributive laws A  (B  C)  (A  B)  (A  C) A  (B  C)  (A  B)  (A  C) Absorption laws A  (A  B)  A A  (A  B)  A De Morgan’s laws (A  B)  (A)  (B) (A  B)  (A)  (B) Others A0A A00 A 11 A 1 A A  (A)  1 A  (A)  0 (A)  A (Returns to original by double negation) [Logical design of XOR circuit] 1) Focus on the parts where the output of the truth table is 1 and determine AND operation where the result is 1 on the basis of the input at that time. When (X=0, Y=1):  X  Y When (X=1, Y=0): X   Y 2) Create a circuit where the output will be 1 when either of the AND operations you determined is 1. In order to design such a circuit, determine logical expression F 65 where two AND operations are combined with OR operation. Logical expression F  (X  Y)  (X  Y) 3) Determine the circuit diagram by combining the basic circuits such that it represents logical expression F. [Circuit diagram] By expanding the logical expression F determined in [Logical design of XOR circuit] using logical laws, we can determine different logical circuits. Logical expression F  (X  Y)  (X  Y)  ((X  Y)  X)  ((X  Y)  Y)...Distributive law  ((X  X)  (Y  X))  ((X  Y)  (Y  Y))...Distributive law  (1  (Y  X))  ((X  Y)  1)... A  (A)  1  (X  Y)  (X  Y)... A  1  A , Commutative law [Circuit diagram] In the actual logical design, it is common to use NAND circuit, NOR circuit, or XOR circuit as one circuit (basic circuit) as it is. 3-4-2 Arithmetic Operation Circuit In a computer, subtraction can be performed with addition using complement notation. Similarly, the four basic arithmetic operations can be implemented with addition only. This is because multiplication can be performed with repeated addition, and division can be performed with repeated subtraction (i.e. repeated addition). Therefore, in order to implement the four basic arithmetic operations in a computer, only an adder circuit and a complement 66 Chapter 1 Hardware circuit are required. First, the adder circuit is considered here. The basis of addition in a computer is 2-bit addition that adds one bit to one bit. Here, then, a circuit to perform 2-bit addition is considered. As 2-bit addition, the following four types are possible. The results of the addition of two 1-bit binary numbers are shown below. [Results of the addition of two 1-bit binary numbers] Values to be added Operation result X Y Carry (c) Sum (s) 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 0 From this table, it is clear that carry is 1 only when two entered values are both 1, this is a logical product operation (AND). It is also clear that sum is 0 when two entered values are the same and 1 when they are different, and therefore, this is an exclusive logical sum operation (XOR). Therefore, a circuit diagram with the configuration below is derived. This circuit is called a half adder. Figure 1-32 Circuit diagram of half adder Adder circuit of a computer is configured with this half adder as the basis. However, in half adder, carry from low order is not taken into account. Therefore, arithmetic operation of numerical values represented with multiple bits cannot be performed. Because of that, another adder circuit of 3 bits including carry from low order becomes necessary. The table below summarizes the results of arithmetic operation of 3-bit addition considering carry (c0) from low order. 67 [Results of arithmetic operation of 3-bit addition] Values to be added Operation result X Y c0 Carry (c1) Sum (s) 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 In order to derive circuit configuration from this table, we will get the following if we think about logical expression F1 for determining carry (c1) and logical expression F2 for determining sum (s). [Logical expression F1 for determining carry] 1) With the input for which the output of truth table will become 1, determine AND operations where the result will be 1. When (X=0, Y=1, c0=1):  X  Y  c 0 When (X=1, Y=0, c0=1): X   Y  c 0 When (X=1, Y=1, c0=0): X  Y   c0 When (X=1, Y=1, c0=1): X  Y  c0 2) Determine logical expression F1 by combining AND operations we determined with OR operations. Logical expression F1  (X  Y  c0)  (X  Y  c0)  (X  Y  c0)  (X  Y  c0) [Logical expression F2 for determining sum] 1) With the input for which the output of truth table will become 1, determine AND operations where the result will be 1. When (X=0, Y=0, c0=1):  X   Y  c 0 When (X=0, Y=1, c0=0):  X  Y   c 0 When (X=1, Y=0, c0=0): X   Y   c 0 When (X=1, Y=1, c0=1): X  Y  c0 2) Determine logical expression F2 by combining the AND operations we determined with OR operations. Logical expression F2  (X  Y  c0)  (X  Y  c0) 68 Chapter 1 Hardware  (X  Y  c0)  (X  Y  c0) By expanding (simplifying) these logical expressions F1 and F2 by using logical laws, we can derive the configuration of a 3-bit adder circuit. However, even expansion of logical expression with this method is difficult, and it can be anticipated that configuration of the circuit will become complicated. Therefore, we will use half adders after 3-bit addition is divided into 2-bit addition. [Dividing 3-bit addition into 2-bit addition] 1) Add X and Y, and determine carry (c’) and sum (s’). 2) Add s’ and c0, and determine carry (c’’) and sum (s’’). s’’ determined here will be sum (s) in overall arithmetic operation. 3) If there is any carry in this addition, then carry will occur for overall arithmetic operation. Therefore, carry (c1) in overall arithmetic operation is determined with OR operation of c’ and c’’. (Carry will never be 1 in both the operations) Full adder shown in Figure 1-33 is the adder circuit configured on the basis of this concept. In a computer, the number of full adders equal to the number of bits of arithmetic operation is arranged to form the arithmetic operation circuit. Figure 1-33 Circuit diagram of full adder Next, let us think about the complement circuit. In order to perform arithmetic operations (four basic arithmetic operations) with only adders (half adder/full adder), we will need a circuit for determining complement (complementer) in order to perform subtraction by using addition. Inside a computer, binary arithmetic operations are performed. Therefore, it is common to use two types of complementers, namely, 1’s complementer that determines 1’s 69 complement, and 2’s complementer that determines 2’s complement. 1’s complement in binary numbers is determined by inverting the original bit sequence (0 is inverted to 1, and 1 is inverted to 0). Therefore, 1’s complementer can be formed only with NOT circuit. On the other hand, there are various methods of forming 2’s complementer. However, the concept of using an adder to add 1 to 1’s complement determined using 1’s complementer is a relatively easy method. 3 - 5 High Speed Technologies High speed technologies are technologies that increase the operating speed (processing capacity) of computers by creating new mechanisms using each device. 3-5-1 High Speed Memory Access Memory is the term that means a device or a medium that records data, and when simply referred to as “memory,” it mostly means the main memory unit (main memory). High speed memory access is a technology that resolves bottlenecks caused by difference in access speeds (access gap) by even slightly accelerating access to main memory (DRAM), which has slower access speed compared with the register (SRAM) of the processor. (1) Buffer memory Buffer memory is the medium-speed storage installed between high-speed storage and low-speed storage. Cache memory, which is a buffer memory, is the medium-speed storage composed of SRAM and installed between high-speed register and low-speed main memory. Figure 1-34 Working of cache memory In a computer system where cache memory is used, if the data required by the processor is available (when it is hit) in cache memory, then cache memory is accessed. On the other hand, when the data is not there (when it is mishit) in cache memory, main memory

Use Quizgecko on...
Browser
Browser