Digital System Design Digital Systems and Binary Number - PowerPoint PPT Presentation

1 / 84
About This Presentation
Title:

Digital System Design Digital Systems and Binary Number

Description:

Digital Systems and Binary Number Assoc. Prof. Pradondet Nilagupta pom_at_ku.ac.th Acknowledgement This lecture note is modified from Engin112: Digital Design by Prof ... – PowerPoint PPT presentation

Number of Views:292
Avg rating:3.0/5.0
Slides: 85
Provided by: Pradondet3
Category:

less

Transcript and Presenter's Notes

Title: Digital System Design Digital Systems and Binary Number


1
Digital System DesignDigital Systems and Binary
Number
  • Assoc. Prof. Pradondet Nilagupta
  • pom_at_ku.ac.th

2
Acknowledgement
  • This lecture note is modified from Engin112
    Digital Design by Prof. Maciej Ciesielski, Prof.
    Tilman Wolf, University of Massachusetts Amherst
    and original slide from publisher

3
Digital Hardware Systems
Digital Systems
Digital vs. Analog Waveforms
Analog values vary over a broad range
continuously
Digital only assumes discrete values
4
Digital Circuits
  • Digital circuit can be represented by a black-box
    with inputs on one side, and outputs on the other.

The input/output signals are discrete/digital in
nature, typically with two distinct voltages (a
high voltage and a low voltage).
In contrast, analog circuits use continuous
signals.
5
Digital Hardware Systems
  • Digital Binary System
  • Two discrete values
  • yes, on, 5 volts, current flowing, "1"
  • no, off, 0 volts, no current flowing, "0
  • Advantage of binary systems
  • rigorous mathematical foundation based on logic
  • its easy to implement

both the door must be open and the car running
before I can back out
IF the garage door is open AND the car is
running THEN the car can be backed out of the
garage
the preconditions must be true to imply the
conclusion
6
Binary Bit and Group Definitions
  • Bit - a single binary digit
  • Nibble - a group of four bits
  • Byte - a group of eight bits
  • Word - depends on processor 8, 16, 32, or 64
    bits
  • LSB - Least Significant Bit (on the right)
  • MSB - Most Significant Bit (on the left)

7
Binary Representation of Information
  • Information divided into groups of symbols
  • 26 English letters
  • 10 decimal digits
  • 50 states in USA
  • Digital systems manipulate information as 1s
    0s
  • The mapping of symbols to binary value is known
    as a code
  • The mapping must be unique

8
Digital Systems
  • Digital systems operate on discrete elements of
    information
  • Numbers (e.g., pocket calculator) -gt digits -gt
    digital
  • Letters (e.g., word processor)
  • Pictures (e.g., digital cameras)
  • For a digital systems to operate on a continuous
    data, it needs to quantize (digitize) that data
    first
  • Covert data into digital representation
  • Topics
  • How are numbers represented in digital systems
  • How computer performs basic arithmetic operations

9
Numbers
  • Common numbering system is base10
  • Why?
  • Numbers in base 10
  • Ten different digits 0, 1, 2, 3, 4, 5, 6, 7, 8,
    9
  • Number is represented by a sequence of digits an
    an-1 a1 a0
  • Value of number is an10nan-110n-1a1101a0
    100
  • Positional notation
  • General equation
  • May contain a decimal point
  • Negative index for digits after decimal point
  • Examples
  • 1234.56 if ambiguous, write (1234.56)10
  • Leading zeros cause no problems 00001234.56

10
Number Systems
  • General form, with base r
  • Base r is also called radix
  • In decimal system r 10 in binary r 2
  • Coefficients in positional notation are 0,1,,
    r-1.
  • What is the range of values of an n-bit number in
    radix r ?
  • Minimum value 0
  • Maximum value rn-1
  • Number of different values rn

