CSE 141L Homepage | Lab Overview | Lab Description
| Deadline: | Wednesday, April 13, 1:45pm PT (via moodle) |
| Changes: |
|
| April 9 |
|
| April 9 |
|
| April 11 |
|
| April 11 |
|
Jump to: Lab Files | Fetch Unit Specification | Datapath Implementation
svn checkout svn://parallel.ucsd.edu/fetch-unit-datapath/trunk
This will checkout the trunk directory. You can find all the necessary files with proper naming conventions in this directory. (You may need to install a svn client on your machine.)Note: You will frequently need to reference this schematic (ppt) for the lab.
The svn repo contains the following files:
| File | Description |
|---|---|
| fifo.v | The FIFO queue for the project. |
| adder.v | 2-input 32-bit adder verilog module. You must complete the implementation of this module. |
| fetch.v | Verilog module for fetch unit. You must complete the implementation of this module. |
| mux.v | Verilog module for 2-input multiplexor. You must complete the implementation of this module. |
| signext.v | Verilog module for sign extension unit. You must complete the implementation of this module. |
| ram17_1024b.v | Quartus Megawizard-generated Verilog file that describes a RAM with 1024 addresses, each containing 17 bits of data. |
| lab2a.hex | A file that specifies the contents of the RAM. Addresses 0x00 - 0x3f (i.e. 0 - 63) contain their own address (e.g. address 5 have "5" stored in it) while all other addresses (i.e. 64 - 1023) have the value "0" stored in them. |
| ram17_1024b.qip | The Quartus II IP File for the RAM module. It appears this file is only used when you map to an FPGA, but we could be wrong. |
Create a new project in Quartus II and add all the Verilog files from the zip file to it. As in lab 1, we will be targeting the Cyclone II EP2C35F672C6 FPGA for our design. Make sure the HEX and QIP files are in your project directory or Quartus might cry.
Your fetch unit must obey the specification that follows:module fetch#(parameter I_WIDTH = 17, A_WIDTH = 10, O_WIDTH = 5) ( input clk, // inputs from the exec unit input dequeue_i, input restart_i, input [A_WIDTH-1 : 0] restart_addr_i, // memory interface input load_store_valid_i, input store_en_i, input [A_WIDTH-1 : 0] load_store_addr_i, input [I_WIDTH-1 : 0] store_data_i, output [I_WIDTH-1 : 0] load_data_o, output load_data_valid_o, // ouputs to the exec unit output [I_WIDTH-1 : 0] instruction_data_o, output [A_WIDTH-1 : 0] instruction_addr_o, output instruction_valid_o );
| Q1 | Suppose that the address of the last fetched instruction (pc_r) is 0x12. If the 'P' bit of the last fetched instruction is '0', what is the address of the next fetched instruction? Assume that restart_i signal is not asserted. |
The situation described in Q1 requires the use of an adder and MUX. Implement both of these components in Verilog in their respective files (adder.v and mux.v). Make sure you use RTL Verilog.
| Q2 | What is the binary encoding of an instruction that branches to the instruction located right before the current instruction? For example, if the current instruction address is 0x25, it should branch to address 0x24. Use 'X' for don't care bits. Briefly explain how this case would be handled in the given datapath. |
As mentioned earlier, the calculating the branch target requires the sign extended version of the offset. Implement the sign extension module in signext.v so that branches can function correctly. Hint: You can duplicate a bit N times by {N{1'bx}} in verilog. For example, 5'b11111 can be briefly expressed by {5{1'b1}}. )
| Q3 | Imagine the following scenario. The back-end execution unit has found that the branch prediction in the fetch unit was wrong. How can it generate the correct address for the fetch unit? If the execution unit sent restart_i and restart_addr_i at cycle 10, what is the earliest cycle in which the execution unit can start executing at the correct address? Explain. |
| Q4 | Examine the datapath. Notice that pc_r can be used for the PC and can be fed to the SRAM. Considering that pc_r contains the last fetched PC, it seems odd to use the same address in two consecutive cycles. Explain why this path is needed. |
| Q5 | Envision the following scenario.
|
You should now be ready to implement your fetch unit in Verilog (fetch.v). In doing so, you should follow these simple guidelines:
| Q6 | Given that you have not implemented control signals yet, why might it make sense to ignore the resource utilization and frequency numbers that Quartus reports? |
| Q7 | Click Here For This Part of the Lab. |
Good luck!