CSE141L Lab 2, Part B: Processor Front-End - Fetch Control


CSE 141L Homepage | Lab Overview | Lab Description


Deadline: Friday, Oct. 31 Nov. 7 at NOON.
Changes:
  1. The deadline has been moved back 1 week. This part is now due Friday, Nov. 7 at NOON.

Lab Overview:

We are making great progress with the fetch unit for our new processor. While we have the datapath all set up, we need to complete our front-end implementation by adding in the necessary control logic. Because our unofficial motto of quality control here at AwesomeCore is "Hugs, not bugs!", you will need to perform some rigorous testing of the completed fetch unit to make sure that it meets our specification. After our work with the front-end is done, we can proceed to the back-end implemenation in the next lab. You must work individually on this lab but make sure you start making friends with your colleagues; you are going to need to find a partner for the next lab. Good luck!

Lab Deliverables:

Again, we won't be requiring that you demonstrate your design to your supervisor. The requirements for this lab are:


Lab Description:

Jump to: Lab Files | Steps: Step 1, Step 2, Step 3, Step 4 | Hints and Tips

Lab Files:

For this part of the lab, you will not need any additional Verilog files. However, we will be performing simulations to test the fetch unit. The following zip file contains all the testbench files you will need for the lab:
cse141L-lab2-part_b.zip.

You will probably need to refer to the datapath frequently for this lab. Here is a quick link to it: datapath.pdf

Step 1: Control Implementation

Now that you have the datapath in place, add all the necessary control logic to fetch.v. To understand the semantics of each control signal, refer to the tables below. Again, part of your grade will count towards your coding style so keep your Verilog code as clean and unambiguous as possible.

Input Control Signals

The following control signals will come from the back-end of the processor.

Signal Value Semantics
restart 0 Normal execution
1 Restart execution from 'restart_addr'
load_store_valid 0 No load or store operation
1 Load or store operation.
store_en 0 load
1 store

Internal Control Signals

The following control signals are used only within the front-end.

Signal Value Semantics
sel_mux[0] 0 Branch target address (i.e. PC+SignExt(offset))
1 Next instruction (i.e. PC+1)
sel_mux[1] 0 Previously used PC
1 Output of mux0
sel_mux[2] 0 Restart address (i.e. restart_addr)
1 Output of mux1
sel_mux[3] 0 Output of mux2
1 Target address of load or store operation
ram_we 0 Read data from SRAM
1 Write data to SRAM
fifo_enqueue 0 No effect
1 Insert item into FIFO
fifo_clear 0 No effect
1 Remove all entries from the FIFO

Output Control Signals

The following signals are sent to the back-end of the processor.

Signal Value Semantics
instruction_valid 0 Data on instruction_addr and instruction_data are invalid
1 instruction_addr and instruction_data are valid
load_data_valid 0 load_data is invalid
1 load_data is valid

Step 2: Testbenches

We have provided several testbenches for you to test out the implementation of your fetch unit. They are all provided in the
cse141L-lab2-part_b.zip. You should note that the provided testbenches rely on the following assuptions: To use the given testbenches, unzip the file into your project directory and add all the TBW files to your project. Note that you will be performing post-route simulations, not behavioral simulations for your answers.

For the first set of questions (Q1 - Q6), you will need to examine the given files and understand what they are doing. Make sure you pay attention to the time period that each question specifies. You will need to get screen captures of the results of your simulations. You can limit the screen captures to the parts of the simulations that are of interest, but make sure all of the relevent signals are included and that both their names AND values are clearly visible. Failure to produce readable screenshots will result in you not getting any credit for that question.

test.tfw

First, we will be looking at the "test" testbench. Examine the "test.tfw" file and try to understand what functionality is being tested. Now, answer the following questions:

Q1 After the restart is asserted at 200ns, how long does it take for the output signal 'instruction_valid' to change. Show your answer by getting a screen capture of this event.
Q2 How many instructions will the processor back-end have received by 450ns?
Q3 How many load/store operations are executed during the simulation? Do the load/store operations interrupt the transfer of instructions to the back-end? Explain why or why not.
Q4 How many cycles does it take the output port 'load_data_valid' to change after a load operation is asserted? Grab a screen capture to show your answer.

branch.tfw

The "branch" testbench executes the following program:

	addr  instruction
	#0    nonbranch_op0
	#1    nonbranch_op1
	#2    conditional branch to #7 (predicted taken)
	#3    nonbranch_op3
	#4    nonbranch_op4
	#5    nonbranch_op5
	#6    nonbranch_op6
	#7    jump to #0

After examining the tfw file and running the simulation, answer the following questions:

Q5 How many conditional branches were executed in the testbench? How many of these were predicted correctly?
Q6 Explain how the fetch unit recovers from a misprediction. Take a screenshot of your simulation showing the fetch unit during one of the mispredictions.

Step 3: Create a new testbench

An essential skill in hardware debugging is the ability to create your own testbenches. We need you to create a test bench to test the following important situation: both 'restart' and 'load_store_valid' are simultaneously asserted while the FIFO is full. Assume that the 'dequeue' signal is asserted 2 cycles after 'restart' and 'load_store_valid' are asserted. Make sure to set the timing configuration as the figure below. To meet the setup time requirement, you should assert inputs at the negative (i.e. falling) egdes. You should submit your test bench files(*.tfw, *.tbw) with other Verilog files.

As part of your report, answer the following questions about the test bench you created:

Q7 Fully describe the scenario which you used for your testbench. Make sure you describe when signals are asserted/deasserted and explain why they are changed at those times.
Q8 Show the results of your test bench simulation by taking several screenshots. The screenshots should show all relevant events that occur during your simulation. Of particular concern are the transitions on the output signals (namely, fifo_full, instruction_valid and load_data_valid).

Step 4: Performance Evaluation

Now that we are confident that the fetch unit is operating correctly, it is time to see how we are doing with performance. As you did in Lab 1, you will evaluate performance using the Static Timing Report that is generated by Xilinx ISE. By default, a truncated report is provided to you. In order to get the detailed report, you need to change the reporting properties using the following procedure.

First, expand the "Place & Route" menu then right click on "Generate Post-Place & Route Static Timings" in order to reach the properties (see the following image).

Next, set the report type to "Verbose" and make sure that "Perform Advanced Analysis" is checked, as in the figure below.

Implement your design now and look over the static timing report that has been generated.

Q9 What is the maximum achievable frequency?. If the branch prediction is perfect, what is the maximum number of instructions your fetch unit transfers to the backend in 1 second?

Note that the "critical path" is the path through your processor with the longest delay. Decreasing the length of the critical path would allow you to increase the frequency of your processor.

Q10 Based on your timing report, describe the critical path in your fetch unit. For example, the critical path might be: load_store_addr_r -> mux3 -> sram.addr

Hints and Tips

The following information may help you with this lab.

This lab created by Donghwan Jeon, 2007. Modified by Sat Garcia, 2008.