2 Overview Digital Systems, Computers, and Beyond Information RepresentationNumber Systems [binary, octal and hexadecimal]Arithmetic OperationsBase ConversionDecimal Codes [BCD (binary coded decimal)]Alphanumeric CodesParity BitGray Codes
3 Digital LogicDeals with the design of computersEarly computers were used for computations of discrete elements (digital)The term logic is applied to circuits that operate on a set of just two elements with values True and False
4 DIGITAL & COMPUTER SYSTEMS - Digital System Takes a set of discrete information inputs and discrete internal information (system state) and generates a set of discrete information outputs.System StateDiscreteInformationProcessingSystemInputsOutputs
5 Digital Computer Example MemoryControlCPUDatapathunitInputs: keyboard, mouse, wireless, microphoneOutputs: LCD screen, wireless, speakersAnswer: Part of specification for a PC is in MHz. What does that imply? A clock which defines the discrete times for update of state for a synchronous system. Not all of the computer may be synchronous, however.Input/OutputSynchronous or Asynchronous?
6 And Beyond – Embedded Systems Computers as integral parts of other productsExamples of embedded computersMicrocomputersMicrocontrollersDigital signal processors
7 Examples of Embedded Systems Applications Cell phonesAutomobilesVideo gamesCopiersDishwashersFlat Panel TVsGlobal Positioning Systems
8 INFORMATION REPRESENTATION - Signals Information represents either physical or man-made phenomenaPhysical quantities such as weight, pressure, and velocity are mostly continuous (may take any value)Man-made variables can be discrete such as business records, alphabet, integers, and unit of currencies.This discrete value can be represented using multiple discrete signals.Two level, or binary signals are the most prevalent values in digital systems.
9 Signal Examples Over Time Continuous in value & timeAnalogDigitalDiscrete in value & continuous in timeAsynchronousDiscrete in value & timeSynchronous
10 Signal Example – Physical Quantity: Voltage Threshold RegionThe HIGH range typically corresponds to binary 1 and LOW range to binary 0. The threshold region is a range of voltagesfor which the input voltage value cannot be interpreted reliably as either a 0 or a 1.The two discrete values are defined by ranges of voltages called LOW and HIGHBinary values are represented abstractly by:Digits 0 and 1, words (symbols) False (F) and True (T), words (symbols) Low (L) and High (H), and words On and Off.
11 Binary Values: Other Physical Quantities What are other physical quantities represent 0 and 1?CPU VoltageDiskCDDynamic RAMMagnetic Field DirectionSurface Pits/LightElectrical Charge
12 NUMBER SYSTEMS – Representation Positive radix, positional number systemsA number with radix r is represented by a string of digits: An - 1An - 2 … A1A0 . A- 1 A- 2 … A- m + 1 A- m in which 0 £ Ai < r and . is the radix point.Digits available for any radix r system 0,1,2,…, r-1The string of digits represents the power series:(Number)r=å+j = - mjii = 0rA(Integer Portion)(Fraction Portion)i = n - 1j = - 1()()
13 Number Systems – Examples GeneralDecimalBinaryRadix (Base)r102Digits0 => r - 10 => 90 => 113Powers of 4Radix-1-2-3-4-5r0r1r2r3r4r5r -1r -2r -3r -4r -5100100010,000100,0000.10.010.0010.000148163188.8.131.520.0625
14 Special Powers of 2 220 (1,048,576) is Mega, denoted "M" 210 (1024) is Kilo, denoted "K"220 (1,048,576) is Mega, denoted "M"230 (1,073, 741,824)is Giga, denoted "G"240 (1,099,511,627,776 ) is Tera, denoted “T"
15 ARITHMETIC OPERATIONS - Binary Arithmetic Single Bit Addition with CarryMultiple Bit AdditionSingle Bit Subtraction with BorrowMultiple Bit SubtractionMultiplication
17 Multiple Bit Binary Addition Extending this to two multiple bit examples:CarriesAugendAddendSumNote: The 0 is the default Carry-In to the least significant bit.CarriesAugendAddendSum
18 Single Bit Binary Subtraction with Borrow Given two binary digits (X,Y), a borrow in (Z) we get the following difference (S) and borrow (B):Borrow in (Z) of 0:Borrow in (Z) of 1:ZX1- Y-0-1BS0 01 10 1Z1X- Y-0-1BS111 00 01 1
19 Multiple Bit Binary Subtraction Extending this to two multiple bit examples:BorrowsMinuendSubtrahendDifferenceNotes: The 0 is a Borrow-In to the least significant bit. If the Subtrahend > the Minuend, interchange and append a – to the result.BorrowsMinuendSubtrahend – –10011Difference
21 BASE CONVERSION - Positive Powers of 2 Useful for Base ConversionExponentValueExponentValue1112,04812124,09624138,192381416,3844161532,7685321665,53666417131,072712818262,144825619524,2889512201,048,576101024212,097,152
22 Converting Binary to Decimal To convert to decimal, use decimal arithmetic to form S (digit × respective power of 2).Example:Convert to N10: Powers of 2: 43210=>1 X = 16+ 1 X = 8+ 0 X = 0+ 1 X 21 = 2+ 0 X 20 = 02610
23 Commonly Occurring Bases NameRadixDigitsBinary20,1Octal80,1,2,3,4,5,6,7Decimal100,1,2,3,4,5,6,7,8,9Hexadecimal160,1,2,3,4,5,6,7,8,9,A,B,C,D,E,FThe six letters (in addition to the 10integers) in hexadecimal represent:Answer: The six letters A, B, C, D, E, and F represent the digits for values10, 11, 12, 13, 14, 15 (given in decimal), respectively, in hexadecimal.Alternatively, a, b, c, d, e, f are used.
24 Numbers in Different Bases Good idea to memorize!DecimalBinaryOctalHexadecimal(Base 10)(Base 2)(Base 8)(Base 16)000000000000100001010102000100202030001103030400100040405001010505060011006060700111070708010001008090100111091001010120A1101011130B1201100140C1301101150D1401110160E1501111170F16100002010
25 Conversion Between Bases To convert from one base to another:1) Convert the Integer Part2) Convert the Fraction Part3) Join the two results with a radix point
26 Conversion Details To Convert the Integral Part: Repeatedly divide the number by the new radix and save the remainders. The digits for the new radix are the remainders in reverse order of their computation. If the new radix is > 10, then convert all remainders > 10 to digits A, B, …To Convert the Fractional Part:Repeatedly multiply the fraction by the new radix and save the integer digits that result. The digits for the new radix are the integer digits in order of their computation. If the new radix is > 10, then convert all integers > 10 to digits A, B, …
27 Example: Convert 46.687510 To Base 2 Join the results together with the radix point:Answer 1: Converting 46 as integral part: Answer 2: Converting as fractional part:46/2 = 23 rem = * 2 = int = 123/2 = 11 rem = * 2 = int = 011/2 = 5 remainder = * 2 = int = 15/2 = 2 remainder = * 2 = int = 12/2 = 1 remainder =1/2 = 0 remainder = Reading off in the forward direction:Reading off in the reverse direction:Answer 3: Combining Integral and Fractional Parts:
28 Additional Issue - Fractional Part Note that in this conversion, the fractional part can become 0 as a result of the repeated multiplications.In general, it may take many bits to get this to happen or it may never happen.Example Problem: Convert to N20.65 = …The fractional part begins repeating every 4 steps yielding repeating 1001 forever!Solution: Specify number of bits to right of radix point and round or truncate to this number.
29 Checking the Conversion To convert back, sum the digits times their respective powers of r. From the prior conversion of = 1·32 + 0·16 +1·8 +1·4 + 1·2 +0·1== 46= 1/2 + 1/8 + 1/16==
30 Octal (Hexadecimal) to Binary and Back Restate the octal (hexadecimal) as three (four) binary digits starting at the radix point and going both ways.Binary to Octal (Hexadecimal):Group the binary digits into three (four) bit groups starting at the radix point and going both ways, padding with zeros as needed in the fractional part.Convert each group of three bits to an octal (hexadecimal) digit.
31 Octal to Hexadecimal via Binary Convert octal to binary.Use groups of four bits and convert as above to hexadecimal digits.Example: Octal to Binary to HexadecimalWhy do these conversions work?Answer 1:110|011| |111|111 2Regroup:1|1001| |1111|1(000)2Convert:D FAnswer 2: Marking off in groups of three (four) bits corresponds to dividing or multiplying by 23 = 8 (24 = 16) in the binary system.
32 Convert the following numbers to the specified bases (F3D2)16 (?)10 ExamplesConvert the following numbers to the specified bases(F3D2)16 (?)10(341)8 (?)16(153)10 (?)2( )2 (?)10(245)10 (?)1615 *16^3 + 3* 16^2 + 13* = (62418) group in 4s E1153 / 2 = 76 + ½76/2 = /238/2 = /219/2 = ½9/2 = 4 + ½4/2 = 2 + 0/22/2 = 1 + 0/2½ = 0 + ½answer =(4) 1*2^ * 2^3 + 1 *2^ = 77245/16 = /1615 /16 = /16answer = F5
33 Binary Numbers and Binary Coding Flexibility of representationWithin constraints below, can assign any binary combination (called a code word) to any data as long as data is uniquely encoded.Information TypesNumericMust represent range of data neededVery desirable to represent data such that simple, straightforward computation for common arithmetic operations permittedTight relation to binary numbersNon-numericGreater flexibility since arithmetic operations not applied.Not tied to binary numbers
34 Non-numeric Binary Codes Given n binary digits (called bits), a binary code is a mapping from a set of represented elements to a subset of the 2n binary numbers.Example: A binary code for the seven colors of the rainbowCode 100 is not usedColorBinary Number000001010011101110111RedOrangeYellowGreenBlueIndigoViolet
35 Number of Bits Required For coding Given M elements to be represented by a binary code, the minimum number of bits, n, needed, satisfies the following relationships:2n ³ M > 2(n – 1)n = log2 M where x , called the ceiling function, is the integer greater than or equal to x.Example: How many bits are required to represent decimal digits with a binary code?M = 10Therefore n = 4 since:24 =16 is 10 > 23 = 8and the ceiling function for log2 10 is 4.
36 Number of Elements Represented Given n digits in radix r, there are rn distinct elements that can be represented.But, you can represent m elements, m < rnExamples:You can represent 4 elements in radix r = 2 with n = 2 digits: (00, 01, 10, 11).You can represent 4 elements in radix r = 2 with n = 4 digits: (0001, 0010, 0100, 1000).This second code is called a "one hot" code.
37 BCD Code Binary Coded Decimal Decimal digits stored in binary Four bits/digitLike hex, except stops at 9Example931 is coded asEasier to interpret, but harder to manipulate.Remember: these are just encodings. Meanings are assigned by us.
38 ALPHANUMERIC CODES - ASCII Character Codes American Standard Code for Information InterchangeThis code is a popular code used to represent information sent as character-based data. It uses 7-bits to represent:94 Graphic printing characters.34 Non-printing charactersSome non-printing characters are used for text format (e.g. BS = Backspace, CR = carriage return)Other non-printing characters are used for record marking and flow control (e.g. STX and ETX start and end text areas).(Refer to Table 1-4 in the text)
40 ASCII Properties ASCII has some interesting properties: Digits 0 to 9 span Hexadecimal values 3016to 3916.Upper case A-Z span 4116to 5A16.Lower case a-z span 6116to 7A16.Lower to upper case translation (and vice versa)occurs byflipping bit 6.Delete (DEL) is all bits set,a carryover from whenpunched paper tape was used to store messages.Punching all holes in a row erased a mistake!
41 PARITY BIT Error-Detection Codes Redundancy (e.g. extra information), in the form of extra bits, can be incorporated into binary code words to detect and correct errors.A simple form of redundancy is parity, an extra bit appended onto the code word to make the number of 1’s odd or even. Parity can detect all single-bit errors and some multiple-bit errors.A code word has even parity if the number of 1’s in the code word is even.A code word has odd parity if the number of 1’s in the code word is odd.
42 4-Bit Parity Code Example Fill in the even and odd parity bits:The codeword "1111" has even parity and the codeword "1110" has odd parity. Both can be used to represent 3-bit data.Even ParityOdd ParityMessageParityMessageParity--000000--001001--010010--011011--100100--101101--Even Parity Bits: 0, 1, 1, 0, 1, 0, 0, 1Odd Parity Bits: 1, 0, 0, 1, 0, 1, 1, 0110110--111111--
43 GRAY CODE – DecimalWhat special property does the Gray code have in relation to adjacent decimal digits?DecimalBCDGray00000000100010100200100101300110111401000110501010010601100011701110001810001001Answer: As we “counts” up or down in decimal, the code word for the Gray code changes in only one bit position as we go from decimal digit to digit including from 9 to 0.910011000
44 Does this special Gray code property have any value? Optical Shaft EncoderDoes this special Gray code property have any value?An Example: Optical Shaft Encoder111000100000BB1110001101001B2Yes, as illustrated by the example that followed.G2G1G111010101011100011110010(a) Binary Code for Positions 0 through 7(b) Gray Code for Positions 0 through 7
45 Shaft Encoder (Continued) How does the shaft encoder work?For the binary code, what codes may be produced if the shaft position lies between codes for 3 and 4 (011 and 100)?Is this a problem?Answer 1: The encoder disk contains opaque and clear areas.Opaque represents a 0 and clear a 1. Light shining through each ring of the encoder corresponding to a bit of the code strikes a sensor to produce a 0 or a 1.Answer 2: In addition to the correct code, either 011 or 100, the codes 000, 010, 001, 110, 101, or 111 can be produced.Answer 3: Yes, the shaft position can be completely UNKNOWN!
46 Shaft Encoder (Continued) For the Gray code, what codes may be produced if the shaft position lies between codes for 3 and 4 (010 and 110)?Is this a problem?Does the Gray code function correctly for these borderline shaft positions for all cases encountered in octal counting?Answer 1: Only the correct codes, either 010 or 110Answer 2: No, the shaft position is known to be either 3 or 4 which is OK since it is halfway in between.Answer 3: Yes, since an erroneous code cannot arise. This includes between 0 and 7 (000 and 100).
47 UNICODE extends ASCII to 65,536 universal characters codes For encoding characters in world languagesAvailable in many modern applications2 byte (16-bit) code wordsSee Reading Supplement – Unicode on the Companion Website
48 Topics Covered Discrete information and systems Positive radix positional numbering systemsDecimal, Binary, Octal, HexadecimalBase conversionBinary codesASCCII, BCD, Gray CodeParity encoding