11
Positional Number Systems
  • Numeric value is represented by a series of
    digits
  • Number of digits used is fixed by radix
  • Digits multiplied by a power of the radix
  • Digit order determines radix powers
  • Very large numbers can be represented
  • Can also represent fractional values.

12
Positional Integer Number Values
Given a digit series of The full expression
for the represented value is
13
Positional Fractional Number Values
Given a digit series of The full expression
for the represented value is
14
Binary Numbers
  • Base 2 number use only two digits 0, 1
  • Why?
  • Digits need to be represented in a system
  • Electronic systems typically use voltage levels
  • Representing 10 different voltages reliably is
    difficult
  • Binary decision is much easier (On, Off)
  • Binary representation is ideal
  • Minimal number of digits
  • Easily represented in voltages

15
Examples for Binary Numbers
  • What value is represented by (01001)2?
  • Leading zero makes no difference
  • (1001)2 translates into 123022021120800
    1(9)10
  • Same process for numbers with decimal point
  • What is the value of (1001.1001)2?
  • (1001.1001)2 12302202112012-102-20
    2-312-480011/2001/16(9.5625)10
  • Important its NOT (9.9)10!
  • Can you count binary?
  • How far can you count with 10 fingers?

16
Binary Number Terminology
  • Base is also called radix
  • Binary numbers are made of binary digits (bits)
  • Groups of four bits are called nibbles
  • E.g., (1101)2
  • Groups of eight bits are called bytes
  • E.g., (01001101)2
  • What is the range of values of an n-bit binary
    number?
  • Minimum value 0
  • Maximum value 2n-1
  • Number of different values 2n
  • Powers of 2 are important in ECE

17
Powers of 2
  • You must memorize all powers of 2 up to 216!
  • Other important powers of 2
  • Trick to simplify estimation
  • 21010241000103
  • Example 232423041094 billion
  • Prefixes
  • kilo (103 210), Mega (106 220), Giga (109
    230), Tera (1012 240),
  • In computer systems typically based on powers of 2

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536
8 16 24 32 64
256 65536 16777216 4294967296 18446744073709551616
18
Memory Size
  • Definition of Mega and Giga can make a
    difference!
  • Disk drive manufacturers define it conveniently
  • How many more MP3 songs could you store on this
    80GB disk if GB was based on the real computer
    systems definition?
  • Difference is 8023080109 5,899,345,920 bytes
  • 128kbit MP3 coding 16kB per second
  • 5,899,345,920/16,384 360000 s. 100 hours of
    music

19
Other Number Systems
  • Octal number system
  • Digits 0, 1, 7
  • Aggregates 3 digits of binary system (i.e., 3-bit
    number)
  • E.g., (57)8 (47)10
  • Hexadecimal number system
  • 16 digits require 6 new digit symbols 0, 9, A,
    B, C, D, E, F
  • Aggregates 4 digits of binary system (1 nibble or
    half byte)
  • E.g., (1F)16 (31)10
  • Conversion between system

20
Number Base Conversions
  • Conversion from base r to decimal
  • Expansion to power series and
    addition of terms
  • Conversion from decimal to base r
  • Divide number and successive quotients by r
  • Sequence of remainders is base r number
  • Example convert (41)10 to binary (r2)
  • 41 20 ? 2 1
  • 20 10 ? 2 0
  • 10 5 ? 2 0
  • 5 2 ? 2 1
  • 2 1 ? 2 0
  • 1 0 ? 2 1

a0 1 a1 0 a2 0 a3 1 a4 0 a5 1
(101001)2
21
Number Base Conversions
  • Conversion to/from octal and hexadecimal
  • Easier if done via binary
  • 3 or 4 bit sequences correspond to digit
  • Example

(2414)10(100101101110)2
  • Direct conversion possible, too
  • 2414 301 ? 8 6
  • 301 37 ? 8 5
  • 37 4 ? 8 5
  • 4 0 ? 8 4 gt (4 5 5 6)8

