DOC PREVIEW
UCLA COMSCI M151B - Sol HW3

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 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 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Homework #3 SolutionComputer OrganizationQ1. Draw (by hand, don’t copy and paste) the detailed state transition graph (STG) of the multi-cycle control unit showing very clearly the states and values of the associated control signals.Solution:Q2. State very explicitly the fundamental advantages and disadvantages of using multi-cycle implementation over single-cycle implementation of MIPS architecture.Solution:Main advantages1. Uses the clock cycle efficiently; the clock cycle is timed to accommodate the slowest instruction step.2. Multi-cycle implementations allow functional units to be used more than once per instruction as long as they are used on different clock cycles.Main disadvantagesMulti-cycle implementation requires additional hardware: more internal state registers, more multiplexers, and more complicated (FSM) control.Q3. The multicycle datapath that we studied had one ALU, which was used to increment the PC as well as for ALU operations (and address calculations), and branch target calculation. The single-cycle datapath had 3 separate adders/ALUs, one for incrementing the PC, one for ALU operations (and address calculation), and one for branch target calculation. Why are a different number of ALUs used in the two different datapaths?Solution:In the single-cycle datapath, we needed to perform 3 ALU operations in a clock cycle, and since a single ALU could only perform one operation in a cycle, 3 ALUs were needed. In the multicycle datapath, the same ALU could be used for all 3 functions, in different clock cycles.Q4. Refer to the figure below, which shows the datapath for the single cycle implementation. The gating that is shown works fine for the BEQ instruction (BRANCH = 1 and ZERO =1 selects the branch address to be loaded into the PC). Modify this logic so that it will also accommodate the BNE instruction. Make your changes on the figure (you can add extra control lines if you want, just make sure that you tell me what causes them to be asserted).Solution:Q5. What is microprogramming?Solution:A method for implementing control of a finite state machine, where the control is implemented using a sequence of microinstructions that are stored in a ROM and activate control signals whenthey are "executed".Q6. Solve problem 5.2 from your textbook. The stuck-at-0 faults in the single-cycle datapath.Solution:a. RegWrite = 0: All R-format instructions, in addition to lw, will not work because these instructions will not be able to write their results to the register file.b. ALUop1 = 0: All R-format instructions except addition will not work correctly because the ALU will perform addition instead of the required ALU operation.c. ALUop0 = 0: beq instruction will not work because the ALU will perform addition instead of subtraction, so the branch outcome may be wrong.d. Branch (or PCSrc) = 0: beq will not execute correctly. The branch instruction will always be not taken even when it should be taken.e. MemRead = 0: lw will not execute correctly because it will not be able to read data from memory.f. MemWrite = 0: sw will not work correctly because it will not be able to write to the data memory.Q7. Solve problem 5.3 from your textbook. The stuck-at-1 faults in the single-cycle datapath.Solution:a. RegWrite = 1: sw and beq should not write results to the register file. sw (beq) will overwrite a random register with either the store address (branch target) or random data from the memory data read port.b. ALUop0 = 1: lw and sw will not work correctly because they will perform subtraction instead of the addition necessary for address calculation.c. ALUop1 = 1: lw and sw will not work correctly. lw and sw will perform a random operation depending on the least significant bits of the address field instead of addition operation necessaryfor address calculation.d. Branch = 1: Instructions other than branches (beq) will not work correctly if the ALU Zero signal is raised. An R-format instruction that produces zero output will branch to a random address determined by its least significant 16 bits.e. MemRead = 1: All instructions will work correctly. (Data memory is always read, but memory data is never written to the register file except in the case of lw.)f. MemWrite = 1: Only sw will work correctly. The rest of instructions will store their results in the data memory, while they should not.Q8. Solve problem 5.29 from your textbook. The stuck-at-0 faults in the multi-cycle datapath.Solution:a. RegWrite = 0: All R-format instructions, in addition to lw, will not work because these instructions will not be able to write their results to the register file. b. MemRead = 0: None of the instructions will run correctly because instructions will not be fetched from memory. c. MemWrite = 0: sw will not work correctly because it will not be able to write to the data memory. d. lRWrite = 0: None of the instructions will run correctly because instructions fetched from memory are not properly stored in the IR register. e. PCWrite = 0: Jump instructions will not work correctly because their target address will not be stored in the PC. f. PcWritecond = 0: Taken branches will not execute correctly because their target address will not be written into the PC.Q9. Solve problem 5.30 from your textbook. The stuck-at-1 faults in the multi-cycle datapath.Solution:a. RegWrite = 1: Jump and branch will write their target address into the register file. sw will write the destination address or a random value into the register file. b. MernRead = 1: All instructions will work correctly. Memory will be read all the time, but IRWrite and lorD will safeguard this signal. c. MemWrite = 1: All instructions will not work correctly. Both instruction and data memories will be written over by the contents of register B. d. IRWrite = 1: lw will not work correctly because data memory output will be translated as instructions. e. PCWrite = 1: All instructions except jump will not work correctly. This signal should be raised only at the time the new PC address is ready (PC + 4 at cycle 1 and jump target in cycle 3). Raising this signal all the time will corrupt the PC by either ALU results of R-format,memory address of lw/sw, or target address of conditional branch, even when they should not be taken. f. PCWriteCond = 1: Instructions other than branches (beq) will not work correctly if they raise the ALU’s Zero signal. An R-format instruction that produces zero output will branch to a random address determined by their


View Full Document

UCLA COMSCI M151B - Sol HW3

Download Sol HW3
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 Sol HW3 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 Sol HW3 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?