CSE141L Lab 3, Part A: Backend Datapath


CSE 141L Homepage | Lab Overview | Lab Description


Deadline: Wednesday May 4th, 1:45pm PT (via moodle)
Changes:
  1. None.

Lab Overview:

Congratulations on finishing up your fetch unit. By now you should have either designed your own ISA (if you are currently enrolled in 141) or leased an ISA design from one of the 141 teams. Time is short so to speed-up the process of implementing your processor, you will now be working with a partner of your choosing. In order to set your processor apart, you should come up with a unique "codename" for it.

While things are looking good now, there is still a lot of work left to be done. Namely, you need to implement the back-end (execution unit) of your processor. We are going to follow a similar path as we did for the front-end; we are first going to design the datapath first (part A), then implement control (part B). Finally, you will do a lot of debugging (to make sure that our customers don't end up with faulty chips) and optimize/evaluate (lab 4). You'll also likely need to go back and change a few things in your front-end now that you have a target ISA. You may also find a few deficiencies in your ISA and will need to properly address them. Based on your previous performance, we know you can accomplish this monumental task though. Good luck!

Lab Deliverables:

For part A of this lab, you will need to create the datapath for your execution unit. Much like you did with your fetch unit, you will need to identify the major components of your datapath and implement them using RTL Verilog. You will then tie them all together using structural Verilog to get your completed datapath. Similar to labs 1 and 2, there are several questions that you need to answer in your report. Please make sure that you answer all of them. For this lab and from now on, you will be working with your partner. Since you each completed the fetch unit individually, it is up to you to decide who's fetch unit you will use. Again, there will be no interview for this part of the lab.

You will need to turn in an electronic copy by the deadline via moodle. Once again, the answers to the questions should be in a PDF file. The Verilog files (as well as your PDF) should be included in a ZIP file with the following name convention: cse141L-lab3-part_a-lastname1-firstname1-AND-lastname2-firstname2.zip. (The name of the PDF should be the same, except with the "pdf" extension instead of "zip".)


Lab Description:

Jump to: Processor Overview | Core Interface | Front End, Revisted | The BackEnd | Datapath Questions | Coding & Implementation

Processor Overview: The "Big Picture"

In lab 2, we gave you the datapath design for your fetch unit. In this lab, you will be developing the execution unit's (i.e. the backend's) datapath on your own. Your guide will be your ISA, which will dictate which components you need to add to your datapath. Because we have split up the front-end and back-end of your processor, your processor will have at least 2 pipeline stages. You may choose how deeply to pipeline your backend, if at all. Just remember that there will be fabulous awards given to those with excellent designs and performance to get creative in designing your backend. Don't make it too complex though, as you don't have a lot of time to complete it.

The Processor Core Interface

The processor core is the top module of your processor design. It should instantiate two modules: your fetch unit and your execution unit. It should haves the following interface:

 
// D_WIDTH  : data width
// PA_WIDTH : port (i.e. IO channel) address width
 
module core#(parameter D_WIDTH = 34, PA_WIDTH = 4)
(
    input  clk,
    input  reset_i,
    
    // I/O interface
    input  [D_WIDTH-1 : 0]  in_data_i,
    input  in_ack_i,
    input  out_ack_i
    output in_req_o,
    output out_req_o,
    output [PA_WIDTH-1 : 0] in_addr_o,
    output [PA_WIDTH-1 : 0] out_addr_o,
    output [D_WIDTH-1 : 0]  out_data_o,
); 

The core interface is simple - it consists of clk, synchronous reset_i, and I/O interface. When the reset_i signal transitions from high to low, the processor core starts executing from address 0x0 of the instruction memory. The I/O interface provides the interface for in and out instructions, which communicate to the outside world. Since the available pins are usually very limited, the I/O interface multiplexes 16 channels into one physical channel to save the pincount. All I/O interface signals are edge-triggered.

The I/O interface is similar to a conventional bus interface. The 'in' instruction asserts in_req_o and in_addr_o, then waits for in_ack_i to become 1. If in_ack_i arrives, the backend stores in_data_i into the register the 'in' instruction specifies. In the best case, the in_ack_i signal will arrive in the next cycle, but it can be arbitrarily delayed if no data is available in the specified channel. In the waveform example below, the core asserts in_req_o with in_addr_o to 0xF. The core spends two idle cycles, then it stores 0x123 to the register file when in_ack_i signal arrives.

The 'out' instruction works in a similar way, but the backend also asserts out_data_o along with out_req_o and out_addr_o. After asserting a request, the backend waits for out_ack_i. Like in_ack_i, out_ack_i could arrive after an arbitrarily long delay, signaling the completion of a request. In the waveform example below, the core asserts out_req_o with out_addr_o to 0xF and out_data_o to 0x123, then waits for out_ack_i. When the out_ack_i signal is asserted after one cycle, the core completes the out instruction.

The Frontend (Fetch Unit) Revisited

You already have a baseline frontend implementation, which allows the fetch unit to work independently of the backend. However, you may find that you need to modify existing fetch unit so that it can be well matched to your ISA.

Q1 Review your fetch unit and update it if you need to. If you make any changes, explain them and why they were needed.

The Backend

The backend of your processor if where execution of instructions occurs. The datapath should be defined structurally, i.e. it should simply consist of instantiations of modules. One of the tasks of this part of the lab is to create these modules using RTL verilog (and the "MegaWizard" Plug-In).

The following is a list of the major modules that you will need to implement in your execution unit.

Q2 List all the other leaf modules needed for the backend of your processor. For each module, list all the instructions that use the module.

The Backend Interface