22
Number Systems - Summary
  • Base r numbers
  • Binary
  • Octal
  • Hexadecimal
  • Conversion between number systems
  • Summation of power series
  • Division with remainders
  • Powers of 2
  • Computer systems based on powers of 2
  • kilo 1024
  • Mega 1024 1024
  • Giga 1024 1024 1024
  • Next
  • Computer arithmetic
  • Signs, complements

23
Computer Arithmetic
  • Computer arithmetic
  • Addition, subtraction
  • Multiplication
  • Signed numbers
  • Complements

24
Binary Addition
  • Binary addition works like normal addition
  • Stay within 0,1
  • Carries as usual
  • Example

Carry 111111
111101 10111
1010100
  • Addition of multiple numbers possible
  • Carry gets a bit more difficult

25
Binary Subtraction
  • Subtraction same as normal subtraction
  • Borrows as usual
  • Example

10 0
0 10
111101 - 10111
0
1
1
0
0
1
26
Binary Multiplication
  • Binary multiplication
  • Same as normal multiplication
  • Multiplication a lot easier in binary domain
  • Example

111101 1010
000000
111101
000000
111101
1001100010
27
Signed Numbers
  • How are signed numbers handled in base 10?
  • Plus or minus sign placed in front of number
  • Can we do that for binary numbers?
  • Sign needs to be represented in digital system
  • Only choice are 0 and 1
  • 0 indicates
  • 1 indicates
  • Examples on five-bit numbers
  • 01101 11101 00000 10000
  • 13 13 0 0
  • Signed Magnitude representation

28
Arithmetic with Signed Magnitude
  • Addition example 1
  • Plus signs are leading zeros -gt no problem
  • 01001 (9)10
  • 00010 (2)10
  • 01011 (11)10
  • Addition example 2
  • What happens with negative numbers?
  • 01001 (9)10
  • 10010 (2)10
  • 11011 ??? (7)10
  • Problem negative numbers
  • Sign can turn addition into subtraction

29
Signed Magnitude - Problems
  • Need to consider many cases to implement addition
    correctly
  • Decision process for (A) (B)
  • If A ? B then
  • If A lt B then

magnitude calculation
  A  
  -
B (AB), (A-B), -
  - (A-B), (AB), -
sign of result
  A  
  -
B (AB), (B-A),
  - (B-A), - (AB), -
30
Signed Magnitude Representation
  • Arithmetic with signed magnitude is difficult
  • Two representations of zero
  • Different cases for addition and subtraction

1000
31
Complements
  • Complements allow easier arithmetic
  • Representation of negative numbers a bit more
    involved
  • Two types of complements
  • Radix complement r s complement
  • Decimal 10s complement
  • Binary 2s complement
  • Diminished radix complement (r1)s complement
  • Decimal 9s complement
  • Binary 1s complement

32
Diminished Radix Complement
  • Given a number N in base r having n digits, the
    (r1)s complement of N is defined as
  • (r n 1) N
  • Example for 6-digit decimal numbers
  • 9s complement is (r n1)N (1061)N
    999999N
  • 9s complement of 546700 is 999999546700
    453299
  • Example for 7-digit binary numbers
  • 1s complement is (r n 1) N (271)N
    1111111N
  • 1s complement of 1011000 is 11111111011000
    0100111
  • Observation
  • Subtraction from (rn1) will never require a
    borrow
  • Diminished radix complement can be computed
    digit-by-digit
  • For binary 1 0 1 and 1 1 0
  • Flips 0s to 1s and 1s to 0 (bit
    complementation)

33
Ones Complement Representation
  • 1s complement is simple to compute
  • Bit complementation
  • Still, two representations of zero

