Docsity

Booth Algorithm and Single Cycle Processor Problems, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
Name:__________________________________________
1
Problem 1: (25 points) Arithmetic
The original reason for Booth’s algorithm was to reduce the number of operations by avoiding
operations when there were string of 0s and 1s. Revise the algorithm presented in class to look
at 4 bits at a time and compute the product three bits at a time.
Recall the table for 2 bits (A is the multiplicand, B is the multiplier):
Ai Ai-1 Operation
0 0 Do nothing
0 1 Add B
1 0 Subtract B
1 1 Do nothing
Fill in the following table to determine the 3-bit Booth encoding. Explain the reason for the
operation on each line. Two of the cases are given for you.
Current Bits Previous
Bit Operation Reason
Ai+2 A
i+1 Ai Ai-1
0 0 0 0 None Middle of a string of 0s
0 0 0 1
0 0 1 1
0 1 0 1
1 0 1 0
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Booth Algorithm and Single Cycle Processor Problems and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

Problem 1: (25 points) Arithmetic The original reason for Booth’s algorithm was to reduce the number of operations by avoiding operations when there were string of 0s and 1s. Revise the algorithm presented in class to look at 4 bits at a time and compute the product three bits at a time.

Recall the table for 2 bits (A is the multiplicand, B is the multiplier): Ai Ai-1 Operation 0 0 Do nothing 0 1 Add B 1 0 Subtract B 1 1 Do nothing

Fill in the following table to determine the 3-bit Booth encoding. Explain the reason for the operation on each line. Two of the cases are given for you.

Current Bits Previous Bit Operation Reason

Ai+2 Ai+1 Ai Ai-

0 0 0 0 None Middle of a string of 0s

Problem 2: (35 points) Single Cycle Processor

The following single cycle processor seems to be executing random instructions. You must investigate and find out why. You suspect that the control is the cause of the problem.

On the next page you will find a picture of the datapath, and the corresponding control signals are below.

PCSrc RegDst RegWr ExtOp ALUSrc ALUCtr MemWr MemToReg addu 0 0 1 1 x 0 0 0 subu 0 1 1 x 0 0 0 0 ori 0 1 1 0 x 2 0 0 lw 0 1 1 1 1 0 1 1 sw 0 x 0 0 1 0 1 x beq Equal x 0 x 0 3 0 x jr 2 x 0 x x x 0 x

The ALUCtr encoding is as follows: Control Bits Operation 0 add 1 sub 2 or 3 xor

Assume the following:

  • “Equal” means that PCSrc takes on the value of the equal signal coming out of the “= 0?” module. This will either be 0 or 1.
  • The “= 0?” module outputs 1 if the input to the module is 0 , otherwise it outputs 0.
  • The modules within the datapath (i.e. extender, alu) all work correctly.
  • The register file (RegWr) and data memory (MemWr) both write when their respective write signals are 1
  • The extender will zero extend if ExtOp is 0, and will sign extend when ExtOp is 1

Part a) (25 points) What does the broken processor actually do for the following sequence of instructions? The first instruction has been done for you as an example. If there is more than one possibility, please list all of them (note that this may be a different instruction, correct, behavior, or an undefined instruction). If the incorrect result does not match a valid MIPS instruction, give a sequence of instructions that correspond to the behavior. Also give a very brief explanation of your possibilities. For simplicity, we have used the actual register number rather than the names.

Intended Instruction Actual Instruction(s)

addu $1, $2, $ addu $1, $2, $0 (if ALUSrc = 0) - correct addiu $1, $2, 33 (if ALUSrc = 1) - incorrect

subu $4, $5, $

ori $7, $8, 0x

beq $11, $12, 24

sw $10, -12($31)

lw $9, -16,($29)

Part b) (10 points) Describe the changes to the control signals that must be done to make the processor function correctly. The control signals from the previous page have been reprinted for your convenience.

PCSrc RegDst RegWr ExtOp ALUSrc ALUCtr MemWr MemToReg

addu 0 0 1 1 x 0 0 0

subu 0 1 1 x 0 0 0 0

ori 0 1 1 0 x 2 0 0

lw 0 1 1 1 1 0 1 1

sw 0 x 0 0 1 0 1 x

beq Equal x 0 x 0 3 0 x

jr 2 x 0 x x x 0 x

Part b) (15 points) Complete this finite state machine diagram for the addm instruction. Be sure to include any new control signals you may have added.

Problem 5: (40 points) Caches

AMAT = Hit time + (Miss rate × Miss penalty)

(4 points) A processor has a direct-mapped cache capable of holding B bytes of data in total, and each block of the cache contains b bytes of data (both B and b are powers of two). How many bits does it take to implement the cache?

Now you must figure out what the values of B and b are for the processor. Consider the following code:

// We will choose values for LENGTH and STEP char a[LENGTH]; int i, j, temp; for(i = 0; i < 10000; i++) for(j = 0; j < LENGTH; j = j + STEP) temp = temp + a[j];

How does this code help us?

Part a) Suppose STEP is initially 1. (4 points) If LENGTH ≤ B, how many cache misses would we expect each time the outer for- loop is executed?

(4 points) How would things change if we increased LENGTH until it became larger than 2B?

Part c) Drawing inferences from the data: (4 points) What is the value of B? Explain your answer.

(4 points)What is the value of b? Explain your answer.

(4 points)What is the approximate time for a cache hit?

(4 points) What is the approximate time for a cache miss?