Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.

Similar presentations


Presentation on theme: "1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub."— Presentation transcript:

1 1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub

2 2 Digital Electronics …. Everywhere

3 3 Objective LEARN BASICS BEHIND COMPUTER SYSTEMS Hardware architecture and organization Digital logic design –Switching and logic gate design Computer architecture building blocks –Adders/subtractors/counters –Shift/rotate registers –Multiplexers/demultiplexers and encoders/decoders –Controllers and sequencers

4 4 Generic Computer System

5 5 Hierarchy in a System

6 6 NAND Gate Example

7 7 Analog and Digital Signal Analog signals vary continuously over a specified range with infinite values. t X(t) Analog signal Digital signals can assume only finite values. 7 Sampled Quantized Digital

8 8 Binary Logic Levels

9 9 Number Systems Number Systems? What are the different forms to represent the number systems? –Decimal –Hexadecimal representation –Binary representation –Arithmetic Operations

10 10 Decimal Number System Radix or base is equal to 10, e.g. N = 1256.932 N = 1x10 3 +2x10 2 +5x10 1 +6x10 0 +9x10 -1 +3x10 -2 +2x10 -3

11 11 Polynomial Representation of Numbers a n is the most significant digit or MSD and a -m is the least significant digit or LSD Radix or base can be any integer, most known systems are -r = 2 (binary) -r = 3 (Ternary) -r = 4 (Quaternary) -r = 8 (Octal) -r = 16 (Hexadecimal)

12 12 Commonly Used Number Systems NameDecimalBinaryOctalHexadecimal Radix102816 Possible digit values 0 to 90 and 10 to 70 to 9 A to F

13 13 Number Systems

14 14 Conversion to Decimal Binary to Decimal: N = (11010.1101) 2 N = 1x2 4 +1x2 3 +0x2 2 +1x2 1 +0x2 0 +1x2 -1 +1x2 -2 +0x2 -3 +1x2 -4 = 26.8125

15 15 Conversion to Decimal Octal: N = (4 5 2 6. 2 3) 8 N = 4x8 3 +5x8 2 +2x8 1 +6x8 0 +2x8 -1 +3x8 -2 = 2390 + 19/64 Hexadecimal: N = (A 1 F.1 C) 16 N = Ax16 2 +1x16 1 +Fx16 0 +1x16 -1 +Cx16 -2 =2592+28/256

16 16 Conversion from Decimal Radix Divide Technique: Divide the given integer successively by the target radix, noting the reminder in each step, until the quotient is zero. Collect the from each step starting from last to first. Convert (245) 10 = (?) 2

17 17 Conversion from Decimal Convert: (245) 10 = (?) 8 Convert: (245) 10 = (?) 16

18 18 Conversion from Decimal Radix Multiply Technique: Successively multiply the given fraction by the required base, noting the integer portion of the product at each step. Collect the integer digits starting from first to last. Convert: (0.345) 10 = (?) 2

19 19 Conversion from Decimal Covert: (242.45) 10 = (?) 2

20 20 Conversion Between Systems From Binary to: –Octal: arrange bits in groups of 3 and substitute (10111011001) 2 = (010 111 011 001) 2 = (2731) 8 –Hex: arrange bits in groups of 4 and substitute (10111011001) 2 = (0101 1101 1001) 2 = (5D9) 16 = (5D9) H Each single hex digit (4 bits) is called a nibble –Decimal: use general positional summation method (10111011001) 2 = 1x2 10 + 0x2 9 + 1x2 8 + 1x2 7 + 1x2 6 + 0x2 5 + 1x2 4 + 1x2 3 + 0x2 2 + 0x2 1 + 1x2 0 = (1497) 10

21 21 Conversion Between Systems From Octal to: –Binary: Substitute each Oct digit with 3 binary bits (1234) 8 = (001 010 011 100) 2 –Hex: Convert to binary, then to Hex (1234) 8 = (001 010 011 100) 2 = (0010 1001 1100) 2 = (29C) 16 –Decimal: use general positional summation method (1234) 8 = 1x8 3 + 2x8 2 + 3x8 1 + 4x8 0 = 1x512 + 2x64 + 3x8 + 4x1 = (668) 10

22 22 Conversion Between Systems From Hex to: –Binary: Substitute each Hex digit with 4 binary bits (C0DE) 16 = (1100 0000 1101 1110) 2 –Octal: Convert to binary, then to Hex (C0DE) 16 = (1100 0000 1101 1110) 2 = (001 100 000 011 011 110) 2 = (140336) 8 –Decimal: use general positional summation method (C0DE) 16 = 12x16 3 + 0x16 2 + 13x16 1 + 14x16 0 = 12x4096 + 0x256 + 13x16 + 14x1 = (49374) 10

23 23Arithmetic Arithmetic rules in all Number Systems are the same (-, +, *, / ), just remember the base Binary Arithmetic: Binary Addition

24 24 Binary Arithmetic Binary Subtraction: Binary Multiplication:

25 25 Binary Arithmetic Binary Division

