Question: Objective In this project the student will write a program to solve a problem using the processor that was completed in Lab 8 . Testing

Objective
In this project the student will write a program to solve a problem using the processor that was completed in Lab 8. Testing will be by board demonstration. ModelSim can be used to help track down errors. For extra credit, the student will modify the processor to enable loading a program into memory using the boards switches for input.
Background
The equation of a line is often expressed as y = mx + b , where m is the slope and b is the y-intercept. Our processor does not do multiplication (or division) directly and it also cant handle floating-point numbers or results greater than +/-127, or so we must keep these constraints in mind. We will restrict b to be an integer between 0 and +/-22_10, and x to be an integer between 0 and +/-7. Lets also restrict m to be an integer between 0 and +/-15. Remember to convert any negative numbers into twos complement form. Store the values of these variables, x, m, b, y(-3) to y(3) and any other variables you need in memory far away from where the program is stored
One approach to doing multiplication is just adding a number (m in this case) to itself x times (x is the multiplier), in an inner loop and keeping a running total*. This could be done using a while loop (think JUMP) with a counter, i (stored in memory somewhere) that is set initially equal to |x| to control the number of times to do the inner loop. When i becomes zero, exit the inner loop, add b and store in a location for y(x). If starting with x =-3 and ending with x =3, test to see if the outer loop is done by subtracting 3 from x and use JZER to exit the outer loop, otherwise increment x and go through the inner loop again. If x is negative, add negative values of m, i times then add b. If x =0, obviously you just store b for y(0).
If we limit x to a maximum value of 3 we can alternatively use a simpler approach by subtracting 2 from x for positive, non-zero values of x as follows:
x Subtract 2? Op y(x)
0 no JZER = b
1 x-2 JNEG = m + b
2 x-2 JZER = m<<1+b
3 x-2 JPOS = m<<1+ m + b
-1,-2,-3 n/a n/a =-[y(|x|)-b]+b
For any arbitrary value of a multiplier (such as x >3) this approach involves an iterative process of inspecting bit0 of x and if a 1 then adding the multiplicand (m) to the product (a running sum starting at zero), then shift the multiplier (x) right one bit and the multiplicand (m) left one bit and repeat the test of bit0, adding the shifted multiplier to the product if bit0 is a 1. Continue this operation until all the bits of the multiplier have been inspected Since we are limiting our multiplier to 7 our width is 3 so there are three iterations of the loop. Keep in mind for a seven bit product (2s complement for 8 bit signed number) the maximum multiplier is 3 bits wide and the multiplicand can be a maximum of four bits wide.
After computing all the values for y(x), regardless of your method, load an indicator value that you dont expect to see (such as EE) into AC, then start loading each result of y successively until all have been loaded, then end with an infinite loop. When executing the program, operate the clock until you see the indicator value, then afterwards each group of six clock cycles reveals the stored answers for y.
*Do modular division in a similar way by doing multiple subtractions instead of additions with a counter that becomes the quotient once the remainder is less than the divisor.
Activity: Write the Assembly Language Program and Convert to Machine Code
Write a program in our processors assembly language with corresponding machine code alongside to solve the problem described above and save as a text file (give comments to document your authorship as always and explain each line of code. The instructor will specify the values of m and b you must use.
Syntax of assembly language for our processor:
e.g. To load a value E7 to AC, you can write
Assembly Code Machine Code Comments
Label : LOADI 0xE702 E7//Load 0xE7 into AC
The program should begin at address 0x00. Since there is no STOP instruction, your last line of code could be a JUMP instruction that jumps to itself.
Load your program into memory with the switches one byte at a time, return LD_PGM to 0 and then RESET.
Run your program and watch the PC as you step through the program by pressing the CLK button and notice when the PC shows you have reached this last line.
Submission checklist:
New SV code for control module and test bench code/bdf
Assembly language to solve the problem (including machine code and comments) and the corresponding .mif file, if applicable.

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!