CDA3101-S13-Recitation1-SLIDES - Digital Logic

Download Report

Transcript CDA3101-S13-Recitation1-SLIDES - Digital Logic

CDA3101 Recitation Section
Introduction,
Digital Logic,
Performance Equation, and
Benchmarking
Introduction
●
Lecture is for learning the theory of computer architecture,
underlying design principles, and high level concepts.
Recitation sections are for learning how to apply those
ideas in practice. (ie. solve problems)
Hint: don't skip recitation
Where does your grade come from?
●
Homework (6, 24%): will contain questions that are
Vocab: you will probably see some of these on the
exam
– Easy: well within the scope of the exam
– Long: material is not too hard for the exam, but the
question takes much too long
– Hard: some homeworks (not all) may contain
questions that are more challenging than exam
Note: question difficulty
questions
predictions are based on my
own subjective
experience
– Beyond the scope of the course (often
as
EC)
from previously TAing this
course. This slide is not a
Quizzes (5, 10%)
–
●
promise!
Short, easier than exam questions
Midterm Exams (3, 42%)
–
●
●
Final Exam: (24%)
Tips for Knowledge/Vocab Questions
●
Example from Exam 2 grading rubric, previous semester
Digital Logic
●
●
Logic gates convert some input signals (1s or 0s) to
some output signals (1s or 0s).
Input connected to output by “wires”, which do not
change the logic level, and logic gates, which do.
NOT
●
AND
OR
XOR
Bubbles on gates negate the logic level at the bubble:
NAND
Truth Tables
●
A truth table is the output of a circuit for every possible
combination of inputs
NAND - not (a and b)
a
0
0
1
1
b
0
1
0
1
y
1
1
1
0
A
B
Y
Problem 1 - Digital Logic
●
Problem 1: prove that NAND is the universal
gate. Represent the following gates using
NAND.
●
NOT
●
AND
●
OR
●
XOR
Problem 1 - Digital Logic
NOT
AND
A
A
B
A
Y
Y
A
B
A
B
Y
Y
Y
Problem 1 - Digital Logic
OR
A
B
Y
De Morgans Law:
A+ B=( A⋅B)
A
Y
B
Problem 1 - Digital Logic
XOR
A
B
Definition:
Y
A B+ B A
Expression consists only of NOT, AND, and
OR. Plug in previous solutions to complete
the problem.
Problem 2 – Digital Logic (SOP/POS)
●
Find the SOP (sum-of-product) and POS
(product of sums) representation for the
following expression using truth table
f =( x y )+ ( y z w)⋅( z x )+ ( x w)
Problem 2 – Digital Logic (SOP)
f =( x y )+( y z w)⋅( z x )+( x w )
x
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
y
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
z
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
w
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
xy
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
yzw zx
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
1
xw f
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
Each SOP minterm is a
boolean expression that
matches a particular row.
The SOP expression says f is
true if I'm in the 10th row of the
truth table OR the 12th row OR
the 13th row... etc.
f sop = x y z w+ x y z w +
x y z w+ x y z w+ x y z w +
x yzw
Problem 2 – Digital Logic (SOP)
f sop = x y z w+ x y z w+ x y z w+ x y z w +
x y z w+ x y z w
Diagram (first 2 terms)
x yzwx yzw
f
Problem 2 – Digital Logic (POS)
f =( x y )+ ( y z w)⋅( z x)+ ( x w)
x
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
y
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
z
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
w
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
xy
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
yzw zx
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
1
xw f
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
Each POS minterm is a
boolean expression that
excludes a particular row.
The POS expression says f is
true if I'm not in the 1st row of
the truth table AND I'm not in
the 2nd row AND I'm not in the
3rd row... etc.
f
=( x + y + z +w)( x + y + z +w)
( x+ y+ z + w)( x+ y + z + w)
( x+ y+ z + w)( x+ y + z + w)
( x+ y+ z + w)( x+ y + z + w)
( x+ y+ z +w )( x+ y + z + w)
pos
Performance Evaluation
●
Time to run a program:
Hint: Very important equation!
Problem 3 - Performance Evaluation
●
Machine M1, which clocks at 2 GHz, can run a
program P in 15 seconds, under an average
CPI of 3.
1) How many instructions are required to run P?
2) We want to design a machine M2 which, under
the same average CPI, can run P in a third of the
time. How fast must the clock speed of M2 be to
achieve this task?
Problem 3 - Performance Evaluation
●
Machine M1, which clocks at 2 GHz, can run a program P
in 15 seconds, under an average CPI of 3.
1) How many instructions are required to run P?
(IC)(CPI)
Runtime=
Clock Rate
cyc
inst
15 sec=
9 cyc
2×10
sec
( IC )3
cyc
(15 sec)(2×10
)
sec
IC=
=1x1010 inst
cyc
3
inst
9
Problem 3 - Performance Evaluation
●
Machine M1, which clocks at 2 GHz, can run a program P
in 15 seconds, under an average CPI of 3.
2) We want to design a machine M2 which, under the same
average CPI, can run P in a third of the time. How fast must
the clock speed of M2 be to achieve this task?
(IC)(CPI)
Runtime=
Clock Rate
(1x1010 inst )(3
5 sec=
cyc
)
inst
Clock Rate
cyc
(1x10 inst )(3
)
inst
9 cyc
Clock Rate=
=6
=6 GHz
5 sec
sec
10
Problem 4 - Performance Evaluation
●
We have two machines, M1 and M2, which we
will use to run a program P. M2 runs at twice
the clock speed of M1, and requires 2 more
clock cycles on average per instruction. M2
runs P in 75% of the time it takes for M1 to run
the same program.
1) At what CPI does M1 run? M2?
2) If the program consists of 5000 instructions, and
M1 can run it in ten seconds, what is the clock
speed of M2?
Problem 4 - Performance Evaluation
●
We have two machines, M1 and M2, which we will use to run a
program P. M2 runs at twice the clock speed of M1, and requires
2 more clock cycles on average per instruction. M2 runs P in
75% of the time it takes for M1 to run the same program.
1) At what CPI does M1 run? M2?
What we know!
Clock Rate 2 =2 Clock Rate 1
CPI 2 =CPI 1 + 2
Runtime 2 =(0.75)Runtime 1
IC 1 = IC 2
Problem 4 - Performance Evaluation
(cont) At what CPI does M1 run? M2?
What we know!
(IC)(CPI 1 )
Runtime1 =
Clock Rate 1
Clock Rate 2 =2 Clock Rate 1
(IC)(CPI 2 )
Runtime 2 =
Clock Rate 2
Runtime 2 =(0.75)Runtime 1
Approach: solve for constant
term (IC) and set two sides equal.
CPI 2 =CPI1 + 2
IC 1 =IC 2
(Runtime 1 )(Clock Rate 1 ) (Runtime 2 )(Clock Rate 2 )
IC=
=
CPI 1
CPI 2
( Runtime1 )(Clock Rate1 )(CPI 2 )
CPI 1=
(Runtime 2 )(Clock Rate 2 )
(Runtime1 )(Clock Rate 1 )(CPI 1+ 2) CPI 1+ 2
CPI 1=
=
(0.75 Runtime1 )(2 Clock Rate 1 )
(0.75)(2)
Problem 4 - Performance Evaluation
(cont) At what CPI does M1 run? M2?
CPI 1 + 2
CPI 1=
(0.75)(2)
(1.5) CPI1 =CPI 1+ 2
(0.5)CPI 1=2
CPI 1=4
CPI 2 =6
What we know!
Clock Rate 2 =2 Clock Rate 1
CPI 2 =CPI1 + 2
Runtime 2 =(0.75)Runtime 1
IC 1 =IC 2
Problem 4 - Performance Evaluation
2) If the program consists of 5000
instructions, and M1 can run it in ten
seconds, what is the clock speed of
M2?
Runtime 2 =(0.75)10 sec=7.5 sec
(IC)(CPI 2 )
Runtime 2 =
Clock Rate 2
(5000 inst )(6
7.5 sec=
What we know (updated)!
Clock Rate 2 =2 Clock Rate 1
CPI1 =4
CPI 2 =6
Runtime 2 =(0.75)Runtime 1
IC 1 =IC 2 =5000
cyc
)
inst
Clock Rate 2
(5000 inst )(6
Clock Rate 2 =
7.5 sec
cyc
)
inst
=4000
cyc
=4 KHz
sec
Problem 5 - Performance Evaluation
●
Given a machine M with clock
rate 4 GHz and a program P that
has 50,000 instructions and the
following instruction mix and CPI,
what incidence percentage (%y)
should instructions of type C
have to guarantee that the
execution time is no more than
100 micro-seconds?
Type
A
B
C
D
E
%
12
25
y
23
rem
CPI
6
13
11
5
2
Problem 5 - Performance Evaluation
●
What we know: Clock rate = 4 GHz;
IC = 50,000; Runtime < 100 x 10-6
(IC)(CPI)
Runtime=
Clock Rate
(50000)(CPI)
100×10 ≥
4×109
−6
Type
A
B
C
D
E
%
12
25
y
23
rem
CPI
6
13
11
5
2
CPI =0.12(6)+ 0.25(13)+ y (11)+ 0.23(5)+ (1−0.23− y−0.25−0.12)(2)
cyc
CPI =(5.92+ 9y)
inst
(50000 inst)(5.92+ 9y)
100×10−6 ≥
4×109
cyc
inst
cyc
sec
y≤0.2311 , so y must compose at most 23.11% of instructions
cyc
inst
Arith. Mean, Geo. Mean, Median
●
●
Given a data set with N elements
Arithmetic Mean: sum all the elements, divide
by N
●
●
Geometric Mean: multiply all the elements,
take the Nth root
●
●
Used for raw timing data.
Used for comparing performance between systems.
Median: sort all the elements, then take the
middle element (or if even number of elements,
take the arithmetic mean of the two middle
elements)
Arith. Mean, Geo. Mean, Median
●
Given { 3, 7, 1, 5 }
●
Arithmetic Mean:
–
●
Geometric Mean:
–
●
(3 + 7 + 1 + 5) / 4 = 4
(3 * 7 * 1 * 5)^(1/4) = 3.2
Median:
–
–
Sorted {1, 3, 5, 7}
(3+5)/2 = 4
SPEC Benchmarks
http://www.spec.org/cpu2000/docs/
What is a benchmark?
●
a program used to time execution on a computer system
Why are benchmarks added or removed?
●
in response to changes in applications