1000
34
Radix Complement
  • The rs complement of an n-digit number N in base
    r is defined as
  • r n N for N ? 0 and 0 for N 0
  • Radix complement is diminished radix complement
    1 (r n 1) N 1 r n N
  • Example for 6-digit decimal numbers
  • 10s complement is r n N 106N 1000000N
  • 10s complement of 546700 is 1000000546700
    453300
  • Rule Leave least significant 0s unchanged,
    subtract first nonzero least significant digit
    from 10, subtract all higher significant digits
    from 9.
  • Example for 7-digit binary numbers
  • 2s complement is r nN 27N 10000000N
  • 2s complement of 1011000 is 100000001011000
    0101000
  • Rule Leave least significant 0s and first 1
    unchanged, replace 1s with 0s and 0s with 1s
    in all higher significant digits.

35
Twos Complement Representation
  • Arithmetic with 2s complement is most efficient
  • Bit complementation 1
  • Single representation of zero!

0
1000
36
Complements - Summary
  • Complement of complement is original number
  • Diminished radix complement
  • (r n1)((r n1)N) r n1r n1 N N
  • Radix complement
  • r n(r nN) r nr n N N
  • Representation of zero
  • Radix complement 0
  • Diminished radix complement r n 1 and its
    complement 0
  • Radix points
  • Remove radix point
  • Compute complement
  • Put radix point back at same relative position

37
Comparison ( n4 )
Decimal
Signed Magnitude
Ones Complement
Twos Complement
-8 -
-
1000 -7
1111
1000 1001 -6
1110
1001
1010 -5 1101
1010
1011 -4
1100 1011
1100 -3
1011
1100
1101 -2 1010
1101
1110 -1
1001 1110
1111 0
0000 or 1000 0000
or 1111 0000
1 0001
0001
0001 2 0010
0010
0010 3
0011
0011 0011 4
0100
0100
0100 5 0101
0101
0101 6
0110 0110
0110 7
0111
0111 0111
38
Subtraction with Complements
  • Subtraction M N
  • Add minuend M to rs complement of subtrahend N
  • M N M (rn N) M N r n
  • What about the additional r n ?
  • If M ? N
  • Then M N r n ? r n
  • With n bits only numbers lt r n can be expressed
  • n1st digit is ignored (drop the carry out bit)
  • If M lt N
  • Then M N r n r n (N M) r s
    complement of (N-M)
  • r s complement signifies negative number
  • So, (N M) M N

39
Arithmetic with Radix Complement
  • Subtraction works as addition of complement
  • Addition/subtraction of signed numbers
  • Negative numbers are expressed as r s complement
  • Simple addition yields correct result
  • No need to distinguish different cases
  • Addition/subtraction of unsigned numbers
  • Can be performed on same hardware as signed
    numbers
  • Most modern digital systems use 2s complement

40
Twos Complement Overflow
Consider two 8-bit 2s complement numbers. I can
represent the signed integers -128 to 127 using
this representation.What if I do (1) (127)
128. The number 128 is OUT of the RANGE
that I can represent with 8 bits. What happens
when I do the binary addition?
127 7F 1 01------------------
- 128 / 80 (this is actually -128 as a
twos complement
number!!! - the wrong answer!!!)How do I know
if overflowed occurred? Added two POSITIVE
numbers, and got a NEGATIVE result.
41
Detecting Twos Complement Overflow
Twos complement overflow occurs is Add two
POSITIVE numbers and get a NEGATIVE result
Add two NEGATIVE numbers and get a POSITIVE
resultI CANNOT get twos complement overflow if
I add a NEGATIVE and a POSITIVE number
together. The Carry out of the Most Significant
Bit means nothing if the numbers are twos
complement numbers.
42
Overflow Conditions
Add two positive numbers to get a negative
number or two negative numbers to get a positive
number
43
Example Overflow
0 1 1 1 0 1 0 1 0 0 1 1 1 0 0 0
1 0 0 0 1 0 0 1 1 1 0 0 1 0 1 1 1
5 3 -8
-7 -2 7
Overflow
Overflow
0 0 0 0 0 1 0 1 0 0 1 0 0 1 1 1
1 1 1 1 1 1 0 1 1 0 1 1 1 1 0 0 0
5 2 7
-3 -5 -8
No overflow
No overflow
Overflow when carry in to sign does not equal
carry out
44
Floating Point Numbers (I)
  • Fixed point numbers have limited range.
  • To represent very large or very small numbers, we
    use floating point numbers (cf. scientific
    numbers).
  • Examples
  • 0.23 x 1023 (very large positive number)
  • -0.1239 x 10-10 (very small negative number)

