






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The solution to problem 1 of the cs152 midterm exam at the university of california, berkeley. The problem requires designing the datapath and control signals to implement the cs and cslwcs instructions in a single-cycle processor. The solution includes adding new blocks, such as muxes and a generalized alu, and modifying existing signals.
Typology: Exams
1 / 12
This page cannot be seen from the preview
Don't miss anything!
input
Input 2
zero
Greater
output
GALU
ALUcontrol
box A (^) B C box
See below
Instruction Alusrc Memto Reg
Reg Write
Mem Read
Mem Write
NewC1 NewC
Sw 1 X 0 0 1 0 0 R-format 0 0 1 0 0 0 0 cslw 0 1 1 1 0 1 0 cslwcs 0 1 1 1 0 1 1
With this new processor, the time = 1,000,000 * 81ns = 81ms
A) [10 points] Microprogram the following instructions by filling in the table. The SrcA and SrcB fields specify which signals will be assigned to BusA and BusB, respectively. The WrDest field specifies what component is written at the end of the cycle. This can be any one of the state registers (A and B can be paired together in one cycle), the register file, or memory. It is implied that all other components will not be written accidentally. The Sequence field behaves as presented in class: it specifies whether the microprogram should return to the fetch stage to start a new macroinstruction, dispatch to a location specific to the current opcode, or proceed in order. You should ignore the BEQ instruction for now – it is only provided for part (C). Hint: you do not need to fill all the rows.
01 Decode – – – A,B Dispatch 02 ADD A B Add S Next 03 – S – RegFile Fetch 04 05 06 ADDI A SX Add S Next 07 – S – RegFile Fetch 08 09 0A LW A SX Add S Next 0B S – – M Next 0C – M – RegFile Fetch 0D 0E SW A SX Add S Next 0F S B – Mem Fetch 10 11
12 BNE A B Sub –
If ALUzero Then Next Else Fetch 13 PC SX Add PC* Fetch
B) [10 points] One of the major drawbacks to using large buses is the massive loading caused by so many components all connected to the same node. To approximate the effect of the increased loading, assume that it takes an additional 10ns just to drive a signal on a bus (in other words, assume the hollow arrowheads in the datapath schematic have a delay of 10ns). Each component delay is copied below for your reference (you’ll notice they all match the other problems). Neglecting the BNE instruction , what is the maximum clock frequency of this processor? Registers (clk-to-Q) 1ns Register File 10ns Extender 3ns ALU 15ns Memory 10ns nPC Logic 10ns
The critical path of this processor is during instruction fetch, where the buses must be accessed twice, along with the memory and register delay. The minimum cycle time is therefore Time = clk-to-Q + bus_access + memory + bus_access = 1 + 10 + 10 + 10 = 31 ns
The maximum clock frequency is the inverse of time, such that Freq = 1/Time = 1/31 ns ≈ 32.258 MHz
Problem 4: MIPS 5 Stage Pipelined Processor (30 points) The processor shown on the next page is one implementation of a standard MIPS 5 stage pipelined processor. The specifications of the processor are as following: Five pipeline stages: IF, ID, EX, MEM, WB The processor does not have forwarding nor hazard implemented yet. Control signal are represented by dotted lines. Control bus value represents the actual control bits from top down. Control signal values are in binary format. Data signal values are in decimal value. RegisterFile writes in the first half of the cycle , and reads in the second half Both instruction and data memory read asynchronously; data memory writes synchronously. Both memories are byte addressed. Data memory size is 16 words and only the least significant bits are used to address the memory. Each component has been labeled with worst-case delay. Registers only have clock-to-Q delay, zero setup/hold time. Assume no clock skew. The diagram of the processor also includes a snapshot of the processor at the beginning of the cycle, with necessary signal values labeled. Table 1 & 2 shows the contents of the Register file, Data memory at the snapshot time. Assume register file and memory have been correctly updated in the previous cycle, but all writes in the current cycle have not taken place yet. Table 3 shows the ALU Control truth table. MIPS R3000 Opcode table is also attached at the end.
A) How many branch delay slot(s) does this processor have? (4 points)
3
B) What is the minimum clock period of the processor? (4 points)
1+6+15 = 22 ns
C) In MIPS assembly language, determine exactly what instruction is being executed in ID stage? What’s the result? i.e., register file or data memory content changes. (6 points)
Sub $9, $7, $ $9 = 24 – 8 = 16 Note: WB stage write to $7 with value 24
D) In MIPS assembly language, determine exactly what instruction is being executed in EX stage? What’s the result? i.e., register file or data memory content changes. (6 points)
Lw $7, 16432($0) Note: it’s the same word address as 48($0) $7 = Mem(48/4) = 32 Note: MEM stage SW to address 48 with value 32
E) Now implement only the hazard detection unit without forwarding, such that from the software’s perspective, the processor has exactly one branch delay slot, exactly one load delay slot, and all hazards should be resolved on hardware level. You are only allowed to add write enable control signals to any of the five pipeline registers, along with necessary control logics. (10 points) i. In order to stall the pipeline, some of the five pipeline registers should have write enable control signal. Filling in the following table. (‘Y’ means yes needed, ‘N’ means not necessary) PC IF/ID ID/EX EX/MEM MEM/WB
ii. Describe in words, or pseudocode, under what condition should each of the pipeline register be write disabled, and for how many processor cycles in each case. Pipeline Register
Write Disable Condition
PC If ID detects BCH, disable for 2 cycles; If ID detects LW, disable for 1 cycles;
If MEM instruction writes back to the same register as ID instruction uses, disable for 1 cycles;
IF/ID Same as PC disable conditions
ID/EX Never
EX/MEM Never
MEM/WB Never