Literature Review TB for CME 433 and EE 800 (2022 - 09)
This git contains the testbench files for the LR exercise for Fall 2022 Term.
Instructions
A: Testing your setup
- Download/Clone the repository over your local machine.
- Make sure that ModelSim/QuestaSim software is installed on your machine and available in the PATH variable.
- If you don't have ModelSim/QuestaSim available on your personal machine, I would advise you to use machines avaialble in USASK ENGR Labs.
- Start a terminal and change directory into "sim" folder.
- Use the following command to run the testbench with exact multiplier:
source ./gen_exact_results.sh
- Once the testbench is completed. Move to the python folder and make sure that numpy is installed in your python environment.
- Run the following command to generate accuracy stats:
python get_mnist_stats.py exact
- Your output should be:
Acc: 0.96
B: Adding your multiplier
- Copy the verilog/systemverilog source file of your multiplier in the "src" directory.
- Open "src/mult16via8.sv" file, and instantiate your multiplier at the directed place.
- If you've changed the source file. Remember that you must reverse it before you generate the exact results again.
C: Running the testbench for ALL Layers
- Open "testbench/tb_fullmnist.sv" file, and make sure that line#82 reads the following:
last_layer_mode = 0;
- Start a terminal and change directory into "sim" folder.
- Use the following command to run the testbench for your multiplier:
source ./run_tb.sh approx
- Once the testbench is completed. Move to the python folder and make sure that numpy is installed in your python environment.
- Run the following command to generate accuracy stats:
python get_mnist_stats.py approx
- Your output should be:
Acc: [Accuracy of your multiplier here]
D: Running the testbench for the LAST Layer
- Reverse any and all changes you've made to "src/mult16via8.sv".
- Repeat all the steps from Section A.
- Repeat all the steps from Section B.
- Open "testbench/tb_fullmnist.sv" file, and make sure that line#82 reads the following:
last_layer_mode = 1;
- Start a terminal and change directory into "sim" folder.
- Use the following command to run the testbench for your multiplier:
source ./run_tb.sh approx_lastlayer
- Once the testbench is completed. Move to the python folder and make sure that numpy is installed in your python environment.
- Run the following command to generate accuracy stats:
python get_mnist_stats.py approx_lastlayer
- Your output should be:
Acc: [Accuracy of your multiplier here]
E: Calculating NMED
- Modify the "python/get_mnist_stats.py" file with your own code to generate NMED for your multipliers.
F: Requirements for your final report and presentation:
- Perform all the steps included in Section A to E.
- Record the Accuracy values for Section C, and NMED for each layer for Section C. Here you will record a total of 4 metrics: 1 Accuracy, 3 NMED_per_layer
- Record the Accuracy values for Section D, and NMED for the last layer. Here you will record a total of 2 metrics: 1 Accuracy, 1 NMED_last_layer
- Write your own testbench to generate the NMED of your multiplier for all possible input values. Here you will record 1 metric: NMED_all_possible_inputs.
G: EE800 Students
- The floating point inputs and weights are provided in "data/EE800data" folder.
- A sample model is given in "python/float_mnist_model.py".
- You can run the sample model by moving to the python folder and make sure that numpy is installed in your python environment.
- Run the following command to generate accuracy stats:
python float_mnist_model
- You should see the following output:
Accuracy: 0.962
- You will have modify the provided testbench for your multiplier and posit format. You can convert the provided .txt files (from Step#1) directly to posit and feed into the testbench.