45
Floating Point Numbers (II)
  • Floating point numbers have three parts
  • mantissa, base, and exponent
  • Base is usually fixed for each number system.
  • Therefore, needs only mantissa and exponent.

46
Floating Point Numbers (III)
  • Mantissa is usually in normalised form
  • (base 10) 23 x 1021 normalised to 0.23 x
    1023
  • (base 10) -0.0017 x 1021 normalised to
    -0.17 x 1019
  • (base 2) 0.01101 x 23 normalised to
    0.1101 x 22
  • A 16-bit floating point number may have 10-bit
    mantissa and 6-bit exponent.
  • More bits in exponent gives larger range.
  • More bits for mantissa gives better precision.

47
Arithmetic with Floating Point Numbers (I)
  • Arithmetic is more difficult for floating point
    numbers.
  • MULTIPLICATION
  • Steps (i) multiply the mantissa
  • (ii) add-up the exponents
  • (iii) normalise
  • Example
  • (0.12 x 102)10 x (0.2 x 1030)10
  • (0.12 x 0.2)10 x 10230
  • (0.024)10 x 1032 (normalise)
  • (0.24 x 1031)10

48
Arithmetic with Floating Point Numbers (II)
  • ADDITION
  • Steps (i) equalise the exponents
  • (ii) add-up the mantissa
  • (iii) normalise
  • Example
  • (0.12 x 103)10 (0.2 x 102)10
  • (0.12 x 103)10 (0.02 x 103)10 (equalise
    exponents)
  • (0.12 0.02)10 x 103 (add
    mantissa)
  • (0.14 x 103)10
  • Can you figure out how to do perform SUBTRACTION
    and DIVISION for (binary/decimal) floating-point
    numbers? (Hint remember sometimes, the mantissa
    might need normalizing)

49
Weighted and Unweighted Codes
  • Most numeric number representations are in a
    class known as Weighted Codes where
  • Binary integers and fractions are special case
    where weights are powers of 2
  • Unweighted codes are codes that cannot be
    assigned a weight value for each bit

50
Binary Coded Decimal
  • Four bits are used to represent each decimal
    digit
  • In each 4-bit group, 6 values are not used
  • Many possible codes, natural BCD (equivalent
    binary digits) most common
  • BCD is not as efficient as binary
  • BCD is easy to convert to/from decimal (it really
    is decimal with different symbols)
  • BCD add/subtract circuits are complex

51
BCD Code Examples
Weighted codes
Unweighted code
Digit 0 1 2 3 4 5 6 7 8 9
8421 0000 0001 0010 0011 0100 0101 0110 0111 1000
1001
84-2-1 0000 0111 0110 0101 0100 1011 1010 1001 10
00 1111
XS3 0011 0100 0101 0110 0111 1000 1001 1010 1011
1100
The 8421 or natural BCD code is the most common
BCD code in use
52
Other Decimal Codes
Weighted codes
Unweighted code
Decimal digit BCD 8421 2421 Excess-3 8 4 -2 -1
0 0000 0000 0011 0000
1 0001 0001 0100 0111
2 0010 0010 0101 0110
3 0011 0011 0110 0101
4 0100 0100 0111 0100
5 0101 1011 1000 1011
6 0110 1100 1001 1010
7 0111 1101 1010 1001
8 1000 1110 1011 1000
9 1001 1111 1100 1111
The 8421 or natural BCD code is the most common
BCD code in use
53
BCD Addition
Case 1
Case 2
0001 1 0101 5 (0) 0110 (0) 6
0110 6 0101 5 (0) 1011 (1) 1
WRONG!
Case 3
1000 8 1001 9 (1) 0001 (1) 7
Note that for cases 2 and 3, adding a factor of 6
(0110) gives us the correct result.
54
BCD Addition (cont.)
  • BCD addition is therefore performed as follows
  • 1) Add the two BCD digits together using normal
    binary addition
  • 2) Check if correction is needed
  • a) 4-bit sum is in range of 1010 to 1111
  • b) carry out of MSB 1
  • 3) If correction is required, add 0110 to 4-bit
    sum to get the correct result BCD carry out 1

