1 / 30

Understanding Digital Logic Circuits: From Binary Operations to BCD Addition and Gray Codes

Explore digital signals, two types of circuits, non-decimal arithmetic, two's complement, BCD numbers, Gray codes, and more in this comprehensive lecture. Learn about character codes like ASCII and Unicode. Practice BCD addition and Gray code conversion examples.

dayton
Download Presentation

Understanding Digital Logic Circuits: From Binary Operations to BCD Addition and Gray Codes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 3 ENGRE 254 1/14/09

  2. Lecture 1 review • Digital signals assume two values represented by “0” and “1”. Typically a “0” represents a voltage near 0 volts, and a “1” represents a voltage near 5 volts (3.3 volts for newer devices). • Two types of digital circuits: • Combinational • Simpler • Output a function of present input. • Consists of logic gates without feedback. • Sequential • The output is a function of not only the present input, and current state which is determined by past events. • Consists of flip-flops or gates with feedback.

  3. Non-decimal arithmetic. • Same rules as decimal. • Different addition, subtraction, multiplication tables. • Binary Examples

  4. Binary multiplication and division example

  5. Base 5 multiplication example

  6. Representing negative numbers • Sign-magnitude. +199.1210, -199.1210, -1012 • This is what people normally use. • Complicates digital logic. • Complement number systems. • May use radix or radix-1 (actually rn or rn – 1 for n digit words). • In base 10 we use 10’s complement or 9’s complement. • In base 2 we use 2’s complement or 1’s complement. • Simplifies digital logic. Eliminates need for separate hardware for addition and subtraction. • The 2’s complement has become the standard. • We will concentrate on 2’s complement.

  7. 9’s and 10’s complement.

  8. One’s Complement Rule: Complement each bit.

  9. Two’s complement • To find 2’s complement. • Easy way. Starting at rightmost bit, copy through first 1 then complement each bit.

  10. 2’s complement • With n bits we can represent binary values form 0 to 2n-1. • For example with 3 bits: 000, 001, …, 111. • With 3 bits 111 + 001 = 000. (Overflow!) • For an n bit number B, B2 = 2n – B • -B = -2n + B2 • A – B = -2n + A + B2 Rule: To subtract A – B take two’s complement of B and add. Ignore contents of 2n bit position.

  11. Examples

  12. Two’s complement example (using 6 bits) Consider other examples such as: 12-17, -12-(-17), -17-(-12), etc.

  13. Binary codes for decimal numbers. • Decimal numbers are represented in a digital system using a string of bits. • This can be done in various ways. • A set of n-bit strings where different strings represent different numbers or other things is called a code. • A particular combination of n-bit values is called a code word. • See Table 2-9 on page 49 for example codes for decimal digits. • A common and convenient code for decimal numbers is BCD.

  14. Lab 2: Wire up the circuit below and verify that it converts 2421 code to BCD. For example an input of “1111” produces output of “1001”. 1 1 1 1 1 1 0 0 1

  15. BCD • BCD is a binary representation of decimal numbers in a form that can easily be interpreted by a person. • Suppose we want to store 149210 in a 16 bit computer word. • In binary 149210 = 0000 0101 1101 01002 • In BCD 149210 is stored as • 0001 0100 1001 0010BCD

  16. BCD addition • Suppose 1492 and 1066 are stored in BCD. 1492  0001 0100 1001 0010 1066  0001 0000 0110 0110 If we add these in binary we get an incorrect result. Rule to add BCD numbers start at least significant BCD position (4 bits) add in binary if there is a carry or the result is grater than 9 add 6. Repeat for each BCD position.

  17. BCD addition example 0001 0100 1001 0010 0001 0000 0110 0110 ____ 1000 = 8 < 9 no carry OK 1111 = 15 > 9 must add 6 0110 ___1 0101 Now OK (9 + 6 = 15) ____ 0101 = 5 < 9 no carry OK 0010 = 2 < 9 no carry OK Final BCD Answer = 0010 0101 0101 1000 149210 + 106610 = 255810 Conclusion BCD addition is easy we just have to know when to correct by adding 6. Some microprocessors have a decimal adjust addition (DAA) instruction for automatically performing BCD addition correction.

  18. Gray Code The most common example of a unit distance code (Successive values differ by only one bit). See Table 2-10 page 52. Binary code Gray code

  19. Gray Code conversionBinary to Gray • The binary value B = bn…b2 b1 b0 can be converted to Gray code G = gn…g2 g1 g0. • With gi = bi+1 bi or G = B  B/2 Examples: If B =110 then G = 110  011 = 101 If B = 10110111then G = 10110111  1011011 = 11101100

  20. Gray to Binary From gi = bi bi+1 it follows that bi = gi  bi+1 • Example: Let G = 01011111. Then using b8 = 0. • b7 = g7  b8 = 0  0 = 0 • b6 = g6  b7 = 1  0 = 1 • b5 = g5  b6 = 0  1 = 1 • b4 = g4  b5 = 1  1 = 0 • b3 = g3  b4 = 1  0 = 1 • b2 = g2  b3 = 1  1 = 0 • b1 = g1  b2 = 1  0 = 1 • b0 = g0  b1 = 1  1 = 0 • B = 01101010

  21. Character Codes • ASCII most common code for representing alphanumeric characters. • 7 bit code. Typically stored in a byte. The 8th bit can be used for parity or extended characters. • See Table 2-11 on page 54. • Microsoft has introduced Unicode, a 16-bit code, and MBCC to provided windows support for extended characters (Japanese etc.).

  22. n-cubes and distance • The values of an n-bit code can be considered as the coordinates of vertices of an n-dimensional Boolean hypercube. • See figure 2-8 on page 57. • Useful for visualizing coding concepts. • See figure 2-9 on page 57. • Hamming distances – The number of bits in which the coordinates of two points differ. • See figure 2-10 page 59. • m-subcube – a set of 2m vertices in which n-m bits of the coordinates have the same value. • See Figure 2-8 Page 57

More Related