Download presentation

Presentation is loading. Please wait.

Published byBrittney Owen Modified about 1 year ago

1
CEC 220 Digital Circuit Design Binary Codes Wednesday, January 14 CEC 220 Digital Circuit Design Slide 1 of 16

2
Lecture Outline Wednesday, January 14 CEC 220 Digital Circuit Design Binary Arithmetic Review Extending Numeric Precision Binary coded decimal Slide 2 of 16

3
Binary Codes Binary Arithmetic Review Wednesday, January 14 CEC 220 Digital Circuit Design The following Binary pattern represents what signed number? Given that the representation is sign and magnitude? Given that the representation is 1’s complement? Given that the representation is 2’s complement? What is the difference between carry out and overflow? How do we convert to base 6 ? = = = - 10 Slide 3 of 16

4
Binary Codes Extending Precision Wednesday, January 14 CEC 220 Digital Circuit Design How do we increase the number of bits used to represent (in 2’s comp) a given number? We don’t want to change the numeric value!! Simply sign extend the number i.e. replicate the sign bit again & again … Example: 0011 1010 becomes = +3 (in four bits) = +3 (in eight bits) = -6 (in four bits) = -6 (in eight bits) becomes Slide 4 of 16

5
Binary Codes Increasing Precision Wednesday, January 14 CEC 220 Digital Circuit Design Range of Integers (2’s complement representation) An 8-bit unsigned integer? A 16-bit unsigned integer? A 32-bit unsigned integer? An 8-bit signed integer? A 16-bit signed integer? A 32-bit signed integer? 0 to (2 n -1) = 0 to to (2 n -1) = 0 to 65, (2 n-1 ) to (2 n-1 -1) = to (2 n-1 ) to (2 n-1 -1) = -32, to 32, to (2 n -1) = 0 to 4,294,967, (2 n-1 ) to (2 n-1 -1) = -2,147,483, to 2,147,483, Slide 5 of 16

6
Binary Codes Increasing Precision Wednesday, January 14 CEC 220 Digital Circuit Design Representation of Floating Point Numbers Example of the IEEE 754 standard o Single precision 32 bit floating point format o For this example: – Sign = 0, hence, a positive number – Exponent = 124, hence, – Fraction = …0 2 = 1+0x x x2 -3 +… = o Hence, the number is +1.25/8 = = Slide 6 of 16

7
Binary Codes Binary Coded Decimal (BCD) Wednesday, January 14 CEC 220 Digital Circuit Design Represent a decimal by encoding each individual digit in binary form How many bits do we need to represent each digit? o Ten possible choices for each digit (i.e. 0 to 9) An example of using the binary coded decimal representation (BCD) Not a very efficient use of “bits” !!! Slide 7 of 16

8
Binary Codes Weighted Codes Wednesday, January 14 CEC 220 Digital Circuit Design BCD is one example of a generalized “weighted” code: Weights: Binary digits: In the case of BCD the weights are: o E.g.: 0110 = 8x0+4x1+2x1+1x0 = 6 BCD is referred to as a weighted code o The codes 1010, 1011, 1100, 1101, 1110, and 1111 are unused Decimal Digit Code (BCD) Slide 8 of 16

9
Binary Codes Other Weighted Codes Wednesday, January 14 CEC 220 Digital Circuit Design Code Example: o Encode 4 via a code; – Hence, 4 = 0101 as a code – Also, 4 = 0110 as a code Decimal Digit Code The encoding is not unique !! Slide 9 of 16

10
Binary Codes Weighted Codes Wednesday, January 14 CEC 220 Digital Circuit Design Other Weighted Codes Excess-3 Code: BDC + 3 Decimal Digit Code (BCD) Excess-3 Code = Slide 10 of 16

11
Binary Codes Weighted Codes Wednesday, January 14 CEC 220 Digital Circuit Design Other Weighted Codes 2-out-of-5 Code o Two out of 5 bits are 1’s for every decimal digit Decimal Digit 2-out-of-5 Code Slide 11 of 16

12
Binary Codes Weighted Codes Wednesday, January 14 CEC 220 Digital Circuit Design Other Weighted Codes Grey Code o Codes for successive decimal digits differ by exactly one bit Decimal Digit Gray Code Slide 12 of 16

13
Binary Codes Various Codes Wednesday, January 14 CEC 220 Digital Circuit Design Decimal Digit Code (BCD) Code Excess-3 Code 2-out-of-5 Code Gray Code Slide 13 of 16

14
Binary Codes ASCII Codes Wednesday, January 14 CEC 220 Digital Circuit Design Slide 14 of 16

15
Binary Codes Binary Codes: Examples Wednesday, January 14 CEC 220 Digital Circuit Design What does represent in a weighted code? What does represent in a BCD (i.e ) weighted code? Express 4 9 in excess-3 code = =4 ANS: = = 01119= =1100 ANS: = =6 ANS: 8 6 Slide 15 of 16

16
Next Lecture Wednesday, January 14 CEC 220 Digital Circuit Design Introduction to Boolean Algebra Slide 16 of 16

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google