55
BCD Negative Number Representation
  • Similar to binary negative number representation
    except r 10.
  • BCD sign-magnitude
  • MSD (sign digit options)
  • MSD 0 (positive) not equal to 0 negative
  • MSD range of 0-4 positive 5-9 negative
  • BCD 10s complement
  • -N ? 10r - N 9s complement 1
  • BCD 9s complement
  • invert each BCD digit (0?9, 1 ? 8, 2 ? 7,3 ? 6,
    7 ? 2, 8 ? 1, 9 ? 0)

56
Negative BCD Numbers
  • 84-2-1 and XS3 codes allow for easy digit
    inversion.
  • XS3 code is also easy to implement
  • Addition is like binary
  • Correction factor is -3 or 3

57
Decimal Arithmetic
  • Everything needs to be 4-bit aligned
  • represented by 0 (0000)
  • represented by 9 (1001)
  • Signed magnitude representation or complements
  • Signed magnitude hardly used
  • 10s complement most common
  • Example 375 (240)
  • Negative numbers represented by 10s complement
  • 10s complement of 240 is 104 240 9760
  • Addition of all digits and discard of end carry
  • Sign of result automatically correct

0 375
9 760
0 135
58
Mechanical encoder with sequential sector
numbering
At boundaries can get a code different than
either adjacent sector
59
Gray Codes
  • Grey codes are minimum change codes
  • From one numeric representation to the next, only
    one bit changes
  • Primary use is in numeric input encoding apps.
    where we expect non-random input values changes
    (I.e. value n to either n-1 or n1)
  • Milling machine table position
  • Rotary shaft position

60
Rotary Encoder
  • an electro-mechanical device used to convert the
    angular position of a shaft or axle to a digital
    code, making it a sort of transducer. These
    devices are used in robotics, in top-of-the-line
    photographic lenses, in computer input devices
    (such as optomechanical mice and trackballs), and
    in rotating radar platforms.

61
Standard binary encoding
Sector Contact 1 Contact 2 Contact 3 Angle
1 off off off 0 to 45
2 off off on 45 to 90
3 off on off 90 to 135
4 off on on 135 to 180
5 on off off 180 to 225
6 on off on 225 to 270
7 on on off 270 to 315
8 on on on 315 to 360
the drawback that if the disc stops between two
adjacent sectors, or the contacts are not
perfectly aligned, it can be impossible to
determine the angle of the shaft.
62
Example problem
  • off- on- on (starting position)
  • on- on- on (first, contact 1 switches on)
  • on- on- off (next, contact 3 switches off)
  • on- off- off (finally, contact 2 switches off)
  • The sequence are 4,8,7,and then 5.
  • The shaft appears to have jumped from sector 4 to
    sector 8, then gone backwards to sector 7, then
    backwards again to sector 5, which is where we
    expected to find it.
  • In many situations, this behavior is undesirable
    and could cause the system to fail.
  • For example, if the encoder were used in a robot
    arm, the controller would think that the arm was
    in the wrong position, and try to correct the
    error by turning it through 180, perhaps causing
    damage to the arm.

