Question: Assignment 2 : Processors, Pipelines, and Instruction Representation 1 5 points + 3 bonus Task 1 : Pipelined Architecture Assume you are programming in assembly

Assignment 2: Processors, Pipelines, and Instruction Representation
15 points +3 bonus
Task 1: Pipelined Architecture
Assume you are programming in assembly on a 16-bit architecture which employs a five-stage pipeline for instruction execution. The five stages are:
(1) fetch next instruction
(2) decode instruction and fetch operands
(3) perform ALU operation
(4) read or write to memory
(5) store result in register
Your architecture has 8 general purpose registers split into two banks with r0-r3 on bank 1 and \(\mathrm{r4}-\mathrm{r}7\) on baink 2. The following instructions are implemented:
load loads an immediate value into a register \( r_{b}\)(\( r_{e}\) and the immediate value offset are provided as arguments)
mov moves a value from a register \( r_{a}\) to a register \( r_{b}\left(r_{b}=r_{a}\right)\)
add adds the value in register \( r_{a}\) to the value in register \( r_{b}\) and stores the result in register \( r_{b}\left(r_{b}=r_{a}\right.\)\(+\mathrm{r}_{\mathrm{b}}\))
sub subtracts the value in register \( r_{b}\) from the value in register \( r_{a}\) and stores the result in register \( r_{b}\),\(\left(r_{b}=r_{a}-r_{b}\right)\)
emp compares the value of registers \( r_{a}\) and \( r_{b}\) and sets the global register cmp to I if \( r_{2}\geq r_{b}\) and to 0 otherwise.
bae increments the program counter pe by an immediate value if the value of the global register cmp is not equal to 1(\(\mathrm{pc}=\) petoffset)
jmp sets the program counter pe to a value \( r_{3}\) toffset and moves on to the next instruction.
a: Assuming that each stage of the pipeline takes three clock cycles to complete, how many instructions per clock cycle does the overall architecture execute? explain under what conditions
your answer holds true. What would be the consequence of improving stages (1).(2) and (3) to process one instruction per cycle? (3 points)
b: At which stage of the pipeline does the parallelism offered by the register banks become uscful and why? (1 point)
c: For which instructions in the ISA does the use of register banks speed up execution? (1 point)
You have written the following assembly code:
load r0,10 load value 10 into register ro
load \(\mathrm{rl},\mathrm{I}\)\# load 1 into register rl
load \( r 2,0\)\# load 0 into register \( r 2\)
load \( r 3,0\quad \)\# load 0 into register r 3
load \(\mathrm{r}4,1\quad \)\# load 1 into register r 4
load rs,0\# load 0 into rs
while :
add \(\mathrm{rl},\mathrm{r}2\quad
otin \) add contents of rl and r 2, store into r 2
mov r4, r5 ie r5-r4
add \(\mathrm{r}3,\mathrm{r}4\) if \(\mathrm{r4}-\mathrm{r}3+\mathrm{r4}\)
mov r5, r3\# \(\mathrm{r}3=\mathrm{r}5\)
cmpr 2, r0\(\quad \)\# \(\mathrm{cmp}=\mathrm{r}2>-\mathrm{r}0\)
bne while
d: Re-assign register numbers to use the register banks correctly and avoid register conflicts. (2 points)
e: Assume that register bank conflicts are not a problem (we've solved this somehow) and look at the original code above (not your modifications from d:). How many pipeline stalls due to data hazards will occur while executing this program? Assume that no control hazards occur and that the pipeline is always fed with the next instruction from the correct branch. (3 points)
f. Design a binary encoding for the instruction set. What type of operand encoding are you using? What is the largest offset that you can encode? (3 points)
g: The instruction set does not allow for a multiplication operation. Assume we want to use this processor to emulate one which provides a multiplication instruction mul \( r_{a} r_{b}\) which computes the expression \( r_{3}=r_{1}\times r_{b}\). Write an assembly code routine to implement this instruction. You can assume that the jump and boe instructions can be called with a label, instead of an explicit offect. Note: here we are using the pseudo assembly ISA defined above and not some real assembly language. Therefore, I expect the solution to be provided in pseudocode. (5 points)
Assignment 2 : Processors, Pipelines, and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!