The backend of your processor should use an interface that is similar (if not identical) to the following:

 
// I_WIDTH  : instruction width
// IA_WIDTH : instruction address width
// D_WIDTH  : data width
// PA_WIDTH : port address width
 
module backend#(parameter I_WIDTH = 17, IA_WIDTH = 12, D_WIDTH = 34, PA_WIDTH = 4)
(
    input  clk,
    input  reset_i,
    
    // inputs from the fetch unit
    input  [I_WIDTH-1 : 0]  instruction_data_i,
    input  [IA_WIDTH-1 : 0] instruction_addr_i,
    input  instruction_valid_i,    
    input  [I_WIDTH-1 : 0]  load_data_i,
    input  load_data_valid_i,
    
    // outputs to the fetch unit
    output dequeue_o,
    output restart_o,
    output [IA_WIDTH-1 : 0] restart_addr_o,
    output load_store_valid_o,
    output store_en_o,
    output [IA_WIDTH-1 : 0] load_store_addr_o,
    output [I_WIDTH-1 : 0]  store_data_o,
    
    // I/O interface
    output in_req_o,
    output out_req_o,
    output [PA_WIDTH-1 : 0] in_addr_o,
    output [PA_WIDTH-1 : 0] out_addr_o,
    input  [D_WIDTH-1 : 0]  in_data_i,
    output [D_WIDTH-1 : 0]  out_data_o,
    input  in_ack_i,
    input  out_ack_i
); 

Datapath Design

Now that you have identified all the major components needed for the backend datapath, the next step is to design a datapath consisting of those modules you have identified. Make sure that your datapath can handle all the instructions of your ISA. Answer the following questions about the design of your datapath:

Using a whiteboard, or some sketch paper, examine each instruction, one by one, and augment your datapath if necessary so that it can handle all of your instructions, just like we did for the single-cycle CPU in 141. In many cases, only a small amount of hardware needs to be added to the existing design to support the additional instruction. After your design has stabilized, then you will want to create a schematic that you can use to communicate your design, and that you can draw on when you figure out the control logic. (Note: Powerpoint or other user-friendly drawing tools are fine. Schematic entries tools are often not worth the trouble, unless they allow you to exactly specify the placement of wires.)

Q3 Draw the datapath schematic of the backend, doing your best to mimic the style used in Lab 2's datapath.pdf. Annotate all the relevant control signals as you saw in the fetch unit datapath schematic. Include the datapath schematic in your report.

Example Q & A

For Q4 and Q5, answer questions in the same style used in the following example.

Question: What happens when restart_o and restart_addr_o is asserted? Assume that load_store_valid_o is not asserted.
Answer: Assume that restart_o and restart_addr_o are asserted in cycle 0.


The schematic is available here:
example answer schematic

Q4 How does your processor handle the following situations?
  1. reset_i is asserted
  2. An execution of an instruction takes multiple cycles (e.g. the execution of the 'in' instruction can take arbitrarily long time when input data is unavailable.)
  3. The refused_o signal of the memory module is asserted.
Note: Each of these is a distinct situation. You should three different explanations (1 for each scenario), not one explanation of a scenario where all three of these things happen at the same time.

Draw a path on your frontend and backend datapaths and explain on a cycle-by-cycle basis. Follow the explanation style of the example above.
Q5 For each instruction in your ISA, make a copy of your backend datapath and draw a path in the backend datapath which shows how the instruction is handled, label the settings of the control signals, and give an explanation on a cycle-by-cycle basis. You can group instructions into one drawing if they share the same datapath (e.g. add, sub, and xor will likely all be the same). Again, use the answer style used in the example above. Hint: make sure your datapath has stabilized before you start doing this!

Coding & Implementation

Now that you have the datapath design, let's start implementing the datapath. You need to implement the following things:

  1. Major components of the backend such as a register file and a data memory
  2. A backend consisting of various leaf modules
  3. A processor core consisting of a frontend and a backend. As you did in lab 2, you can use RTL Verilog for the implementation of leaf modules. However, you must use structural Verilog for the implementation of the backend and the processor core.
Q6 Implement changes to your register file from Lab 1 to make it compatible with your execution unit. You will not necessarily need to change anything. Describe what changes, if any, you needed to make.

Unlike for the register file, it is better to use a highly optimized memory generator for the data memory module rather than writing your own data memory module. Fortunately, Altra provides a utility named MegaWizard for such a purpose. Generate a data memory module that has 8K 34-bit words and name is 'dmem_34_8k'. You can follow the step-by-step instructions to do it.

Q7 Write a testbench for your memory module, making sure that you use the provided memory module wrapper (dmem.v). Use modelsim to do a behavioral simulation and capture the results of this simulation using one or more screenshots. Include these screenshots in your report. In your report, thoroughly explain both the setup of the testbench the results screenshot(s). The captured screenshot(s) should clearly show that read and write operations work correctly.

For the following questions, you do not need to provide any writeup in your lab. Simply include all the .v files in the zip that you turn in.

Q8 Implement all the other modules required in your datapath. You have to implement each module in a separate .v file with RTL Verilog as you did for modules like adders, muxes, and sign extenders in lab 1. You might find that you can reuse many leaf modules used in the fetch unit.
Q9 Implement backend.v in structural Verilog for the backend of the processor. You do not need to implement the control for the backend in this part of the lab. Since it is hard to test an implementation without control logic, it is enough to show that your Verilog file is synthesizable and implementable.
Q10 Implement core.v as the top module of the your processor design. You can simply wire up the fetch unit and the backend. No control logic is required for core.v.

This lab created by Donghwan Jeon, 2007. Modified by Sat Garcia, 2008. Modified by Arash Arfaee, 2010. Modified by Vikram and Sat, 2011