Question
You will create the algorithm that you will implement n a processor CPU. Your algorithm will take as input an unsigned number: A. It must
You will create the algorithm that you will implement n a processor CPU. Your algorithm will take as input an unsigned number: A. It must then compute the sum of all the numbers from 1 up to and including A. As an example, if A=5, your algorithm will compute 15 by adding: 1+2+3+4+5. You may assume that the input A is already loaded in your register file, as well as any other numbers you require. You must use a loop to implement your algorithm. To do this, complete the following steps:
a) Write out your algorithm is pseudocode.
b) Show a flowchart with all of the processor states like the below example.
c) Show a table like the example one below listing the values of the control signals necessary to implement the algorithm above. You may assign registers any way you like to hold your variables and necessary data, but state it up front!
d) Show an execution trace table like the below example.
e) Lastly, determine the largest value for the unsigned integer A that your algorithm will still compute the correct answer.
State 0: B > 0? Our program has 4 possible states. PC - will hold that state! True, next state =1 while (B>0){ C = C +A; B = B - 1; State 1: C = C+ A // END PROG. Goto state 2 State 2: B = B-1 Go back to state 0 False, next state = 3 Program done, Stay in state 3 forever State 3: Loop Let's implement the algorithm in control memory Algorithm: AR1 ARZ AN WE NZP NextPC Functionality: while (B > 0) { C = C + A; B = B-1; ROW O R3 RO ROW 3 TEST: is B > 0 ROW 1 R2 000 C=C+A ROW 2 ROW O Register File: RO = 0 (for comparison) R1 = 1 (to subtract from B) R2 = A (initially 5 for ex.) R3 = B (initially 2 for ex.) R4 = C(initially O) B=B-1 and loop back to rowo ROW 3 1 x | x X 111 ROW 3 Loop forever on row 3 NZP Test Tricks NZP Condition: 000 Forces output to O NZP Condition: 111 Forces output to 1 V #1 #2 #2 #0 #3 1 x 4 3 2 Lo Clock Cycle PC state #0 +/- A r1 3 A r2 WE Aw ALU out RO 0 R1 R2(#A) 5 R3(#B) R4(#C) Operation B>0? 12 10 X 0 1 5 5 5 55 5 12 10 10 10 B>0 B>0 10 Loop C=C+A B=B- C=C+A B=B- Loop State 0: B > 0? Our program has 4 possible states. PC - will hold that state! True, next state =1 while (B>0){ C = C +A; B = B - 1; State 1: C = C+ A // END PROG. Goto state 2 State 2: B = B-1 Go back to state 0 False, next state = 3 Program done, Stay in state 3 forever State 3: Loop Let's implement the algorithm in control memory Algorithm: AR1 ARZ AN WE NZP NextPC Functionality: while (B > 0) { C = C + A; B = B-1; ROW O R3 RO ROW 3 TEST: is B > 0 ROW 1 R2 000 C=C+A ROW 2 ROW O Register File: RO = 0 (for comparison) R1 = 1 (to subtract from B) R2 = A (initially 5 for ex.) R3 = B (initially 2 for ex.) R4 = C(initially O) B=B-1 and loop back to rowo ROW 3 1 x | x X 111 ROW 3 Loop forever on row 3 NZP Test Tricks NZP Condition: 000 Forces output to O NZP Condition: 111 Forces output to 1 V #1 #2 #2 #0 #3 1 x 4 3 2 Lo Clock Cycle PC state #0 +/- A r1 3 A r2 WE Aw ALU out RO 0 R1 R2(#A) 5 R3(#B) R4(#C) Operation B>0? 12 10 X 0 1 5 5 5 55 5 12 10 10 10 B>0 B>0 10 Loop C=C+A B=B- C=C+A B=B- LoopStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started