Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For your convenience, you are provided with a zip file (1ab7_supplement.zip) containing all the required Verilog files. The top module (named MIPSzy) is stored in
For your convenience, you are provided with a zip file (1ab7_supplement.zip) containing all the required Verilog files. The top module (named MIPSzy) is stored in MIPSzy.v file and the sample testbench (named MIPSzy_TB) is stored in MIPSzy_TB. v file. Using the testbench file, you can: Once you are done with the modifications on the Verilog code, you will write an assembly program that will read two numbers, x and y, stored inside DM[5000] and DM[5004), respectively. Your program will then calculate y-x, 2y-x, 3y-x, 3y-2x, 4y-x, 4y-3x, 5y-x and 5y-3x using the new sub instruction, where necessary. Finally, your program will store results of these calculations into memory addresses DM[5000] to DM[5028], i.e. Initialize values inside memory addresses 5000-5004 lines 31-32 of the testbench, and then Initialize program memory - you can write and store programs of up to 1024 lines lines 35 onwards (depend on the length of the actual program): 29 initial begin // initialize test numbers (can be any number up to 32-bits long) test numbers [O] - 3; // Number to be stored in D (5000) test_numbers [1] = 1; // Number to be stored in DM5004) // initialize instruction memory W2; Before the program run: DM (5000) = x DM[5004] = y After the program run: DM (5000] = y-x DM[5004] = 2y-x DM[5008] = 3y-x MIPSzy_0.IM.memory[O] - '110001100000010000001001110001000; // lw Sto, 5000 (zero) MIPSZY 0.IM memory[1] - '000000001000010000100100000100000; // add Sti, Sto, Sto MIPSzy_0.IM memory[2] - '110101100000010010001001110001000; // sw Sti, 5000 (Szero) Load from DM5000] Double the values + store to DM (5000) end Note that test number values and program memory contents shown here are the ONLY parts you should be editing inside the testbench. DO NOT TOUCH ANYTHING ELSE! Like before, the sample program provided in the testbench reads the number stored in DM[5000], doubles it and writes back to DM[5000). However, this time, it uses offsets during load and store, thereby reducing the number of lines in the program. In the sample testbench, DM/5000) is initialized to 3. Therefore after the execution of the program, DM[5000) should have the doubled value, i.e. 6. You can read any memory address at the end of simulation - by default the testbench prints values stored inside addresses 5000-5028 upon completion of program run. The screenshot below shows the output of Modelsim run, for the input values of x=3 and y=1: # Data at address 5000 is # Data at address 5004 is # Data at address 5008 is # Data at address 5012 is # Data at address 5016 is # Data at address 5020 is # Data at address 5024 is # Data at address 5028 is # ** Note: $stop : ../MIPSzy_TB.V (89) DM [5012] = 3y-2x DM[5016] = 4y-x DM[5020] = 4y-3x DM[5024] = 5y-x DM[5028] = 5y-3x Anondon For your convenience, you are provided with a zip file (1ab7_supplement.zip) containing all the required Verilog files. The top module (named MIPSzy) is stored in MIPSzy.v file and the sample testbench (named MIPSzy_TB) is stored in MIPSzy_TB. v file. Using the testbench file, you can: Once you are done with the modifications on the Verilog code, you will write an assembly program that will read two numbers, x and y, stored inside DM[5000] and DM[5004), respectively. Your program will then calculate y-x, 2y-x, 3y-x, 3y-2x, 4y-x, 4y-3x, 5y-x and 5y-3x using the new sub instruction, where necessary. Finally, your program will store results of these calculations into memory addresses DM[5000] to DM[5028], i.e. Initialize values inside memory addresses 5000-5004 lines 31-32 of the testbench, and then Initialize program memory - you can write and store programs of up to 1024 lines lines 35 onwards (depend on the length of the actual program): 29 initial begin // initialize test numbers (can be any number up to 32-bits long) test numbers [O] - 3; // Number to be stored in D (5000) test_numbers [1] = 1; // Number to be stored in DM5004) // initialize instruction memory W2; Before the program run: DM (5000) = x DM[5004] = y After the program run: DM (5000] = y-x DM[5004] = 2y-x DM[5008] = 3y-x MIPSzy_0.IM.memory[O] - '110001100000010000001001110001000; // lw Sto, 5000 (zero) MIPSZY 0.IM memory[1] - '000000001000010000100100000100000; // add Sti, Sto, Sto MIPSzy_0.IM memory[2] - '110101100000010010001001110001000; // sw Sti, 5000 (Szero) Load from DM5000] Double the values + store to DM (5000) end Note that test number values and program memory contents shown here are the ONLY parts you should be editing inside the testbench. DO NOT TOUCH ANYTHING ELSE! Like before, the sample program provided in the testbench reads the number stored in DM[5000], doubles it and writes back to DM[5000). However, this time, it uses offsets during load and store, thereby reducing the number of lines in the program. In the sample testbench, DM/5000) is initialized to 3. Therefore after the execution of the program, DM[5000) should have the doubled value, i.e. 6. You can read any memory address at the end of simulation - by default the testbench prints values stored inside addresses 5000-5028 upon completion of program run. The screenshot below shows the output of Modelsim run, for the input values of x=3 and y=1: # Data at address 5000 is # Data at address 5004 is # Data at address 5008 is # Data at address 5012 is # Data at address 5016 is # Data at address 5020 is # Data at address 5024 is # Data at address 5028 is # ** Note: $stop : ../MIPSzy_TB.V (89) DM [5012] = 3y-2x DM[5016] = 4y-x DM[5020] = 4y-3x DM[5024] = 5y-x DM[5028] = 5y-3x Anondon
Step 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