DOC PREVIEW
Berkeley COMPSCI 152 - Homework

This preview shows page 1-2-3-4-5-6 out of 19 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS152 Homework I, Fall 2006Name:Homework I is due in class on Thursday September 28 at 11:10 AM.This class is the Mid-term I review session.Late homeworks are NOT accepted. Thus, if you will not be attendingthe review session, you MUST make arrangements to hand off thehomework to the instructor before classtime.Homework will be graded on effort (did you make an honest attempt tosolve each problem?), not correctness. We will distribute the correctanswers for the homework in the review session, but we will probablynot return the homework you hand in until after the exam. So, you may wish to make a copy for reference before you hand it in.This homework will count for approximately 1.5% of your final grade.The homework is based on the Mid-term I exam from Fall 05.You may discuss the homework problems with fellow students and the TAs, but what you write down must be your own work (no copying the answers from someone else!s homework). Good luck! John LazzaroSSID:110215310410515615710815Tot100#Points1 Register File Design (10 points)On the top slide on the next page, we show the write logic for the register filedesign we showed in Lecture 1-2.Redesign the write logic for the register file, so that two registers may bewritten on the same positive clock edge. The 5-bit values ws1 and ws2 specifythe registers to write, the 1-bit values WE1 and WE2 enable writing for eachport (1 = enabled, 0 = disabled), and the 32-bit values wd1 and wd2 are thedata to be written. If both write ports are enabled, and ws1 and ws2 specifythe same register, this register MUST be written with the value wd1.Draw your final design on the bottom slide shown on the next page. If youneed to use a complex logic function in your answer, define a truth table for afunction f(x, y, . . .) below the slide, and draw boxes on the schematic labeledwith f(x, y, . . .). You may use standard symbols for simple gates (OR gates,AND gates, multiplexers, demultiplexers, etc).Work out your design below BEFORE drawing on the slide on the next page.Only the next page will be graded.R1R2...R31QQQR0 - The constant 0 QclkwdDDDEnEnEnDEMUX...ws5WE32From Lecture 1-2: Register File DesignR1R2...R31QR0 - Constant 0Qclkwd1DDDEnEnEnws15WE132wd232ws25WE2QQ2 Single Cycle Design (15 points)Below, we show a slightly-modified version of the single-cycle datapath that wederived in the first weeks of class. On the following pages, we ask questionsabout this design.Clk32Addr DataInstrMem32DPCQ3232+32320x4PCSrc32+32Extimm Note: imm is immediate field from I- format bitfield. Ext unit sign extends, does word->byte shift.BRSrcrd1 Note: rd1 is output from register file. Single-cycle instruction fetch (modified) Mux control: 0 is lower mux input, 1 upper mux input100132rd1RegFile32rd2WE32wd5rs15rs25wsExtRegDestALUsrcExtOpALUctr32ALU3232opMemToReg32DoutData MemoryWE32DinAddrMemWrEqualRegWrimmoprsrtrdshamtfunctoprsrtimm I-format R-format Mux control: 0 is lower mux input, 1 upper mux input RegWr, MemWr: 1 = write, 0 = no write. ExtOp: 1 =sign-extend, 0 = zero-extend.rtrsrsrt Single-cycle datapath (modified)101010Question 2a (5 points). We wish to add a new I-format opcode to theinstruction set, named LWA (Load Word and Autoupdate index). The purposeof LWA is to read a block of memory by invoking LWA many times, withoutneeding to update the index register value by executing add instructions.In the definition below, rs and rt refer to the register coded in the rs and rtI-format fields, and imm refers to the constant coded in the immediate field.Syntax:LWA $rt imm($rs)Actions:$rt = M[$rs + sign_extended(imm)]$rs = $rs + sign_extended(imm)Note that the M[] memory access uses the rs value present at the start of theinstruction, not the updated value written at the end of the instruction.In this question, you are to evaluate how to add LWA to the datapath.Is the datapath, as shown, able to execute LWA? In answering this question,assume that you MAY add a new instruction to the ALU – this function maybe any Boolean function of the two ALU inputs – but you may NOT otherwisechange the datapath.Circle YES or NO below (X points):YES NOIf your answer is yes, fill out the table control values needed for this instruction.Each b ox should be filled with a 0, 1, or X (don’t care). A 0 or 1 that couldhave been an X counts as incorrect. Also specify the ALU function.BRSrcPCSrcRegDestRegWrExtOpALUSrcMemWrMemToRegFunction for ALU:Express ALU function below as a function of “A” (upper input) and “B” (lower input). Specify if equation is boolean or numeric, specify if constants are in decimal or hex.If the answer is no, precisely state how to modify the datapath to supportthe instruction, in 30 words or less. Fuzzy answers get 0 credit (fuzzy example:“add more registers and wires”).If answer is “no”, write your statement below:Question 2b (5 points). We wish to add a new I-format opcode to theinstruction set, named SWA (Store Word and Autoupdate index). The purposeof SWA is to write a block of memory by invoking SWA many times, withoutneeding to update the index register value by executing add instructions.In the definition below, rs and rt refer to the register coded in the rs and rtI-format fields, and imm refers to the constant coded in the immediate field.Syntax:SWA $rt imm($rs)Actions:M[$rs + sign_extended(imm)] = $rt$rs = $rs + sign_extended(imm)Note that the M[] memory access uses the rs value present at the start of theinstruction, not the updated value written at the end of the instruction.In this question, you are to evaluate how to add SWA to the datapath.Is the datapath, as shown, able to execute SWA? In answering this question,assume that you MAY add a new instruction to the ALU – this function maybe any Boolean function of the two ALU inputs – but you may NOT otherwisechange the datapath.Circle YES or NO below (X points):YES NOIf your answer is yes, fill out the table control values needed for this instruction.Each b ox should be filled with a 0, 1, or X (don’t care). A 0 or 1 that couldhave been an X counts as incorrect. Also specify the ALU function.BRSrcPCSrcRegDestRegWrExtOpALUSrcMemWrMemToRegFunction for ALU:Express ALU function below as a function of “A” (upper input) and “B” (lower input). Specify if equation is boolean or numeric, specify if constants are in decimal or hex.If the answer is no, precisely state how to modify the datapath to supportthe instruction, in 30 words or less. Fuzzy answers get 0 credit


View Full Document

Berkeley COMPSCI 152 - Homework

Documents in this Course
Quiz 5

Quiz 5

9 pages

Memory

Memory

29 pages

Quiz 5

Quiz 5

15 pages

Memory

Memory

29 pages

Memory

Memory

35 pages

Memory

Memory

15 pages

Quiz

Quiz

6 pages

Midterm 1

Midterm 1

20 pages

Quiz

Quiz

12 pages

Memory

Memory

33 pages

Quiz

Quiz

6 pages

Quiz

Quiz

5 pages

Memory

Memory

15 pages

Load more
Download Homework
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Homework and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Homework 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?