63
Gray encoding
Sector Contact 1 Contact 2 Contact 3 Angle
1 off off off 0 to 45
2 off off on 45 to 90
3 off on on 90 to 135
4 off on off 135 to 180
5 on on off 180 to 225
6 on on on 225 to 270
7 on off on 270 to 315
8 on off off 315 to 360
In the previous example, the transition from
sector 4 to sector 5, like all other transitions,
involves only one of the contacts changing its
state from on to off or vice versa. This means
that the sequence of incorrect codes shown in the
previous illustration cannot happen here
64
Gray Code for decimal Digits
Gray Code0 00001 00012
00113 00104 01105
11106 10107 10118
10019 1000
A Gray code changes by only 1 bit for adjacent
values. This is also called a thumbwheel code
because a thumbwheel for choosing a decimal digit
can only change to an adjacent value (4 to 5 to
6, etc) with each click of the thumbwheel. This
allows the binary output of the thumbwheel to
only change one bit at a time this can help
reduce circuit complexity and also reduce signal
noise.
65
Gray Codes (cont.)
66
Binary Code to Gray Code Conversion
  • Convert n bit Binary code into n bit Gray Code
  • Bit i of the Gray Code is obtained by comparing
    bits i and i1 of the Binay Code - Add extra 0
    to the left of the Binary code- If bits i and
    i1 in the Binary code are the same then bit i of
    the Gray code is 0 , else bit i is 1.
  • Example Binary 10011
    010011Gray Code 11010
  • Exercise - Convert the Binary Code 11101 into
    Gray code - Convert the Gray
    Code 1101 !!
  • Answer - The gray Code is 10011
    - The Binary Code is 1001

67
Alphanumeric Representation
  • Binary codes used to represent alphabetic and
    numeric characters
  • Two most common are
  • ASCII, 7 bit code, 128 symbols
  • EBCDIC, 8 bit code, 256 symbols
  • Problems can arise when comparing symbol values
    (collation)
  • Comparing A to a in ASCII system yields
    different results in an EBCDIC system.

68
ASCII CODE
  • The ASCII code (American Standard Code for
    Information Interchange) is a 7-bit code for
    Character data. Typically 8 bits are actually
    used with the 8th bit being zero or used for
    error detection (parity checking).8 bits 1
    Byte. A 01000001 41
    00100110 267 bits can only represent 27
    different values (128). This enough to represent
    the Latin alphabet (A-Z, a-z, 0-9, punctuation
    marks, some symbols like ), but what about other
    symbols or other languages?

69
ASCII CODE
b6b5b4
b3b2b1b0 000 001 010 011 100 101 110 111
0000 NUL DLE SP 0 _at_ P p
0001 SOH DC1 ! 1 A Q a q
0010 STX DC2 2 B R b r
0011 ETX DC3 3 C S c s
0100 EQT DC4 4 D T d t
0101 ENQ NAK 5 E U e u
0110 ACK SYN 6 F V f v
0111 BEL ETB 7 G W g w
1000 BS CAN ( 8 H X h x
1001 HT EM ) 9 I Y I y
1010 LF SUB J Z j z
1011 VT ESC K k
1100 FF FS , lt L \ l
1101 CR GS - M m
1110 S0 RS . gt N n
1111 S1 US / ? O _ o DEL
70
UNICODE
  • UNICODE is a 16-bit code for representing
    alphanumeric data. With 16 bits, can represent
    216 or 65536 different symbols.16 bits 2 Bytes
    per character.
  • 0041-005A A-Z0061-4007A a-z
  • Some other alphabet/symbol ranges
  • 3400-3d2d Korean Hangul Symbols3040-318F
    Hiranga, Katakana, Bopomofo,
    Hangul4E00-9FFF Han (Chinese, Japenese,
    Korean)UNICODE used by Web browsers, Java, most
    software these days.

71
Error Detection and Error Correction Code
  • the transmission of data over a channel may
    result in error due to interference, noise, etc.
  • hence, data will be corrupted
  • some schemes have been devised to detect and
    correct the error
  • it is usually accomplished by inserting extra
    bits in the data being transmitted

