Performance and Benchmarks
|
Boolean Algebra and Logic Design
|
The key is to realize that relative performance is all that is asked for - and the problem states that the instruction count is the same for both machines and compilers.
For M1, the execution time can be calculated as:
and for M1:
For M1 the execution time now looks like this:
and for M1:
CPI for the machines can be calculated as:
Total Execution time for A is 1001, for B is 110 and for C is 40.
Computer C is the fastest
C is about 25 times faster than A
C is about 2.75 times faster than B
Without improvements the program spends 20 seconds on multiplication, 50 seconds for memory access and 30 for everything else.
If multiplication is 4 times faster, the multiplication part of the program will take on 5 seconds, and the total running time will be 85 seconds. This corresponds to a speedup of 100/85 = 1.18.
If memory is 2 times faster the memory accesses will now take 25 seconds. The total running time will be 75 seconds, for a speedup of 1.33.
If both improvements are made the total running time will be 5+25+30= 60 seconds for a speedup of 100/60 = 1.67.
The solution requires that the new program spend different percentages of time on the 4 types of operations (multiplication, memory, other) so that the speedup we see if we make multiplication 4 times faster is the same as the speedup we see if we make memory 2 times faster. A little algebra is required.
X is the percentage of time spent in multiplication
Y is the percentage of time spent for memory access
100-X-Y is the percentage of time spent doing other stuff
Without any improvements the program takes 100 seconds. To solve the problem we need to find values for X and Y such that the total time with either one improvement is the same.
With multiplication 4 times faster the new running time is:
With memory 2 times faster the new running time is:
Equating these two expressions and reducing reveals the following relationship between X and Y:
Using percentages of X=20% Multiplication, Y=30% Memory and 50% for other satisfies the conditions and will result in the same speedup for either improvement.
To prove that NAND is a universal operator
(a functionally complete set) we can show how to implement the
primary operators OR, AND and NOT
using just the NAND operator.
Here is the truth table for NAND:
| A | B | A NAND B |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
To build a NOT using only NAND we just
need to recognize that A NAND A is always the same
as NOT A. So the following shows how we can use a
NAND gate to implement NOT:
To build a OR using only NAND we can
use DeMorgan's law to convert A OR B as follows:
Using this and our NAND based inverter, the following
implements OR using only NAND gates:
To build AND using only NAND we just
invert the output of a NAND gate:
Don't worry if you can't do the 4th function, we haven't yet covered 2's complement representation.
Here is a truth table that includes all 4 functions:
And here are boolean equations:
The diagram below shows what the switch does for each of the possible states of S:
Here is the truth table:
Here are boolean equations for C and D.