Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 1 Lecture 3 ENGRE 254 1/14/09

2 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 3

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

5 5 Binary multiplication and division example

6 6 Base 5 multiplication example X01234 000000 101234 20241113 303111422 404132231

7 7 Representing negative numbers Sign-magnitude. +199.12 10, -199.12 10, -101 2 –This is what people normally use. –Complicates digital logic. Complement number systems. –May use radix or radix-1 (actually r n or r n – 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.

8 8 9’s and 10’s complement.

9 9

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

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

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

13 13 Examples

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

15 15 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.

16 16

17 17 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”. 11111111 1 0 0 1 1

18 18 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 1492 10 in a 16 bit computer word. –In binary 1492 10 = 0000 0101 1101 0100 2 –In BCD 1492 10 is stored as –0001 0100 1001 0010 BCD

19 19 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.

20 20 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 1492 10 + 1066 10 = 2558 10 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.

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

22 22 DecimalBinaryGray 0000 1001 2010011 3 010 4100110 5101111 6110101 7111100

23 23 Gray Code conversion Binary to Gray The binary value B = b n …b 2 b 1 b 0 can be converted to Gray code G = g n …g 2 g 1 g 0. With g i = b i+1  b i or G = B  B/2 Examples: If B =110 then G = 110  011 = 101 If B = 10110111then G = 10110111  1011011 = 11101100

24 24 Gray to Binary From g i = b i  b i+1 it follows that b i = g i  b i+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

25 25 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.).

26 26

27 27 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 2 m vertices in which n-m bits of the coordinates have the same value. –See Figure 2-8 Page 57

28 28

29 29

30 30


Download ppt "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."

Similar presentations


Ads by Google