Question: Task 3 - 6 : Create Additional Tests. You will be using the brainless CPU as a subcircuit in Lab 4 . Therefore, we want

Task 3-6: Create Additional Tests.
You will be using the brainless CPU as a subcircuit in Lab 4. Therefore, we want to make sure it
is working properly now rather than trying to debug it while working on Lab 4. In this task,
youll create additional tests to verify that your circuit is, in fact, working properly. Make three
copies of brainless_stim.v and name them brainless_ext_write.v, brainless_int_write.v, and
Version 1.1 Fall 202418
brainless_alu.v. Then, modify the inputs and expected outputs in each so that you perform the
following additional tests:
1. Write a value from data_in to an address in the program_ram. This is an external write
to the RAM. (brainless_ext_write.v)
2. Store a nonzero value from the accumulator to an address in the program_ram. This is
an internal write to the RAM. (brainless_int_write.v)
3. Demonstrate any two additional ALU functions, storing the results in the accumulator.
This may be done with a single simulation. The ALU functions may not be the pass
through or addition functions used in the example program provided in
brainless_stim.v.(brainless_alu.v)
For each of the above, modify the stimulus and expected response as needed and run them
with iverilog. When they work as expected, paste the stimulus you used and a screenshot of the
waves similar to Figure 16 into your template. For the stimulus, just paste in the values assigned
to test_vals as shown in Figure 17.
test_vals[0]=28'h0_0_0_0_0_0_4; // reset - this should always be the first vector
test_vals[1]=28'h3_3_3_0_0_3_1; // get 3 into the accumulator
test_vals[2]=28'h8_5_D_0_1_5_1; // add 3+5 and store in the accumulator
test_vals[3]=28'h8_0_0_0_0_0_0; // do nothing the rest of the way
test_vals[4]=28'h8_0_0_0_0_0_0;
test_vals[5]=28'h8_0_0_0_0_0_0;
test_vals[6]=28'h8_0_0_0_0_0_0;
test_vals[7]=28'h8_0_0_0_0_0_0;
Figure 17. Example of what to paste in your template.
For the two tests which write to the RAM, make sure that the RAM value shows up on the
data_bus output so it can be seen. Do this by properly controlling the select lines to the muxes.
To create these tests, use the same approach we took for the example test in brainless_stim.v.
Ask yourself where the data is now and how the controls need to be set to get the data where
you want it.
Text file to be used here:
`timescale 1ns/1ns
// IMPORTANT: DO NOT MODIFY ANYTHING BETWEEN HERE AND *****
// Module to provide stimulus to the brainless CPU
module brainless_stim(num_tests,values,addr);
output [3:0] num_tests; // how many tests to apply
output [27:0] values; // the values to apply plus expected response
input [2:0] addr; // the address into the memory of values
reg [27:0] test_vals [0:7]; // memory to hold the input and expected output
initial // check for too many tests
begin
#1 if ( num_tests >8)
begin
$display("Too many tests - the limit is 8!");
$finish;
end
end
assign values = test_vals[addr];
// The bits of the test_vals memory are:
//27:23- accum The expectd accumulator output
//23:20- data_bus The expected data_bus value
//19:16- alu_out The expected alu output
//15:12- data_in The data_in input
//11: 8- addr_bus The address bus input
//7- invert An ALU control input
//6- arith An ALU control input
//5- pass An ALU control input
//4- load_acc Load the accumulator
//3- acc_to_db Select the accumulator value
//2- reset Reset the circuit
//1- write Write a value into the RAM
//0- read Select the program_ram value
// IMPORTANT: ONLY MODIFY BELOW THIS LINE *****
assign num_tests =8; // how many tests you want to run
// Each assignment to test_vals[#] is one test.
// NOTE: The maximum number of tests is 8, and they are numbered 0-7.
// NOTE: The tests MUST be numbered consecutively starting with 0.
// NOTE: At least the first test should be reset!
// For the bit assignments, see the comment 14 lines above this line
initial
begin
test_vals[0]=28'h0_0_0_0_0_0_4; // reset - this should always be the first vector
test_vals[1]=28'h3_3_3_0_0_3_1; // get 3 into the accumulator
test_vals[2]=28'h8_5_D_0_1_5_1; // add 3+5 and store in the accumulator
test_vals[3]=28'h8_0_0_0_0_0_0; // do nothing the rest of the way
test_vals[4]=28'h8_0_0_0_0_0_0;
test_vals[5]=28'h8_0_0_0_0_0_0;
test_vals[6]=28'h8_0_0_0_0_0_0;
test_vals[7]=28'h8_0_0_0_0_0_0;
end
endmodule

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!