520 likes | 756 Views
CSE 303 COMPUTER ORGANIZATION. Yrd. Doç. Dr. Mehmet Ali Aktaş. Data Representation in Computer Systems. The organization of any computer depends considerably on how it represents numbers , characters, and control information .
E N D
CSE 303 COMPUTER ORGANIZATION Yrd. Doç. Dr. Mehmet Ali Aktaş
Data Representation inComputerSystems • The organization of any computer depends considerably on how it representsnumbers, characters, and control information. • The most basic unit of information in a digital computer is called a bit, whichis a contraction of binary digit. In the concrete sense, a bit is nothing more than astate of “on” or “off ” (or “high” and “low”) within a computer circuit. • Computer words consist of two or more adjacent bytes that are sometimesaddressed and almost always are manipulated collectively. The word size representsthe data size that is handled most efficiently by a particular architecture. • Words can be 16 bits, 32 bits, 64 bits, or any other size that makes sense withinthe context of a computer’s organization (including sizes that are not multiples ofeight).
Data Representation inComputerSystems • Positional NumberingSystems • The set of valid numerals for a positional numbering system is equal in sizeto the radix of that system. For example, there are 10 digits in the decimal system,0 through 9, and 3 digits for the ternary (base 3) system, 0, 1, and 2. • To distinguish among numbers in differentradices, we use the radix as a subscript, such as in to represent the decimalnumber 33. • EXAMPLE Three numbers represented as powers of a radix.
Data Representation inComputerSystems • The two most important radices in computer science are binary (base two), andhexadecimal (base 16). Another radix of interest is octal (base 8). The binary systemuses only the digits 0 and 1; the octal system, 0 through 7. The hexadecimalsystem allows the digits 0 through 9 with A, B, C, D, E, and F being used to representthe numbers 10 through 15.
Data Representation inComputerSystems • DecimalToBinaryConversions. • ConvertingUnsignedWholeNumbers • Conversion between base systems can be done by using either repeated subtractionor a division-remainder method. The subtraction method is cumbersomeand requires a familiarity with the powers of the radix being used. Being the moreintuitive of the two methods, however, we will explain it first. • As an example, let’s say that we want to convert to base 3.
Data Representation inComputerSystems • The division-remainder method is faster and easier than the repeated subtractionmethod. It employs the idea that successive divisions by the base are in fact successivesubtractions by powers of the base. The remainders that we get when wesequentially divide by the base end up being the digits of the result, which areread from bottom to top.
Data Representation inComputerSystems • This method works with any base, and because of the simplicity of the calculations,it is particularly useful in converting from decimal to binary. Example showssuch a conversion.
Data Representation inComputerSystems • ConvertingFractions • Fractions in any base system can be approximated in any other base system usingnegative powers of a radix. Radix points separate the integer part of a numberfrom its fractional part. In the decimal system, the radix point is called a decimalpoint. Binary fractions have a binary point.
Data Representation inComputerSystems • The methods just described can be used to directly convert any number in anybase to any other base, say from base 4 to base 3 (as in Example). • Itshould be first convertedto base 10 and then tothedesiredbase.
Data Representation inComputerSystems • ConvertingbetweenPower-of-TwoRadices • Binary numbers are often expressed in hexadecimal—and sometimes octal—toimprovetheirreadability. • Because , a group of 4 bits (called a hextet) iseasily recognized as a hexadecimal digit. Similarly, with , a group of 3 bits(called an octet) is expressible as one octal digit. • Using theserelationships, wecan therefore convert a number from binary to octal or hexadecimal by doing littlemore than looking at it.
Data Representation inComputerSystems • 2.5 FLOATING-POINT REPRESENTATION • If we wanted to build a real computer, we could use any of the integer representationsthatwejuststudied. • We would pick one of them and proceed with our designtasks. • Formany years, clever programming enabled these integer systems to act as if theywere, in fact, floating-point systems.
Data Representation inComputerSystems • If you are familiar with scientific notation, you may already be thinking of howyou could handle floating-point operations. • In scientific notation, numbers are expressed in twoparts: a fractional part, called a mantissa, and an exponential part that indicates thepower of ten to which the mantissa should be raised to obtain the value we need. • It is also the basis for floating-point computation in today’s digital computers.
Data Representation inComputerSystems • In digital computers, floating-point numbers consist of three parts: a sign bit, anexponent part (representing the exponent on a power of 2), and a fractional partcalled a significand(which is a fancy word for a mantissa). • Thenumber of bitsused for the exponent and significand depends on whether we would like to optimizefor range (more bits in the exponent) or precision (more bits in the significand). • Forexample, ifweneedtostore the decimal number 17 in14-bit model (as shown in Figure)with a 5-bitexponent, an 8-bit significand, and a sign bit.
Data Representation inComputerSystems • Weknowthat • Analogously, in binary, • If we use this last form, our fractional part will be 10001000 andour exponent will be 00101, as shown here:
BooleanAlgebraandDigitalLogic • Boolean algebra is an algebra for the manipulation of objects that can take ononly two values, typically true and false. • Because computers are built as collections of switches that are either “on” or“off,” Boolean algebra is a very natural way to represent digital information. • Inreality, digital circuits use low and high voltages, but for our level of understanding,0 and 1 will suffice.
BooleanAlgebraandDigitalLogic • It is common to interpret the digital value 0 as false andthe digital value 1 as true. • A Boolean function typically has one or more inputvalues and yields a result, based on these input values, in the range {0,1}. • Three common Boolean operators are AND, OR, and NOT. To better understandthese operators, we need a mechanism to allow us to examine their behaviors.
BooleanAlgebraandDigitalLogic • A Boolean operator can be completely described using a table that lists theinputs, all possible values for these inputs, and the resulting values of the operationfor all possible combinations of these inputs. • This table is called a truthtable. A truth table shows the relationship, in tabular form, between the input valuesand the result of a specific Boolean operator or function on the input variables. • Let’s look at the Boolean operators AND, OR, and NOT to see how each isrepresented, using both Boolean algebra and truth tables.
BooleanAlgebraandDigitalLogic • The logical operator AND is typically represented by either a dot or no symbolat all. For example, the Boolean expression xyis equivalent to the expressionx · y and is read “x and y.” The expression xyis often referred to as a Booleanproduct. • The behavior of this operator is characterized by the truth table shown inTable
BooleanAlgebraandDigitalLogic • The Boolean operator OR is typically represented by a plus sign. Therefore,the expression x + y is read “x or y.” • Thetruth table for OR is shown in Table.
BooleanAlgebraandDigitalLogic • The remaining logical operator, NOT, is represented typically by either anoverscoreor a prime. Therefore, both and x’are read as “NOT x.” The truthtable for NOT is shown in Table.
BooleanAlgebraandDigitalLogic • We now understand that Boolean algebra deals with binary variables and logicaloperations on those variables. Combining these two concepts, we can examineBoolean expressions composed of Boolean variables and multiple logicoperators. For example, the Boolean function:
BooleanAlgebraandDigitalLogic • Boolean expressions can also besimplified, but we need new identities, or laws, that apply to Boolean algebrainsteadof regularalgebra. • These identities, which apply to single Boolean variablesas well as Boolean expressions, are listed in Table.
BooleanAlgebraandDigitalLogic Simplification of BooleanExpressions • EXAMPLE Suppose we have the function F(x,y) = xy+ xy. Using the ORform of the Idempotent Law and treating the expression xyas a Boolean variable,we simplify the original expression to xy. Therefore, F(x,y) = xy+ xy= xy.
BooleanAlgebraandDigitalLogic • EXAMPLE Given the function , we simplify asfollows:
BooleanAlgebraandDigitalLogic LOGIC GATES • The actual physical components, or digital circuits, such as those that performarithmetic operations or make choices in a computer, are constructed from a numberof primitive elements called gates. • Gates implement each of the basic logicfunctions we have discussed. These gates are the basic building blocks for digitaldesign. Formally, a gate is a small, electronic device that computes various functions of two-valuedsignals.
BooleanAlgebraandDigitalLogic • We initially examine the three simplest gates. These correspond to the logicaloperators AND, OR, and NOT. We have discussed the functional behaviorofeach of these Boolean operators. Figure depicts the graphical representationof the gate that corresponds to each operator.
BooleanAlgebraandDigitalLogic • Another common gate is the exclusive-OR (XOR) gate, represented by theBoolean expression: x ⊕y.
BooleanAlgebraandDigitalLogic • Two other common gates are NAND and NOR, which produce complementaryoutput to AND and OR, respectively. Each gate has two different logic symbolsthat can be used for gate representation.
BooleanAlgebraandDigitalLogic MultipleInputGates • In examples, all gates have accepted only two inputs. Gates are notlimited to two input values. There are many variation.
BooleanAlgebraandDigitalLogic • Upon opening a computer and looking inside, one would realize that there is a lotto know about all of the digital components that make up the system. • Everycomputeris built using collections of gates. • These collections of gates are often quite standard,resulting in a set of building blocks that can be used to build the entire computersystem.
BooleanAlgebraandDigitalLogic Digital Circuits and Their Relationship to Boolean Algebra • What is the connection between Boolean functions and digital circuits? • Wehaveseen that a simple Boolean operation (such as AND or OR) can be represented by a simplelogicgate. • More complex Boolean expressions can be represented ascombinations of AND, OR, and NOT gates, resulting in a logic diagram thatdescribestheentireexpression. • We can build logic diagrams (which in turn lead to digital circuits) for anyBooleanexpression.
BooleanAlgebraandDigitalLogic • Boolean algebra allows us to analyze and design digital circuits. Because ofthe relationship between Boolean algebra and logic diagrams, we simplify our circuitby simplifying our Boolean expression.
BooleanAlgebraandDigitalLogic IntegratedCircuits • Typically, gates are not sold individually; they are sold in units called integratedcircuits (ICs). A chip (a small silicon semiconductor crystal) is a smallelectronic device consisting of the necessary electronic components (transistors,resistors, and capacitors) to implement various gates. COMBINATIONAL CIRCUITS • Digital logic chips are combined to give us useful circuits. These logic circuitscan be categorized as either combinational logic or sequential logic.
BooleanAlgebraandDigitalLogic Examples of Typical Combinational Circuits • Let’s begin with a very simple combinational circuit called a half-adder. Considerthe problem of adding two binary digits together. There are only three thingsto remember: 0 + 0 = 0, 0 + 1 = 1 + 0 = 1, and 1 + 1 = 10. • Weneed to specify two outputs, not just one, because we have a sum and a carry toaddress. The truth table for a half-adder is shown in Table. • A closer look reveals that Sum is actually an XOR. The Carry output isequivalent to that of an AND gate. We can combine an XOR gate and an ANDgate, resulting in the logic diagram for a half-adder shown in Figure
BooleanAlgebraandDigitalLogic • Full-Adder
BooleanAlgebraandDigitalLogic DECODER • When a computer is given an address, it must first determine which chip touse; then it must find the actual address on that specific chip. • Forexampleif3 high-order bits are actually usedas the inputs to a decoder so the computer can determine which chip to activateforreadingorwriting. • the first 3 bits are 000, chip 0 should be activated. If thefirst 3 bits are 111, chip 7 should be activated.