Overivew
This lab has 2 parts:
- CPU with BRAM
- FIFO with BRAM
Task 1: CPU w/ BRAM
See subfolder Labs/Lab03/cpu-bram.
Prelab
- You can review the
ee457_early_branch_block_diagram.pdffor a visual overview of the CPU design we are describing. - You can review the EE457 5-stage pipeline slides from Prof. Redekopp (
EE457Unit6*.pdf) - To compare your simulation results with our expected, golden results we use a TCL script. If you do NOT have TCL installed on your Windows laptop, we have included an installer in the
tcl_8.6zip file in our shared folder that you can download and install. You must install it before simulating your design.
Procedure
- Download and extract the source files
lab03-cpu-bram.zip. - Go through the complete
bram0-noreg(Register Array-based memory implementation) design insrc/des/bram0-noreg/cpu_5stage_NOREG.vhd. This is the baseline design that you will then update to use a flow-through (input register) or pipelined (input and output register) synchronous SRAM for the instruction and data memory. - Other complete files that will be used in this design include
ALU.vhd,dmem_NOREG_r1.vhd(data memory),Imem_NOREG.vhd(instruction memory), andreg_file.vhd(register file). - The testbench files in
src/tbare COMMON for all 3 designs and are COMPLETE. They include the main testbenchcpu_tb.vhd, a package for reverse-translation of the machine code to assmebler, and then SIX instruction sequences in thei_fetch_test_stream_*.vhdfiles. Our.doscripts will run all SIX sequences through the testbench, capturing your data memory and register file results and ensure they match the expected, golden output in thesim/golden-resultsfolder.- Note: only one instruction stream package file should be added to the project at the same time. But you don’t need to worry about this when you do behavioral simulations (
sim/bram*/cpu_lab.dofile will automatically place only one instruction stream package file at a time). However, you have to manually include only one instruction stream package file in your Xilinx project when you do post-route simulations
- Note: only one instruction stream package file should be added to the project at the same time. But you don’t need to worry about this when you do behavioral simulations (
- Make a Questa/Modelsim simulation project in the
sim/bram0-noregfolder. You do not have to add any sources manually as ourcpu_lab.dofile will compile the correct files and simulate the various instructions stream. It will also run a TCL script to automatically the compare the memory and register file results from each stream with out expectedgolden-resultsversions. (See the prelab to install TCL.) - Run the
cpu_lab.doscript. It will take a while to run all 6 simulations. At the end you should inspect theresults.txtfile in yoursim/bram0-noregfolder. It will indicated which traces failed or passed. If you passed all sequences you should see:Result is correct!in the file. - For the first exercise (
bram0-noreg), there should not be any difference between your result files and golden result files, since the design is complete. But for the remaining exercises, if one or more instruction sequences fail, you may comment out all the commands incpu_lab.dothat pertain to other stream sequences and simulate one sequence at a time (this will be clear if you look atcpu_lab.do) to debug your work. - Now study the almost-complete design in
src/des/bram1-ft/cpu_5stage_IREG.vhd, which uses a flow-through BRAM (i.e. an input register), and determine which signals you must connect to the indicated locations. Do not just guess but think carefully based on our discussion in lecture. When you think you have your design finished, create a new project in thesim/bram1-ftfolder and run thecpu_lab.dofile in that folder. Follow the procedure described above forbram0-noregto check if your simulation passed and debug as necessary until all instructions sequences pass. - Repeat the process for the almost-complete design in
src/des/bram2-pipe/cpu_5stage_IOREG.vhd, which uses a pipelined BRAM (i.e. an input AND output register), and determine which signals you must connect to the indicated locations. Do not just guess but think carefully based on our discussion in lecture. When you think you have your design finished, create a new project in thesim/bram2-nopipefolder and run thecpu_lab.dofile in that folder. Follow the procedure described above forbram0-noregto check if your simulation passed and debug as necessary until all instructions sequences pass. - Lastly, we want to ensure the code we’ve written is synthesizable. Follow the guidelines and procedures in the
CPU-BRAM-PostSynthesisSimulationTask.pdfdocument in our shared folder to synthesize and simulate your design in Xilinx. - Answer the questions in the
cpu_bram_questions_su2021.pdfand submit the resulting annotated or exported PDF to Gradescope.
Submission
- Online Submission: You need to do two submissions, one for each BRAM type. Copy over the following files to your SCF account
cpu_5stage_IREG.vhd(fromsrc/des/bram1-ftfolder)cpu_5stage_IOREG.vhd(fromsrc/des/bram2-pipefolder)names.txt
- Then run the following submission commands.
submit -user ee560 -tag cpu-bram1 cpu_5stage_IREG.vhd names.txt
submit -user ee560 -tag cpu-bram2 cpu_5stage_IOREG.vhd names.txt
- Review question: Individually complete and submit your annotated or exported PDF answers in the
cpu_bram_questions_su2021.pdfvia Gradescope (also linked via D2L..Lab-Review-Submissionmodule).
Task 2: FIFO w/ BRAM
See subfolder Labs/Lab03/fifo-bram-pipe.
Prelab
- Review our lecture material on FIFO implementation, Gray Code, and using BRAMs in the FIFO design.
Procedure
In this task you will complete a 2-clock FIFO using a pipelined (input and output register) BRAM. You will NOT need to implement the design for an flow-through BRAM.
- Download and extract the source files
lab03-fifo-bram-pipe.zip. - Open and complete the missing parts (specified by the
TaskandTODOcomments in the source code) infifo_bram_ip_op_reg.vhdfile. - Inspect the testbench files in
src/tband especially theproducer.vhdand its associated input file in thesim/ee560_producer_data.txtfile. The producer side data file has 2 columns the first one is the producer side latency and the second one is the data to send out. The last three bits of the 16-bit data indicate consumer latency (suggesting the consumer to take a certain number of clocks to consume the provided data). Please do go through them to understand how producer and consumer latencies are emulated to simulate the environment external to the FIFO. - Simulate your design by creating a project in the
simfolder and then using thefifo_bram_ip_op_reg.dofile. Compare your results produced inee560_received_data.txttoee560_received_data_golden.txtand similarly betwenee560_sent_data.txtandee560_sent_data_golden.txt. Debug your design if these do not match until they do.
Submission
- Online Submission: Submit the following files
fifo_bram_ip_op_reg.vhd(fromsrc/desfolder)names.txt
submit -user ee560 -tag fifo_bram_ip_op_reg fifo_bram_ip_op_reg.vhd names.txt
Celebrate your success!
