





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
The cs61c final exam held at the university of california, berkeley in spring 2007. The exam covers various topics in computer science, including memory management, floating-point numbers, and mips instructions. Students are required to answer multiple-choice questions and provide binary decodings. The exam also includes a palindrome-finder circuit design question.
Typology: Exams
1 / 9
This page cannot be seen from the preview
Don't miss anything!






Department of Electrical Engineering and Computer Sciences Spring 2007 Instructor: Dan Garcia 2007 - 05 - 12
After the exam, indicate on the line above where you fall in the emotion spectrum between “sad” & “smiley”... Last Name First Name Student ID Number Login (^) cs61c- Login First Letter (please circle) a^ b^ c^ d^ e^ f^ g^ h^ i^ j Login Second Letter (please circle) a^ b^ c^ d^ e^ f^ g^ h^ i^ j^ k^ l^ m n o p q r s t u v w x y z Your LAB TA’s name (please circle) Aaron Alex Brian David Matt Michael Valerie Name of the person to your Left Name of the person to your Right All the work is my own. I have no prior knowledge of the exam contents nor will I share the contents with others in CS61C who have not taken it yet. (please sign)
Midterm Revisited M1) Do you remember when… we used to sing, sha la la la… a) Some say bubble-gum pop music is garbage, so let’s start with a question about memory management and running programs! BRIEFLY tell us why the first thing is better than the second thing: Mark & sweep is better than reference counting because it... Reference counting is better than copying because it... Copying is better than mark & sweep because it... The buddy scheme is better than the slab allocator because it... The slab allocator is better than the plain K&R free list because it... Compiling is better than interpreting because ... Interpreting is better than compiling because... Dynamic linking is better than Static linking because... Static linking is better than Dynamic linking because... b) Decode the binary numbers into MIPS instructions with proper register names ($s0, $t0, etc.). If there are any memory addresses, represent them in hex. Address 32 - bit Binary Instruction Type (R, I, J) MIPS Instruction w/args 0xAFFFFFF8 0000 0001 0000 1000 0100 0000 0010 0110 0xAFFFFFFC 0001 0100 0000 1000 1111 1111 1111 1110 0xB0000000 0000 1000 0000 0000 0000 0000 0000 0001 0xB0000004 ...whatever... ...whatever... ori $v0, $0, 0x61C 0xB0000008 ...whatever... ...whatever... jr $ra c) You can replace the first instruction with a new instruction and save 2 clock cycles on a single-cycle non-delayed branch MIPS machine. What is it (in MIPS)? Careful! _______________
M3) Because I MIPS you, baby, and I don’t want to C a thing… What follows is a self-modifying MAL MIPS function. Read it carefully, and answer the questions below. A) What is the equivalent C code for mystery? Assume for this part that we only call mystery once. B) When we call mystery the second time with the same arguments we used the first time , do we get the same answer? If not, what do we get? (assume it’s not an error) C) Replace as few nops as possible by the done: label so that mystery behaves as it did in part A every time it’s called, not just the first time. mystery: la $t0, loop addu $v0, $0, $ loop: beq $a1, $0, done lw $t1, 0($a0) addu $v0, $v0, $t lw $t1, 4($t0) addiu $t1, $t1, 4 sw $t1, 4($t0) addiu $a1, $a1, - 1 j loop done: nop nop nop jr $ra // Precondition: 0 < a1 < 215 __________ mystery (___________ a0, int a1) { } done: __________________________
jr $ra
Post-Midterm Questions F1) Code bugs are terrified of RA-AI-AID!!! (Poof!)
No, we can’t be bribed, but we can improve our memory access time...let’s take a look! a) For the purposes of this question, assume our MIPS processor has two levels of data caches with the capabilities shown in the table on the right. Also assume:
Cache Data Size 32 KiB 512 KiB Block Size 8 B 32 B Associativity 4 - way Direct-mapped Hit Time 1 cycle 33 cycles Miss Rate 10% 2% Write Policy Write-through Write-through Replacement Policy LRU LRU Tag Index Offset AMAT (in clock cycles)
F4) Don’t just sit and wait for another datapath you by! On the right is the single-cycle MIPS datapath presented during lecture. Ignore pipelining for the question. Your job is to modify the diagram to accommodate a new MIPS instruction. Your modification may use simple adders, shifters, mux chips, wires, and new control signals. If necessary, you may replace original labels. We want to add a new MIPS instruction (we’ll call it addpr for “add to pointed reg”) that is almost identical to addi but with a twist. Instead of storing into the rt register the sum of the constant and the value of the register specified by rs, it stores into the rt register the sum of the constant and the value of the register specified by the lowest 5 bits in memory at the address specified by the pointer stored in the rt register. Said another way, first get the pointer stored in the rt register. Follow that pointer to get its value from memory. Take the lowest 5 bits of that value, treat is as a register number, and find out what is stored in that register. Add that to the immediate, and store it in the rt register. a) Make up the syntax for the I-type MAL MIPS instruction that does it (show an example if the pointer lives in $v0, and the constant is 5). On the right, show the register transfer language (RTL) description of addpr. Syntax RTL b) Change as little as possible in the datapath above and list all changes below. You may not need all boxes. (i) (ii) (iii) c) We now want to set all the control lines appropriately. List what each signal should be, an intuitive name or {0, 1, x – don’t care}. Include any new control signals you added. RegDst RegWr nPC_sel ExtOp ALUSrc ALUctr MemWr MemtoReg d) In the context of a single-cycle CPU, lw used to be the “critical path” instruction that really determined our fastest clock period, since it utilized the most components of our datapath. Using the terms below to create an expression that will determine how much slower our clock period will be if we also consider the addpr instruction: PCRegClkToQ, InstMemAccess, ControlLogicDelay, RegFileAccess, ALUdelay, DataMemAccess, RegSetup, RegHold, MemSetup, MemHold_._