72
Single error detection with parity
  • simplest method for error detection
  • insert an additional parity bit for transmission
  • even parity may be generated by
  • for a 4-bit data
  • e.g. for a 4-bit data 0110
  • odd parity may be obtained by
  • e.g.

73
Parity Bit
  • ASCII code may have an extra bit appended to
    detect data transmission errors
  • P 0 if the number of 1s in the character is
    even, else P 1 (even parity)
  • P 0 if the number of 1s in the character is
    odd, else P 1 (odd parity)
  • If any single bit changes, parity will be wrong
    at receive end

Even parity Odd parity ASCII A
1000001 01000001 11000001 ASCII T
1010100 11010100 01010100
74
Parity Code Example
  • Concatenate a parity bit to the ASCII code for
    the characters 0, X, and to produce both
    odd-parity and even-parity codes.

Character ASCII Odd-Parity ASCII Even-Parity ASCII
0 0110000 10110000 00110000
X 1011000 01011000 11011000
0111100 10111100 00111100
75
Binary Storage and Registers
  • How is information stored on a digital system?
  • Bits are stored in binary cells
  • Binary cell can have two stable states 0 and
    1
  • Binary cells are grouped into registers
  • n cells make up n-bit register
  • Size of registers is typically predefined
  • Simple microcontroller 8 bits 1 byte
  • Pentium 32 bits 4 bytes
  • Mac G5 64 bits 8 bytes
  • Digital system can usually process entire
    registers
  • Register transfer operation specify processing

76
Binary Data Storage
  • Binary cells store individual bits of data
  • Multiple cells form a register.
  • Data in registers can indicate different values
  • Hex (decimal)
  • BCD
  • ASCII

0
0
1
0
1
0
1
1
Binary Cell
77
Register Transfer
  • Data can move from register to register.
  • Digital logic used to process data
  • We will learn to design this logic

78
Register Example
  • Data input at keyboard
  • Shifted into place
  • Stored in memory

79
Register Transfer Operations
  • We need processing
  • We need storage
  • We need communication
  • You will learn to use and
  • design these components.

Designing digital logic is focus of rest of course
80
Binary Logic
  • Binary logic uses two possible values
  • 1 and 0
  • yes and no
  • true and false
  • Can be represented by variables A, B, C, x, y,
    z,
  • Logic functions modify input values
  • What is the minimum number of inputs?
  • 1 input -gt pretty uninteresting, inverter or wire
    only
  • 2 inputs -gt basic logic functions
  • What are possible logic functions?
  • NOT, AND, OR
  • Others can be derived from those (NAND, XOR, etc.)

81
NOT Function
  • Complement operation
  • Single input
  • Inverts value of input
  • Symbolized by prime x or overbar
  • Truth table
  • Input combinations on the left
  • Output of function on the right
  • Graphic symbol
  • NOT gate
  • Little circle indicates inversion

input
output
x x'
0 1
1 0
82
AND Function
  • Operation to check if two conditions are met
  • Two inputs
  • Output 1 if and only if both inputs are 1
  • Symbolized by dot or absence of operator
  • xy or xy
  • Truth table
  • Needs to consider 22 4 input combinations
  • Graphic symbol
  • AND gate

83
OR Function
  • Operation to check if at least one condition is
    met
  • Two inputs
  • Output 1 if any one or both inputs are 1
  • Symbolized by plus sign x y
  • Truth table
  • Graphic symbol
  • OR gate

x y z
0 0 0
0 1 1
1 0 1
1 1 1
84
Comparison of Functions
  • Timing diagrams (waveforms)
  • Horizontal axis is time ( t )
  • Vertical axis shows signals, each with two
    different voltage levels

t
85
Multiple Inputs
  • Two inputs might not be enough
  • 3-input AND gate
  • 4-input OR gate
  • What are the rules for aggregating functions?
  • Boolean algebra
Write a Comment
User Comments (0)
About PowerShow.com