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 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 yintercept. Our processor does not do multiplication or division directly and it also cant handle floatingpoint numbers or results greater than or so we must keep these constraints in mind. We will restrict b to be an integer between and and x to be an integer between and Lets also restrict m to be an integer between and Remember to convert any negative numbers into twos complement form. Store the values of these variables, x m b y to y 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 yx If starting with x and ending with x test to see if the outer loop is done by subtracting 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 obviously you just store b for y
If we limit x to a maximum value of we can alternatively use a simpler approach by subtracting from x for positive, nonzero values of x as follows:
x Subtract Op yx
no JZER b
x JNEG m b
x JZER mb
x JPOS m m b
na na yxbb
For any arbitrary value of a multiplier such as x this approach involves an iterative process of inspecting bit of x and if a 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 bit adding the shifted multiplier to the product if bit is a Continue this operation until all the bits of the multiplier have been inspected Since we are limiting our multiplier to our width is so there are three iterations of the loop. Keep in mind for a seven bit product s complement for bit signed number the maximum multiplier is bits wide and the multiplicand can be a maximum of four bits wide.
After computing all the values for yx 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:
eg To load a value E to AC you can write
Assembly Code Machine Code Comments
Label : LOADI xE ELoad xE into AC
The program should begin at address x 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 LDPGM to 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 codebdf
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
