Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
EE345 - Micro-Controllers
Digital Systems and Binary Numbers
Prof. Ahmad Abu-El-Haija
Acknowledgement
This presentation is a modified version of lecture notes
prepared by Dr. Pradondet Nilagupta, Kasetsart University.
The latter is also a modified version based upon
presentations by Prof. Maciej Ciesielski and Prof. Tilman
Wolf, University of Massachusetts Amherst, and original
slides from the publisher.
Digital System Design
May 3, 2017
2
Digital Hardware Systems
Digital Systems
Digital vs. Analog Waveforms
+5
+5
1
0
1
V
Time
–5
Time
–5
Digital:
only assumes discrete values
EE345 – Micro-Controllers
V
May 3, 2017
Analog:
values vary over a broad range
continuously
3
Digital Circuits
Digital circuit can be represented by a black-box with
inputs on one side, and outputs on the other.
inputs
:
Digital
circuit
:
outputs
The input/output signals are discrete/digital in nature,
typically with two distinct voltages (a high voltage and a
low voltage).
High
Low
In contrast, analog circuits use continuous signals.
EE345 – Micro-Controllers
May 3, 2017
4
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
it’s easy to implement
IF the garage door is open
AND the car is running
THEN the car can be backed out of the garage
both the door must
be open and the car
running before I can
back out
the preconditions must be true to imply the conclusion
EE345 – Micro-Controllers
May 3, 2017
5
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)
EE345 – Micro-Controllers
May 3, 2017
6
Binary Representation of Information
Information divided into groups of symbols
26 English letters
28 Arabic letters
10 decimal digits
22 Arab countries
Digital systems manipulate information as 1’s &
0’s
The mapping of symbols to binary value is known
as a “code”
The mapping must be unique
EE345 – Micro-Controllers
May 3, 2017
7
Digital Systems
Digital systems operate on discrete elements of
information
For a digital systems to operate on a continuous data, it
needs to quantize (digitize) that data first
Numbers (e.g., pocket calculator) -> “digits” -> “digital”
Letters (e.g., word processor)
Pictures (e.g., digital cameras)
Covert data into digital representation
Topics:
How are numbers represented in digital systems
How computer performs basic arithmetic operations
EE345 – Micro-Controllers
May 3, 2017
8
Numbers
Common numbering system is “base10”
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: an×10n+an-1×10n-1+…+a1×101+a0×100
Positional notation
Why?
i
a
10
General equation: i
i
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
EE345 – Micro-Controllers
May 3, 2017
9
Number Systems
General form, with base r :
a r
i
i
i
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
EE345 – Micro-Controllers
May 3, 2017
10
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.
EE345 – Micro-Controllers
May 3, 2017
11
Positional Integer Number Values
Given a digit series of
A
n1
... A3 A2 A1 A0 .( Radix point)
The full expression for the represented value is
An1 r
n 1
... A3 r A2 r A1 r
3
2
1
A0 r
0
or
i n 1
Ai r
i
i 0
EE345 – Micro-Controllers
May 3, 2017
12
Positional Fractional Number Values
Given a digit series of
(Radix point)
A A A A
1
2
3
4
... A m
The full expression for the represented value is
A r
1
1
2
A 2 r A3 r
3
A r
4
4
... A m r
m
or
i m
A r
i 1
EE345 – Micro-Controllers
i
i
May 3, 2017
13
Binary Numbers
Base 2 number use only two digits: 0, 1
Digits need to be represented in a system
Why?
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
EE345 – Micro-Controllers
May 3, 2017
14
Examples for Binary Numbers
What value is represented by (01001)2?
Same process for numbers with decimal point
Leading zero makes no difference
(1001)2 translates into 1×23+0×22+0×21+1×20=8+0+0+1=(9)10
What is the value of (1001.1001)2?
(1001.1001)2 =
1×23+0×22+0×21+1×20+1×2-1+0×2-2+0×2-3+1×2-4=
8+0+0+1+1/2+0+0+1/16=(9.5625)10
Important: it’s NOT (9.9)10!
Can you count binary?
How far can you count with 10 fingers?
EE345 – Micro-Controllers
May 3, 2017
15
Binary Number Terminology
Base is also called “radix”
Binary numbers are made of binary digits (bits)
Groups of four bits are called “nibbles”
Groups of eight bits are called “bytes”
E.g., (01001101)2
What is the range of values of an n-bit binary number?
E.g., (1101)2
Minimum value: 0
Maximum value: 2n-1
Number of different values: 2n
Powers of 2 are important
EE345 – Micro-Controllers
May 3, 2017
16
Powers of 2
You must memorize all powers of 2 up to 216!
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
Other important powers of 2:
16
24
32
64
256
65536
16777216
4294967296
18446744073709551616
Trick to simplify estimation:
8
210=1024≈1000=103
Example: 232=4×230≈4×109=4 billion
Prefixes:
kilo (103 ≈ 210), Mega (106 ≈ 220), Giga (109 ≈ 230), Tera (1012 ≈ 240), …
Computer systems are typically based on powers of 2
EE345 – Micro-Controllers
May 3, 2017
17
Other Number Systems
Octal number system
Hexadecimal number system
Digits 0, 1, … 7
Aggregates 3 digits of binary system (i.e., 3-bit number)
E.g., (57)8 = (47)10
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:
octal (base 8)
decimal (base 10)
binary (base 2)
hexadecimal
(base16)
EE345 – Micro-Controllers
May 3, 2017
18
Number Base Conversions
Conversion from base r to decimal
Expansion to power series
i
a
r
i and addition of terms
i
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 (r=2)
a0 = 1
41 = 20 2 + 1
a1 = 0
20 = 10 2 + 0
a2 = 0
10 = 5 2 + 0
(101001)2
a3 = 1
5 = 22+1
a4 = 0
2 = 12+0
a5 = 1
1 = 02+1
EE345 – Micro-Controllers
May 3, 2017
19
Number Base Conversions
Conversion to/from octal and hexadecimal
Easier if done via binary
3 or 4 bit sequences correspond to digit
Example:
(4 5 5 6)8
(2414)10=(100101101110)2
(9
EE345 – Micro-Controllers
May 3, 2017
6
E)16
20
Number Systems - Summary
Base r numbers
Conversion between number systems
Summation of power series
Division with remainders
Powers of 2
Binary
Octal
Hexadecimal
Computer systems based on powers of 2
kilo = 1024
Mega = 1024 × 1024
Giga = 1024 × 1024 × 1024
Next:
Computer arithmetic
Signs, complements
EE345 – Micro-Controllers
May 3, 2017
21
Computer Arithmetic
Computer arithmetic
Addition, subtraction
Multiplication
Signed numbers
Complements
EE345 – Micro-Controllers
May 3, 2017
22
Binary Addition
Binary addition works like “normal” addition
Stay within {0,1}
Carries as usual
Example:
Carry:
111111
augend:
111101
addend: + 10111
1010100
Addition of multiple numbers possible
Carry gets a bit more difficult
EE345 – Micro-Controllers
May 3, 2017
23
Binary Subtraction
Subtraction same as “normal” subtraction
Borrows as usual
Example:
10
0 0–10
minuend:
–– –
111101
subtrahend: - 10111
1 0 011 0
EE345 – Micro-Controllers
May 3, 2017
24
Binary Multiplication
Binary multiplication
Same as “normal” multiplication
Multiplication a lot easier in binary domain
Example:
EE345 – Micro-Controllers
111101
× 1010
000000
111101
000000
111101
1001100010
multiplicand
multiplier
May 3, 2017
25
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’
Examples on five-bit numbers:
‘0’ indicates ‘+’
‘1’ indicates ‘–’
01101
+ 13
11101
– 13
00000
+ 0
10000
– 0
Signed Magnitude representation
EE345 – Micro-Controllers
May 3, 2017
26
Arithmetic with Signed Magnitude
Addition example 1:
Plus signs are leading zeros -> no problem
Augend:
01001
(9)10
Addend: + 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
EE345 – Micro-Controllers
May 3, 2017
27
Signed Magnitude Representation
Arithmetic with signed magnitude is difficult
Two representations of zero
Different cases for addition and subtraction
0000
1111
1110
1101
-6
0001
-7 +0 +1
-5
0010
+2
+3
+4
-4
1100
1011
-2
+6
-1 -0 +7
1001
EE345 – Micro-Controllers
0100
+5
-3
1010
0011
1000
0101
0110
0111
May 3, 2017
28
Complements
“Complements” allow easier arithmetic
Representation of negative numbers a bit more involved
Two types of complements
Radix complement: r’ s complement
Decimal: 10’s complement
Binary: 2’s complement
Diminished radix complement: (r–1)’s complement
Decimal: 9’s complement
Binary: 1’s complement
EE345 – Micro-Controllers
May 3, 2017
29
Diminished Radix Complement
Given a number N in base r having n digits, the (r–1)’s complement of
N is defined as:
(r n –1) – N
Example for 6-digit decimal numbers:
Example for 7-digit binary numbers:
9’s complement is (r n–1)–N = (106–1)–N = 999999–N
9’s complement of 546700 is 999999–546700 = 453299
1’s complement is (r n –1) – N = (27–1)–N = 1111111–N
1’s complement of 1011000 is 1111111–1011000 = 0100111
Observation:
Subtraction from (rn–1) will never require a borrow
Diminished radix complement can be computed digit-by-digit
For binary: 1 – 0 = 1 and 1 – 1 = 0
Flips 0’s to 1’s and 1’s to 0’ (bit complementation)
EE345 – Micro-Controllers
May 3, 2017
30
One’s Complement Representation
1’s complement is simple to compute
Bit complementation
Still, two representations of zero
0000
1111
1110
1101
0001
0010
-0 +0 +1
-1
+2
-2
+3
+4
-3
1100
1011
-5
+6
-6 -7 +7
1001
EE345 – Micro-Controllers
0100
+5
-4
1010
0011
1000
0101
0110
0111
May 3, 2017
31
Radix Complement
The r’s 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:
10’s complement is r n – N = 106–N = 1000000–N
10’s complement of 546700 is 1000000–546700= 453300
Rule: Leave least significant 0’s unchanged, subtract first nonzero least
significant digit from 10, subtract all higher significant digits from 9.
Example for 7-digit binary numbers:
2’s complement is r n–N = 27–N = 10000000–N
2’s complement of 1011000 is 10000000–1011000 = 0101000
Rule: “Leave least significant 0’s and first 1 unchanged, replace 1’s with
0’s and 0’s with 1’s in all higher significant digits.”
EE345 – Micro-Controllers
May 3, 2017
32
Two’s Complement Representation
Arithmetic with 2’s complement is most efficient
Bit complementation + 1
Single representation of zero!
0000
1111
1110
1101
-1
0
0001
0010
+1
-2
+2
-3
+3
+4
-4
1100
1011
-6
+6
-7 -8 +7
1001
EE345 – Micro-Controllers
0100
+5
-5
1010
0011
1000
0101
0110
0111
May 3, 2017
33
Complements - Summary
Complement of complement is original number
Diminished radix complement:
(r n–1)–((r n–1)–N) = r n–1–r n+1 + N = N
Radix complement:
r n–(r n–N) = r n–r n+ N = N
Representation of zero
Radix complement: 0
Diminished radix complement: r n –1 and it’s complement 0
Radix points
Remove radix point
Compute complement
Put radix point back at same relative position
EE345 – Micro-Controllers
May 3, 2017
34
Signed Binary Numbers Comparison ( n=4 )
Decimal
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
EE345 – Micro-Controllers
Signed Magnitude
--1111
1110
1101
1100
1011
1010
1001
0000 or 1000
0001
0010
0011
0100
0101
0110
0111
signed One’s
Complement
---1000
1001
1010
1011
1100
1101
1110
0000 or 1111
0001
0010
0011
0100
0101
0110
0111
May 3, 2017
Signed Two’s
Complement
1000
1001
1010
1011
1100
1101
1110
1111
0000
0001
0010
0011
0100
0101
0110
0111
35
Subtraction with Complements
Subtraction M – N
What about the additional r n ?
If M N
Add minuend M to r’s complement of subtrahend N
M – N = M + (rn – N) = M – N + r n
Then M – N + r n r n
With n bits, only numbers < r n can be expressed
n+1st digit is ignored (drop the “carry out” bit)
If M < 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
EE345 – Micro-Controllers
May 3, 2017
36
Arithmetic with Radix Complement
Subtraction works as addition of complement
Addition/subtraction of signed numbers
Addition/subtraction of unsigned numbers
Negative numbers are expressed as r ’s complement
Simple addition yields correct result
No need to distinguish different cases
Can be performed on same hardware as signed numbers
Most modern digital systems use 2’s complement
EE345 – Micro-Controllers
May 3, 2017
37
Two’s Complement Overflow
Consider two 8-bit 2’s complement numbers. We can represent the
signed integers -128 to +127 using this representation.
What if we do (+1) + (+127) = +128.
The number +128 is OUT
of the RANGE that we can represent with 8 bits. What happens when
we do the binary addition?
+127 =
7F
+
1 = 01
------------------128 ≠ 80 (this is actually -128 as a two’s
complement number!!! - the wrong answer!!!)
How do we know if overflow occurred? Added two
POSITIVE numbers, and got a NEGATIVE result.
EE345 – Micro-Controllers
May 3, 2017
38
Detecting Two’s Complement Overflow
Two’s complement overflow occurs when we:
or
Add two POSITIVE numbers and get a NEGATIVE result,
Add two NEGATIVE numbers and get a POSITIVE result
We CANNOT get two’s complement overflow if we add a
NEGATIVE and a POSITIVE number together.
The Carry out of the Most Significant Bit means nothing if
the numbers are two’s complement numbers.
EE345 – Micro-Controllers
May 3, 2017
39
Weighted and Unweighted Codes
Most numeric number representations are in a class
known as “Weighted Codes” where
r -1
Value b i w i
i 0
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
EE345 – Micro-Controllers
May 3, 2017
40
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 is really decimal
with different symbols)
BCD add/subtract circuits are complex
EE345 – Micro-Controllers
May 3, 2017
41
Other Decimal Codes
Weighted codes
The 8421 or
natural BCD
code is the
most
common BCD
code in use
EE345 – Micro-Controllers
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
May 3, 2017
42
BCD Addition
Case 1:
0001
1
0101
5
(0) 0110 (0) 6
Case 2:
0110
6
0101
5
(0) 1011 (1) 1
WRONG!
Case 3:
EE345 – Micro-Controllers
1000
8
1001
9
(1) 0001 (1) 7
May 3, 2017
Note that for cases 2 and 3,
adding a factor of 6 (0110)
gives us the correct result.
43
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
EE345 – Micro-Controllers
May 3, 2017
44
BCD Negative Number Representation
Similar to binary negative number representation except r
= 10.
BCD sign-magnitude
MSD (sign digit options)
BCD 10’s complement
MSD = 0 (positive); not equal to 0 = negative
MSD range of 0-4 positive; 5-9 negative
-N 10r - N; 9’s complement + 1
BCD 9’s complement
invert each BCD digit (09, 1 8, 2 7,3 6, …7 2, 8 1, 9
0)
EE345 – Micro-Controllers
May 3, 2017
45
Decimal Arithmetic
Everything needs to be 4-bit aligned
Signed magnitude representation or complements
‘+’ represented by 0 (=‘0000’)
‘–’ represented by 9 (=‘1001’)
Signed magnitude hardly used
10’s complement most common
Example: 375 + (–240)
Negative numbers represented by 10’s complement
10’s complement of 240 is 104 – 240 = 9760
Addition of all digits and
discard of end carry:
0 375
+9 760
0 135
Sign of result automatically correct
EE345 – Micro-Controllers
May 3, 2017
47
Gray Codes
Gray codes are
minimum change
codes
From one numeric
representation to the
next, only one bit
changes
Primary use is in
numeric input
encoding applications
where we expect nonrandom input values
changes (i.e. value n
to either n-1 or n+1)
EE345 – Micro-Controllers
May 3, 2017
Gray Code Dec. Equiv.
0000
0
0001
1
0011
2
0010
3
0110
4
0111
5
0101
6
0100
7
1100
8
1101
9
1111
10
1110
11
1010
12
1011
13
1001
14
1000
15 48
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.
EE345 – Micro-Controllers
May 3, 2017
49
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 = $26
7 bits can only represent 27 (128) different values. This is
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 (e.g., Arabic)?
EE345 – Micro-Controllers
May 3, 2017
50
ASCII CODE
b6b5b4
b3b2b1b0
000
001
010
011
100
101
110
111
0000
NUL
DLE
SP
0
@
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
,
<
L
\
l
|
1101
CR
GS
-
=
M
]
m
}
1110
S0
RS
.
>
N
^
n
~
1111
S1
US
/
?
O
_
o
DEL
EE345 – Micro-Controllers
May 3, 2017
51
UNICODE
UNICODE is a 32-bit code for representing alphanumeric
data. Most often, only 16 bits are used. With 16 bits, we
can represent 216 or 65,536 different symbols.
16 bits = 2 bytes per character.
$0041-005A
A-Z
$0061-4007A a-z
In UNICODE, Arabic characters are coded by the following:
Arabic basic characters: $0600 – $06FF
Arabic supplement: $0750 – $077F
Arabic presentation forms: $FB50 – $FDFF & $FE70 –
$FEFF
UNICODE is used by Web browsers, Java, and most software
EE345 – Micro-Controllers
May 3, 2017
52
Error Detection and Error Correction Codes
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
EE345 – Micro-Controllers
May 3, 2017
53
Single error detection with parity
simplest method for error detection
insert an additional parity bit for transmission
even parity may be generated by
Pe b3 b2 b1 b0 for a 4-bit data
e.g. for a 4-bit data 0110
Pe 0 1 1 0 0
odd parity may be obtained by
Po 1 Pe
e.g.
Po 1 0 1 1 0 1
EE345 – Micro-Controllers
May 3, 2017
54
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
ASCII T = 1010100 11010100
EE345 – Micro-Controllers
May 3, 2017
11000001
01010100
55
Parity Code Example
Concatenate a parity bit to the ASCII code for the
characters 0, X, and = to produce both odd-parity and evenparity codes.
Character
ASCII
Odd-Parity
ASCII
Even-Parity
ASCII
0
0110000
10110000
00110000
X
1011000
01011000
11011000
=
0111100
10111100
00111100
EE345 – Micro-Controllers
May 3, 2017
56
Binary Storage and Registers
How is information stored in a digital system?
Binary cells are grouped into registers
n cells make up n-bit register
Size of registers is typically predefined
Bits are stored in “binary cells”
Binary cell can have two stable states: ‘0’ and ‘1’
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
EE345 – Micro-Controllers
May 3, 2017
57
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
EE345 – Micro-Controllers
May 3, 2017
58
Register Transfer
Data can move from register to register.
Digital logic used to process data
We will learn to design this logic
Register A
Register B
Digital Logic
Circuits
Register C
EE345 – Micro-Controllers
May 3, 2017
59
Register Example
Data input at keyboard
Shifted into place
Stored in memory
EE345 – Micro-Controllers
May 3, 2017
60
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
EE345 – Micro-Controllers
May 3, 2017
61
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 -> uninteresting, inverter or wire only
2 inputs -> basic logic functions
What are possible logic functions?
NOT, AND, OR
Others can be derived from those (NAND, XOR, etc.)
EE345 – Micro-Controllers
May 3, 2017
62
NOT Function
Complement operation
Truth table
Single input
Inverts value of input
Symbolized by prime x’ or overbar x
Input combinations on the left
Output of function on the right
input
output
x
0
x'
1
1
0
Graphic symbol
NOT gate
Little circle indicates inversion
EE345 – Micro-Controllers
May 3, 2017
63
AND Function
Operation to check if two conditions are met
Truth table
Two inputs
Output = 1 if and only if both inputs are 1
Symbolized by dot or absence of operator
x·y or xy
Needs to consider 22 = 4 input combinations
Graphic symbol
AND gate
EE345 – Micro-Controllers
May 3, 2017
inputs output
x
0
0
1
1
y
0
1
0
1
z
0
0
0
1
64
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
EE345 – Micro-Controllers
May 3, 2017
x y
0 0
z
0
0 1
1 0
1 1
1
1
1
65
Comparison of Functions
Timing diagrams (waveforms)
Horizontal axis is time ( t )
Vertical axis shows signals, each with two different voltage levels
t
EE345 – Micro-Controllers
May 3, 2017
66
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
EE345 – Micro-Controllers
May 3, 2017
67