1 Basic Digital Logic. Prof Jess Role @UEAB 2008 ◊Digital Electronics ◊Number Systems and Logic...
-
Upload
brianna-richard -
Category
Documents
-
view
221 -
download
4
Transcript of 1 Basic Digital Logic. Prof Jess Role @UEAB 2008 ◊Digital Electronics ◊Number Systems and Logic...
1
Basic Digital Logic
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
◊ Digital Electronics ◊ Number Systems and Logic◊ Electronic Gates◊ Combinational Logic◊ Sequential Circuits◊ ADC – DAC circuits◊ Memory and Microprocessors◊ Hardware Description Languages
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Weekly Structure
◊ Lectures Monday, Tuesday, Wednesday
◊ Slides in ppt and pdf format on support website:◊ http://www.roletech.net/comp360.htm
(follow link from course website)
◊ Tutorials anytime - Sample Questions on website.
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
The lecture today
◊ Digital vs Analog data◊ Binary inputs and outputs◊ Binary, octal, decimal and
hexadecimal number systems◊ Other uses of binary coding.
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Analog/Analogue Systems
◊ Analogue Systems◊ V(t) can have any value between its
minimum and maximum value
V(t)
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Digital Systems◊ Digital Systems
◊ V(t) must take a value selected from a set of values called an alphabet
◊ Binary digital systems form the basis of almost all hardware systems currently
V(t)
For example, Binary Alphabet: 0, 1.
1 0 1 0 1
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Slide example
◊ Consider a child’s slide in a playground:
continuous movement
a set of discrete steps
levels
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Relationship between Analogue and Digital systems◊ Advantages of Digital Systems
◊ Analogue systems: slight error in input yields large error in output
◊ Digital systems more accurate and reliable
◊ Computers use digital circuits internally
◊ Interface circuits (for instance, sensors and actuators) are often analogue
5 Volt
0 Volt
0.80.4
2.42.8
InputRangefor 1
InputRangefor 0
OutputRangefor 0
OutputRangefor 1
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Exercise
◊ Explain whether the following are analog or digital:
◊ A photograph or painting◊ A scanned image◊ Sound from a computer’s loud speaker◊ Sound file stored on disc
Prof Jess Role @UEAB 2008
Binary Inputs and Outputs
◊ Coding:◊ A single binary input can
only have two values: True or False (Yes or No) (1 or 0)
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary◊ More bits = more combinations
0 0 0 1 1 0 1 1
Each additional input doubles the number of combinations we can representi.e. with n inputs it is possible to represent 2n combinations
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Combinations
◊ Example 1:◊ How many combinations are possible
with 10 binary inputs?
◊ Example 2:◊ What is the minimum number of bits
needed to represent the digits ‘0’ to ‘9’ as a binary code?”
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Decimal systems
◊ Number Representation◊ Difficult to represent Decimal numbers
directly in a digital system◊ Easier to convert them to binary◊ There is a weighting system:
eg 403 = 4 x 100 + 0 x 10 + 3 x 1
or in, powers of 10:
40310= 4x102 + 0x101 + 3x100 = 400 + 0 + 3
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary Inputs and Outputs
◊ Both Decimal and Binary numbers use a positional weighting system, eg:
10102 = 1x23+0x22+1x21+0x20 = 1x8 + 0x4 + 1x2 + 0x1 = 1010
decimal 100 (102) 10 (101) 1 (100)
4 0 3 400 + 0 + 3
binary 8 (23) 4 (22) 2 (21) 1 (20)
1 0 0 1 8 + 0 + 0 + 1
Prof Jess Role @UEAB 2008
Binary to decimal◊ Multiply each 1 bit by the appropriate power of 2
and add them together.
? ? 128 64 32 16 8 4 2 1
1 0 0 0 0 0 1 1
1 0 1 0 0 1 1 0 0
100000112 = ……………….10 ?
1010011002 = ……………………10 ?
Prof Jess Role @UEAB 2008
Binary Inputs and Outputs◊ Number Representation - Binary to decimal◊ A decimal number can be converted to binary by repeated division by 2
number /2 remainder
155 77 1 Least Significant Bit
77 38 1
38 19 0
19 9 1
9 4 1
4 2 0
2 1 0
1 0 1 Most Significant bit
15510 = 100110112
Prof Jess Role @UEAB 2008
Decimal to Binary
An alternative way is to use the “placement” method
128 goes into 155 once leaving 27 to be placed
So 64 and 32 are too big (make them zero)16 goes in once leaving 11
and so on…
128 64 32 16 8 4 2 1
1
1 0 0 1
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Representations
◊ There are different ways of representing decimal numbers in a binary coding
◊ BCD or Binary Coded Decimal is one example.
◊ Each decimal digit is replaced by 4 binary digits
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary Inputs and Outputs
◊ 6 of the possible 16 values unused
◊ example 45310 = 0100 0101 0011BCD
◊ Note that BCD code is longer than a direct representation in natural binary code:
◊ 453 = 111000101
Decimal BCD0 00001 00012 00103 00114 01005 01016 01107 01118 10009 1001
Prof Jess Role @UEAB 2008
Binary Inputs and Outputs
◊ Hexadecimal and Octal◊ Writing binary numbers as strings of 1s and 0s can
be very tedious◊ Octal (base 8) and Hexadecimal (base 16) notations
can be used to reduce a long string of binary digits.
octal 512 (83) 64 (82) 8 (81) 1 (80)
1 2 0 7 512 + 128 + 7
hexadecimal 256 (162) 16 (161) 1 (160)
1 A F 256 + 160 + 15Notice that hexadecimal requires 15 symbols (each number system needs 0 – base-1 symbols) and therefore A – F are used after 9.
Prof Jess Role @UEAB 2008
Octal as shorthand for Binary
◊ Each octal digit corresponds to 3 binary bits
binary octal
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7
To convert a binary string: 10011101010011
Split into groups of 3:
010 011 101 010 011
2 3 5 2 3
Thus 100111010100112 = 235238
Prof Jess Role @UEAB 2008
Similarly with Hexadecimal
◊ Each hex digit corresponds to 4 binary bits
binary hex
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
To convert a binary string: 10011101010011
Split into groups of 4:
0010 0111 0101 0011
Thus 100111010100112 = ……………
16 ?
binary hex
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary inputs and outputs
◊ Colour codes◊ You often see hex used in graphic
design programs for the red, blue and green components of a colour:
◊ FF0000 represents red, for example.◊ How many bits are used to represent
each colour?◊ How many different colours can be
represented?
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary Inputs and Outputs◊ Characters
◊ Three main coding schemes used: ASCII (widespread use), EBCDIC (not used often) and UNICODE (new)
◊ ASCII table (in hex) : 00nul
01soh
02sot
03 etx
04 eot
05enq
06 ack
07 bel
08 bs
09 ht
0a nl
0b vt
0c np
0d cr
0e so
0f si
10 dle
11 dc1
12 dc2
13 dc3
14 dc4
15 nak
16 syn
17 etb
18 can
19 em
1a sub
1b esc
1c fs
1d gs
1e rs
1f us
20 sp
21 !
22 "
23 #
24 $
25 %
26 &
27 '
28 (
29 )
2a *
2b +
2c ,
2d -
2e .
2f /
30 0
31 1
32 2
33 3
34 4
35 5
36 6
37 7
38 8
39 9
3a :
3b ;
3c <
3d =
3e >
3f ?
40 @
41 A
42 B
43 C
44 D
45 E
46 F
47 G
48 H
49 I
4a J
4b K
4c L
4d M
4e N
4f O
50 P
51 Q
52 R
53 S
54 T
55 U
56 V
57 W
58 X
59 Y
5a Z
5b [
5c \
5d ]
5e ̂
5f _
60 ̀
61 a
62 b
63 c
64 d
65 e
66 f
67 g
68 h
69 i
6a j
6b k
6c l
6d m
6e n
6f o
70 p
71 q
72 r
73 s
74 t
75 u
76 v
77 w
78 x
79 y
7a z
7b {
7c 7d }
7e ~
7f del
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Gray Codes ◊ Other codes exist for specific
purposes◊ Gray codes provide a sequence
where only one bit changes for each increment
◊ Allows increments without ambiguity due to bits changing at different times.◊ E.g. changing from 3 to 4, normal
binary has all three bits changing 011 -> 100. Depending on the order in which the bits change any intermediate value may be created.
Dec Gray
0 000
1 001
2 011
3 010
4 110
5 111
6 101
7 100
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Summary
◊ Support website◊ Analogue and Digital◊ Binary Number Systems◊ Coding schemes considered were:
◊ Natural Binary ◊ BCD◊ Octal representation◊ Hexadecimal representation◊ ASCII
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Exercises
◊ You should practice conversions between binary, octal, decimal and hexadecimal.
◊ You should be able to code decimal to BCD (and BCD to decimal).
◊ You should be able to explain and give examples of digital and analogue data.
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary, Hex, & BCD:Binary Number System◊ Most digital systems deal with groups of
bits in even powers of 2, such as 8, 16, 32, and 64 bits
◊ 8-bit Binary number - weighted values of each bit
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary, Hex, & BCD:Binary Number System
◊ Example: Convert 1011 1010 to its decimal equivalent
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
1 0 1 1 1 0 1 0
128 + 0 + 32 + 16 + 8 + 0 + 2 + 0 = 18610
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary, Hex, & BCD:Binary Number System
◊ Fractional Binary Numbers◊ Example: Convert 1011.1010 to its
decimal equivalent
23 22 21 20 2-1 2-2 2-3 2-4
8 4 2 1 1/21/4
1/81/16
1 0 1 1 1 0 1 0
8 + 0 + 2 + 1 + 0.5 + 0 + 0.125 + 0
= 11.62510
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Review – Decimal to Binary
Example 3810 = _______21001102 38
2 9Quotient
Quotient
0
1
1
Remainder
Remainder
RemainderLSB
2 19
2 4
Quotient
0
2 2
Quotient
0
2 1 1 MSB
Remainder
Remainder
Remainder
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Review – Decimal to Binary
Example 3810 = _______2100110
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
0 0 1 0 0 1 1 0
0 + 0 + 32 + 0 + 0 + 4 + 2 + 0
= 3810
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary, Hex, & BCD:Hexadecimal Number System
◊ Most digital systems deal with groups of bits in even powers of 2, such as 8, 16, 32, and 64 bits
◊ Hexadecimal uses groups of 4 bits◊ Base 16
◊ 16 possible symbols◊ 0 thru 9 and A thru F
◊ Easier handling of long binary strings
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary, Hex, & BCD:Converting Hex to Decimal◊ Multiply each digit by its positional
weight
Example: 24316 = 2 x (162) + 4 x (161) + 3 x
(160)= 512 + 64 + 3= 57910
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary, Hex, & BCD:Converting Decimal to Hex
◊ Use repeated division method◊ Divide decimal number by 16◊ First remainder is LSB; last is MSB
◊ Note: when done on calculator, the fractional portion can be multiplied by 16 to get the remainder
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Example 57910 = _____16243
16 579
16 36
16 2
0
Quotient
Quotient
Quotient
3
4
2
Remainder
Remainder
RemainderLSD
MSD
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary, Hex, & BCD:Converting Hex to Binary
◊ Example:9F216 = 9 F 2
= 1001 1111 0010 = 1001111100102
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary, Hex, & BCD:Converting Binary to Hex
◊ Group bits in fours starting with LSB◊ Convert each group to hex digit◊ Add leading zeros to left of MSB of
last group, as needed
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Binary, Hex, & BCD:Converting Binary to Hex
◊ Example:11101001102 =0011 1010 0110
= 3 A 6 = 3A616
◊ Counting in hex reset & carry after F
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Number Systems Conversion Table
Decimal Binary Octal Hexadecimal BCD
0 0 0 0 0
1 1 1 1 0001
2 10 2 2 0010
3 11 3 3 0011
4 100 4 4 0100
5 101 5 5 0101
6 110 6 6 0110
7 111 7 7 0111
8 1000 10 8 1000
9 1001 11 9 1001
10 1010 12 A 0001 0000
11 1011 13 B 0001 0001
12 1100 14 C 0001 0010
13 1101 15 D 0001 0011
14 1110 16 E 0001 0100
15 1111 17 F 0001 0101
Prof Jess Role @UEAB 2008
TTL Logic Chips-Basic Circuitry
◊ Power & Ground (on basic gates - 14 pin DIP)◊ Pin 14 – Vcc (+5V)◊ Pin 7 – GND
◊ Absolute limits7400 NAND Gate Data Sheet
74LS00
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
TTL 74 Series Logic Chips◊ Logic Level voltage ranges
◊ VIN High = 2.0Vmin◊ VIN Low = 0.8Vmax◊ VOUT High = 2.4Vmin◊ VOUT Low = 0.4V max
◊ Indeterminate voltagesAny voltage between 0.8V and 2.0V on an
input can not be guaranteed to be either high or low
◊ Current capabilities◊ IIN High = 40uA◊ IIN Low = -1.6mA◊ IOUT High = -0.4mA◊ IOUT Low = 16mA
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
TTL 74 Series Logic Chips
◊ Fan outFan out (HIGH) = IOH(max) / IIH(max)
For 7400: 400uA/40uA = 10Fan out (LOW) = IOL(max) / IIL(max)
For 7400: 16mA/1.6mA = 10Propagations delays
◊ How long does it take the output to change after a change has happened at the inputs
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
Data Sheets
◊ Floating inputs◊ What happens if you don’t connect an
input to a high or low
◊ CMOS family◊ MOSFET switches instead of bipolar
junction transistor switches◊ Faster than most standard TTL chips◊ More susceptible to static electricity
Prof Jess Role @UEAB 2008
A
BY
Review of Logic Functions
1AND2
A B Y
0 0 1
0 1 1
1 0 1
1 1 0
NAND GateTruth Table
NAND: AB A × B A & B
Prof Jess Role @UEAB 2008
Review of Logic Functions
1AND2
A B Y
0 0 1
0 1 0
1 0 0
1 1 1
XNOR GateTruth Table
XNOR: A + B A $ B
A
BY
Prof Jess Role @UEAB 2008
Review of Logic Functions
1AND2
A B Y
0 0 0
0 1 1
1 0 1
1 1 1
OR GateTruth Table
OR: A + BA # B
A
BY
Prof Jess Role @UEAB 2008
Review of Logic Functions
1AND2
A B Y
0 0 0
0 1 0
1 0 0
1 1 1
AND GateTruth Table
A
BY
AND: AB A × B A & B
Prof Jess Role @UEAB 2008
Review of Logic Functions
1AND2
A B Y
0 0 1
0 1 0
1 0 0
1 1 0
NOR GateTruth Table
OR: A + BA # B
A
BY
Prof Jess Role @UEAB 2008
Review of Logic Functions
1AND2
A B Y
0 0 0
0 1 1
1 0 1
1 1 0
XOR GateTruth Table
XOR: A + B A $ B
A
BY
Prof Jess Role @UEAB 2008
Review of Logic Functions
A Y
0 1
1 0
NOT
A
!
NOT Gate
Truth Table
A Y
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
52
Review
◊ There are 3 basic digital gates:
◊ AND
◊ OR
◊ NOT
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
53
Review
AND, where ALL inputs must be “1” for the output to be “1”
OR, where ANY of the inputs can be “1” for the output to be “1”
NOT (or the Inverter) where the output is the opposite (compliment) of the input.
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
54
Review Questions
What is the outcome of the following:
1
1
0
1
0
1
1
55
Basic Digital Logic 2
Basic Combinational Logic, NAND and NOR gates
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
56
Combinational Logic
◊ A circuit that utilizes more that 1 logic function has Combinational Logic.
◊ As an example, if a circuit has an AND gate connected to an Inverter gate, this circuit has combinational logic.
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
57
Combinational logic
◊ How would your describe the output of this combinational logic circuit?
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
58
NAND Gate
◊ The NAND gate is the combination of an NOT gate with an AND gate.
The Bubble in front of the gate is an inverter.
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
59
Combinational logic
◊ How would your describe the output of this combinational logic circuit?
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
60
NOR gate
◊ The NOR gate is the combination of the NOT gate with the OR gate.
The Bubble in front of the gate is an inverter.
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
61
NAND and NOR gates
◊ The NAND and NOR gates are very popular as they can be connected in more ways that the simple AND and OR gates.
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
62
Exercise 1 – a bit challenging
Complete the Truth Table for the NAND and NOR Gates
Input Output
0 0
0 1
1 0
1 1
Input Output
0 0
0 1
1 0
1 1
NAND NOR
Hint: Think of the AND and OR truth tables. The outputs for the NAND and NOR are inverted.
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
63
Exercise 2 – more challenging
◊ Turn the NAND and NOR gates into inverter (NOT) gates. Include a switch for the input.
64
Basic Digital Logic 2
Chips and Gates
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
65
Basic Digital Chips
◊ Digital Electronics devices are usually in a chip format.
◊ The chip is identified with a part number or a model number.
◊ A standard series starts with numbers 74, 4, or 14.◊ 7404 is an inverter◊ 7408 is an AND◊ 7432 is an OR◊ 4011B is a NAND
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
66
Chips
◊ Basic logic chips often come in 14-pin packages.
◊ Package sizes and styles vary.
◊ Pin 1 is indicated with a dot or half-circle
◊ Numbers are read counter-clockwise from pin 1 (viewed from the top)
Pin 1 Pin 7
Pin 14 Pin 8
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
67
Chips
◊ Chips require a voltage to function
◊ Vcc is equal to 5 volts and is typically pin 14
◊ Ground is typically pin 7
Pin 1 Pin 7
Pin 14 Pin 8
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
68
Chips – Specification Sheet
Diagram from http://www.onsemi.com
Voltage
Ground
The voltage and ground pins must be connected for the device to function. Check the specification sheet to make sure.
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
69
Chips – Specification Sheet
Diagrams from http://www.onsemi.com
A
B
C
D
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
70
Wiring a chip
Vcc
Vcc
IN
IN
OUT
Probe
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
71
Lab Exercise
◊ Using the experimenter’s boards, connect the circuit provided to you in the following pages.
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
72
Layout of the SK-10 Experimenter's Board
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
73
Layout of the SK-10 Experimenter's Board
Flat Side
Wires
7400
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
74
Logic Diagram of Lab
Prof Jess Role @UEAB 2008Prof Jess Role @UEAB 2008
75
Useful Resources◊ Textbooks on Digital Electronics (used is ok!)◊ Electronics Workbench or other electronic simulation
software◊ Craig Maynard’s Virtual Vulcan◊ The following web sites:
◊ http://learnat.sait.ab.ca/ict/digi240_godin/default.htm◊ http://learnat.sait.ab.ca/ict/cmph200/Default.htm◊ http://learnat.sait.ab.ca/ict/cmph200_godin/default.htm
◊ http://focus.ti.com/docs/logic/logichomepage.jhtml◊ http://www.onsemi.com◊ http://www.national.com/
◊ http://www.play-hookey.com/digital/◊ http://www.crhc.uiuc.edu/~drburke/databookshelf.html◊ http://www.digikey.ca/