26 26 Representation of Negative Numbers Why do we need a negative representation? Computers do not understand the negative sign. Example: (178) 10 is equivalent to (10110010) 2 Sign-Magnitude system: b n-1 b n-2 …… b 1 b 0 Example: -178 - 10110010 is equivalent to 1 10110010 +178+10110010 is equivalent to 0 10110010 If the computer has 9 bits to represent numbers use the MSB for the sign Sign bit N-1 magnitude bits

27 27 The Complement Number System A complement is a negative representation of a positive number (and vice versa) The complement of a number (N) r defined by: Twos Complement when r = 2 (Binary System) Examples: -The twos complement of (01010) 2 is 2 5 – (01010) = 100000 – 01010 = 10110 Complement numbers simplify subtractions –Subtraction is converted to addition –Simplifies hardware implementation

28 28 Twos Complement A shortcut to find the Twos complement: Similar to regular binary addition Ignore carry out of MSB

29 29 Ones Complement Another method to represent negative numbers, same as Two complement but do not add one. Example: the ones complement of (01010) 2 is 10101.

30 30 Negative Representation in Computers

31 31 Subtractions with Twos Complement Twos complement to represent negative numbers or subtractions. Example: A – B means A + (-B), i.e. calculate the Twos complement of B, and then add both. Consider A =5, B =4, then A + B is Consider A – B, or A + (-B), then

32 32 Subtractions with Twos Complement B – A or B + (-A) then:

33 33 Subtraction with Ones Complement A=5, and B = 4, then A + (– B) is equal to: Consider B + (– A):

34 34 Overflow What is overflow? –Result of arithmetic exceeds the range i.e. No enough bits to represent number Example: using 4 bit two’s complement binary: 6 + 5 = 11  0110 + 0101 = 1011 = -5 WRONG! The result 11 cannot be represented with 4 bits using two’s complement notation

35 35 When Will Overflow Occur? In unsigned arithmetic: –Adding two positive numbers, if we have a carry out from the MSB, then overflow occurred (overflow = MSB carry out) –Example: using 4 bit unsigned binary: 9 + 10 = 19  1001 + 1010 = 1 0011 = 3 Overflow! In signed two’s complement arithmetic: –Adding a positive and a negative number: overflow can never happen. Why? The result is always between the two numbers  can be represented with same number of bits –Adding two positive or two negative numbers, overflow can happen. How to detect? If sign of result is different than sign of two numbers being added  Overflow Remember: Carry out from MSB is always ignored!

36 36 Overflow Examples Add the following 8-bit two’s complement numbers. Find if there is an overflow or not. 10010110 01110100 ------------ 11011010 10010010 ------------ 01101110 01011101 ------------

37 37 Binary Coded Decimal Computers operate on binary numbers, but when communicate with humans, they use decimal. Conversion from binary to decimal and decimal to binary is necessary. The digits 0 to 9 are coded into binary bits (this is not decimal  binary conversion, it is digit coding) In the BCD code, each decimal digit is represented by 4 bits. The BCD code is the 8,4,2,1 code. BCD is a weighted code (8, 4, 2, and 1 are weights) This code is the simplest, most intuitive binary code for decimal digits and uses the same powers of 2 as a binary number, but only encodes the first ten values from 0 to 9.

38 38 BCD Code Binary Coded Decimal (BCD) –Decimal number 86 is represented in BCD with 8 bits as 1000 0110, with each group of 4 bits is an input to a seven segment display. – A decimal number in BCD is the same as its equivalent binary number only when the number is between 0 and 9. –The binary combinations 1010 through 1111 are not used.

39 39 BCD Code Example: –Consider decimal number 185 and its corresponding value in BCD and binary: BCD addition (hint: Add +6 if the sum >9 )

40 40 BCD Code Example: –Consider the addition of 184 + 576 = 760 in BCD:

41 41 Gray Code –Advantage: only one bit is changed between any two successive codes

42 42 ASCII Code American Standard Code for Information Interchange (ASCII) 42

43 43 ASCII Properties –Digits 0 to 9 span Hexadecimal values 30 16 to 39 16 –Upper case A-Z span 41 16 to 5A 16 –Lower case a-z span 61 16 to 7A 16 –Lower to upper case translation (and vice versa) occurs by flipping bit 6.

44 44 Other Codes

45 45 Error Detection Error-Detecting Code –To detect errors in data communication and processing, an eighth bit is sometimes added to the ASCII character to indicate its parity. –A parity bit is an extra bit included with a message to make the total number of 1's either even or odd. Example: characters with even and odd parity

46 46 Warning: Conversion or Coding? Do NOT mix up conversion of a decimal number to a binary number with coding a decimal number with a BINARY CODE. 13 10 = 1101 2 (This is conversion) 13  0001|0011 (This is coding)

47 47 Chapter 1 47UNICODE UNICODE extends ASCII to 65,536 universal characters codes –For encoding characters in world languages –Available in many modern applications –2 byte (16-bit) code words

48 48 Kilo, Mega, Giga, Tera, Peta Common use prefixes NameAbbrFactor KiloK2 10 = 1,024 MegaM2 20 = 1,048,576 GigaG2 30 = 1,073,741,824 TeraT2 40 = 1,099,511,627,776 PetaP2 50 = 1,125,899,906,842,624


Download ppt "1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub."

Similar presentations


Ads by Google