







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








SingleโCycle Datapath/ MultiโCycle Datapath Adding instructions
Modify the datapath and control signals to perform the new instructions in the corresponding datapath.
Use the minimal amount of additional hardware and clock cycles/control states.
Remember:
๏ท When adding new instructions, don't break the operation of the standard ones. ๏ท Avoid adding ALUs, adders, Reg Files, or memories to the datapath ๏ท You can add MUXes, logic gates, etc. but try to do minimally. (these cost in terms of area, cycle time, etc)
a. Load Word Register (uses R instruction format) lwr Rt, Rd (Rs) #Reg[Rt] = Mem[Reg[Rd]+Reg[Rs]]
b. Add 3 operands (new instruction format: opcode(6), rs(5), rt(5), rd(5), rx(5), (6 bits not used)) add3 Rd, Rs, Rt, Rx #Reg[Rd] = Reg[Rs] + Reg[Rt] + Reg[Rx] c. Add to Memory (new instruction format: opcode(6), rs(5), rt(5), rd(5), offset(11))
addm Rd, Rt, Offset(Rs) #Reg[Rd] = Reg[Rt] + Mem[sign extended offset + Reg[Rs]] d. Branch on less than or Equal (uses I instruction format)
blez Rs, label # if Reg[Rs] < 0, PC = PC+4 + (signโextended offset << 2) e. Branch Equal to Memory (new instruction format: opcode(6), rs(5), rt(5), rd(5), offset(11))
beqm Rd, Rt, Offset(Rs) # if Reg[Rt] = Mem[Offset+Reg[Rs]], PC = PC + 4 + Reg[Rd] f. Branch Equal to 0 to Immediate (uses R instruction format)
beqzi (Rs), Label #if Mem[Reg[Rs]] = 0, then PC = PC + (signโextended offset) (NOTE: This is not PC+4, and not shifted by 2)
g. Store Word and Increment swinc Rt, offset(Rs) #Mem[Reg[Rs] + sign extended offset]= Reg[Rt], Reg[Rs] = Reg[Rs] + 4
h. Store Word and Decrement swdec Rt, offset(Rs) #Mem[Reg[Rs] + sign extended offset] = Reg[Rt], Reg[Rs] = Reg[Rs] โ 4
What if you were to add (g) and (h) simultaneously to the datapaths?
Datapath Timing
๏ท Memory: 200ps ๏ท Register Files Access (READ/Write): 50ps ๏ท ALU and adders: 100ps ๏ท Logic Gates and Multiplexors: 1ps ๏ท All other times are negligible
Other Datapath Questions
Given MIPS code, can you determineโฆ..
๏ท Whatis happening at clock cycle X in the Single Cycle Datapath? Or what cycle is operation X happening? ๏ท What is happening at clock cycle X in the Multi Cycle Datapath? Or what cycle is operation X happening? ๏ท How many cycles it will take to execute the code? ๏ท Can you identify the signals (control and values) in the datapath for a given clock cycle? ๏ท And other questions of this natureโฆ.
Short Answer Misc Questions
Throughput = 1/latency when a system is executing one task at a time eg. In a single or multiโ cycle datapath
Average CPI (old) = 0.40 * 1 + 0.30 * 5 + 0.30 * 2 = 2. Average CPI (enhanced) = 0.40 * 1 + 0.30 * 3 + 0.30 * 2 = 1. Speedup (computation) = 2.5 / 1.9 = 1. Speedup = 1 / ((1 - 0.82) + 0.82 / 1.315) = 1.
b. Which modification gave the best speedup?
Modification (i) provides the best speedup.
c. For the two modifications in part (i) that did not result in the best speedup, is it possible for them to achieve the speedup achieved by the modification in part (ii)? Show your work and explain your answer. i. An infineitely fast dask: Speedup = 1 / (1 โ0.18) = 1.22 which is still slower than i ii. If FP only 1 clock cycle: Average CPI (enhanced) = 0.40 * 1 + 0.30 * 1 + 0.30 * 2 = 1. Speedup (computation) = 2.5 / 1.3 = 1. Speedup = 1 / ((1 - 0.82) + 0.82 / 1.92) = 1.
Assume the following distribution of instruction types (assume that LUI requires 3 cycles):
Processor X Processor Z MULT 0% 5% LUI 5% 0% LW 20% 25% SW 10% 10% RโType 45% 40% BEQ 20% 20%
For example, if processor Z executes 5 MULT instructions out of every 100. For each MULT instruction, processor X executes an additional 30 instructions.
a. Compare the execution times of the two processors.
Execution time = TIC = Cycle time * Instruction Count * Average CPI Exec time(x) = Tx * Ix * Cx Exec time(z) = Tz * Iz * Cz Tx= 10ns; Tz=12ns
If Iz=100, Ix= 95 + (5 * 30) = 245 CPI for each instruction type: MULT=80 cycles, LUI =3, LW=5, SW=4, RโTYPE =4, BEQ=
Therefore: Average CPI for X = Cx = (0.053)+(0.25)+(0.14)+(0.454)+(0.23)=3. Average CPI for Z = Cz = (0.0580)+(0.255)+(0.14)+(0.44)+(0.23)=7.
Comparing execution times: Exec time(x) = 10 ns/c * 3.95 c/i * 245 i = 9677.5 ns Exec time(z) = 12 ns/c * 7.85 c/i * 100 i = 9420 ns
Processor Z with the multiply instruction is about 1.03 times faster than processor X for this instruction mix.
b. At what clock speed for processor Z are the two designs equal in performance?
Equating the two excution times and solving for Tz 10ns * 3.95cpi * 245 instructions = Tz * 7.85cpi * 100 instructions Tz = (10ns * 3.95 * 245)/(7.85* 100) Tz= 12.33ns
For smaller Tz (faster clock), processor Z has better performance; for larger Tz (slower clock), processor X has better performance.
c. (more difficult) Assuming the original ALU latency for processor Z (12 ns), how fast would your softwareemulated multiply have to be (on average) for processor X to be just as fast as processor Z? In other words, how many instructions would processor X execute in place of 1 MUL?
Remember that Ix was defined to be 95 + (# of multiplications) * (cost of each) We first need to find the instruction count of processor X necessary for equal performance. 10ns * 3.95 * Ix = 12ns * 7.85 * 100 which implies Ix = 238. Total number of multiplyโemulate instructions is (238.5โ95)= 143. Therefore number of instructions per multiply = 143.5/5 = ~28 instructions
M1 can never be faster than M2, even if all the instructions are branch instructions, the CPI will be 3 for all 3 cases, and the clock rate is faster on the other 2 processors.
M3 can be faster than M2, if all instruction loads or all stores then
Ex: M2: Average CPI = 14 + 04 + 03 + 03 = 4 M3: Average CPI = 13 + 03 + 03 + 03 = 3
M2 Cycle Time = (CPI#instructions)/ clock rate = 4I/3.2GHz = 1.25I10โ^9 seconds M3 Cycle Time = (CPI#instructions)/ clock rate = 3I/3.2GHz = 1.07I10โ^9 seconds
Review Adder and ALU Creation and Building larger ALUs from units
Consider the 4 โbit ALU below which can perform the following 5 operations: add, sub, AND, OR and
negate B.
Inputs are A={A 3 ,A 2 ,A 1 ,A 0 }, B={B 3 ,B 2 ,B 1 ,B 0 }, and C (^) in. Outputs are result R={R 3 ,R 2 ,R 1 ,R 0 }and C (^) out. Numbers
are in 2โs complement form. Fill in the table below, for each operation, what the values of the control signals should be. Indicate donโt cares where appropriate.
Operation m 1 M 0 Cin B (^) INV Az Add^0 0 0 0 Sub 0 0 1 1 1 OR 1 0 X 0 1 AND^0 1 X^0 Negate B 0 0 0 0 1
Digital Logic
a. bdโ + cโd = ((bโdโ) + (cd))โ bdโ + cโd = (bโdโ)โ(cd)โ De Morgans bdโ + cโd = (b+d)(cโ+dโ) De Morgans bdโ + cโd = bcโ+ cโd+ bdโ + ddโ Distributive bdโ + cโd = bcโ+ cโd+ bdโ + 0 Complementary bdโ + cโd = bcโ(d+dโ)+ cโd+ bdโ Null bdโ + cโd = bcโd + bcโdโ+ cโd+ bdโ Commutative bdโ + cโd = cโd (1 + b) + bdโ(cโ + 1) Distributive bdโ + cโd = bdโ + cโd Null
b. abcโ + bcโd + aโbd = abcโ + aโbd
abcโ + bcโd(a+aโ) + aโbd = abcโ + aโbd Null abcโ + abcโd + aโbcโd + aโbd = abcโ + aโbd Distributive abcโ(1+d) + aโbd (cโ+1) = abcโ + aโbd Commutative abcโ + aโbd = abcโ + aโbd Null
c. aโ + a(aโb + bโc)โ = aโ + b + cโ aโ + a((aโb)โ (bโc)โ) = aโ + b + cโ De Morgans aโ + a((a+bโ)(b+cโ)) = aโ + b + cโ De Morgans aโ + a(ab+bbโ+acโ+bcโ) = aโ + b + cโ Distributive aโ + a(ab+0+acโ+bcโ) = aโ + b + cโ Complementary aโ + a(ab+acโ+bcโ) = aโ + b + cโ Distributive aโ + aab+aacโ+abcโ = aโ + b + cโ Idempotence aโ + ab+acโ+abcโ = aโ + b + cโ Idempotence aโ + a(b+cโ+bcโ) = aโ + b + cโ aโ + b + cโ+ bcโ = aโ + b + cโ No Name aโ + b + cโ(1+ b) = aโ + b + cโ Null aโ + b + cโ = aโ + b + cโ
a. How many literals does z contain? 11 b. Is z, minimal? If not, find the minimal expression using Boolean algebra. No.
c. Find the equivalent sum of minterms (SOP) for z (using ๏m notation)
The straight forward solution using minterms/SOP expression:
A Better Solution using Demorganโs law: Aโ + B + C = ((Aโ + B + C)โ)โ = (ABโCโ)โ
a 1 a 0 b 1 b 0 A+B (decimal)
(decimal)
Z 3 = a1a0b1b Z 2 = a1a0โb1 + a1a0b1b0โ = a1a0โb1 + a1b1b0โ Z 1 = a1โb1b0 + a1โa0b0 + a1โa0b1 +a1a0b1โ + a1b1โb
Z 0 = (a0 + b0)(a1+a0โ+b
Decoders take a binary number and map this value to an output line. 2 โinput values, means 4 different values (4 outputs)