Docsity

Super Scalar Dispatch Unit Using Tomasulo's Algorithm - Lecture Notes | ECE 254A, Papers of Electrical and Electronics Engineering

Partial preview of the text

Download Super Scalar Dispatch Unit Using Tomasulo's Algorithm - Lecture Notes | ECE 254A and more Papers Electrical and Electronics Engineering in PDF only on Docsity!

Super Scalar Dispatch Unit

using

Tomasulo’s Algorithm

Navraj Chohan

ECE 254A

Fall 2006

Abstract

Tomasulo’s algorithm is described and implemented in this project. The algorithm abstracts registers from actual hardware and uses tags to achieve the usage of many local memory locations. Yet it is still able to present the programmer with a set number of conceptual registers adhering to the instruction set architecture (i.e. MIPS). This project will design and implement a multiple instructions dispatch control with reservation stations for both an adding unit and a multiplying unit. Both arithmetic units will have their own designated output buses to ensure high throughput. This will be done while maintaining correctness in terms of structural hazards and data dependencies.

  • Abstract................................................................................................................................
  • Table of Figures...................................................................................................................
  • 1 Introduction.......................................................................................................................
    • 2.1 Two Phased Clocking................................................................................................
    • 2.2 Reservation Stations...................................................................................................
      • 2.2.1 Multiplier Reservation Station............................................................................
      • 2.2.2 Adder Reservation Station..................................................................................
    • 2.3 Arithmetic Units.........................................................................................................
      • 2.3.1 Adder...................................................................................................................
      • 2.3.2 Multiplier............................................................................................................
    • 2.4 Buses..........................................................................................................................
    • 2.5 Instruction Set............................................................................................................
    • 2.6 Dual Instruction Dispatch..........................................................................................
      • 2.6.1 Carry Look-Ahead Logic....................................................................................
      • 2.6.2 Reservation Station and Register Bookkeeping................................................
      • 2.6.3 Data Dependency Hazard Avoidance...............................................................
      • 2.6.4 Structural Hazard Avoidance............................................................................
    • 2.7 Instruction Queue.....................................................................................................
      • 2.7.1 Program Counter...............................................................................................
    • 2.8 Register File.............................................................................................................
      • 2.8.1 Output Queuing.................................................................................................
    • 2.9 Race Conditions.......................................................................................................
  • 3 Detailed Design...............................................................................................................
    • 3.1 Adder Reservation Stations......................................................................................
    • 3.2 Multiplier Reservation Stations...............................................................................
    • 3.3 Instruction Queue.....................................................................................................
    • 3.4 Instruction Dispatch Control....................................................................................
    • 3.5 Register File.............................................................................................................
    • 3.6 Adder Unit...............................................................................................................
    • 3.7 Multiplier Unit.........................................................................................................
    • 4.1 Reservation Stations.................................................................................................
    • 4.2 Instruction Dispatch Unit.........................................................................................
    • 4.3 Register File.............................................................................................................
    • 4.4 Adder and Multiplier................................................................................................
  • 6 Conclusion......................................................................................................................
  • Figure 1: High level design view......................................................................................... Table of Figures
  • Figure 2: Two phased clocking............................................................................................
  • Figure 3: Multiplier reservation stations..............................................................................
  • Figure 4: Adder reservation stations....................................................................................
  • Figure 5: Arithmetic unit conceptual reservation station inputs and general outputs..........
  • Figure 6: RAW example....................................................................................................
  • Figure 7: WAW example...................................................................................................
  • Figure 8: Dispatch unit and instruction queue interface....................................................
  • Figure 9: Conceptual image of register file.......................................................................
  • Figure 10: Data and tag race condition..............................................................................
  • Figure 11: RTL design of a generic reservation station.....................................................
  • Figure 12: Instruction queue RTL level description..........................................................
  • Figure 13: Instruction dispatch RTL level description......................................................
  • Figure 14: Register file RTL level description..................................................................
  • Figure 15: RTL of an adding unit......................................................................................
  • Figure 16: RTL level description of a multiplier unit........................................................
  • Figure 17: Reservation station line implementation..........................................................
  • Figure 18: Reservation station bookkeeping......................................................................
  • Figure 19: Register to tag translation internal structure.....................................................

1 Introduction

An undergraduate course in computer architecture will teach you that the CPU works in a pipelined process and those instructions are dispatched one at a time to take up their portion of the pipelined process. While this was true well over twenty years ago, it no longer is the case in industry. R. M. Tomasulo published his algorithm while working for IBM in 1967. In his article titled, “An Efficient Algorithm for Exploiting Multiple Arithmetic Units,” he showed how a scheme that used register tagging and simultaneous arithmetic execution proved to be the way to design and build microprocessors. In his proposal he has a common data bus which the arithmetic units shared. Unlike his days of where transistors were not cheap, this project design takes the approach that transistors are free, but time is not. This project will have a bus for each arithmetic unit. Each arithmetic unit will also have two reservation stations feeding it sources for computation. In the sections that follow Section 2 will discuss a top level design. Section 3 will go into a detailed explanation of the design listing out signals and presenting RTL diagrams. Section 4 will discuss the implementation details. Section 5 will discuss the testing methodologies and the test cases used to show the implementation met the specifications. The timing diagrams and the Verilog code can be found in Appendix A and Appendix B respectively.

2.1 Two Phased Clocking

In order to get as much work done in a single clock cycle as well as to make the clock cycle as short as possible, two phased clocking is used. Figure 2 shows how a single clock signal can provide two phased clocking. On the positive cycle the output from Logic B is latched, while on the negative cycle the output from Logic A is latched. Thus more work can be done in a single clock cycle versus doing single phased clocking.^1 Figure 2 : Two phased clocking.

2.2 Reservation Stations

A reservation station is a buffer where a single instruction waits for sources to be ready. In this design there will be two types of reservation stations but their functions are the same: to first read an operation on the bus designated for it, store the tags for the sources, get the data for each associated tag, and be ready to feed the data into the arithmetic unit when the arithmetic unit is ready.

2.2.1 Multiplier Reservation Station

There will be two multiplier reservation stations which will buffer operations that need to be performed. The reservation station will monitor the dispatch instruction buses, the adder bus for tags that have completed from the adder reservation stations, its own output bus for multiply tags that have completed, and the register file bus. Figure 3 shows a conceptual picture of what the reservation stations hold as well as their naming terminology as M1 and M2.

2.2.2 Adder Reservation Station

There will be two adder reservation stations which will buffer operations that need to be performed. The reservation station will monitor the dispatch instruction buses, the multiplier bus for tags that have completed from the multiplier reservation stations, its own output bus for adder tags that have completed, and the register file bus. Figure 4 shows a conceptual picture of what the adder reservation stations hold as well as their naming terminology of A1 and A2. (^1) This description was taken from the advance cache project because the same methods for fast design apply here as well. Logic A Logic A Logic BLogic B CLK Latch Latch

Figure 3 : Multiplier reservation stations. Figure 4 : Adder reservation stations.

2.3 Arithmetic Units

The arithmetic units are the pieces that do the actual calculations in the CPU. The goal of the reservation stations is to keep both units as busy as possible, having each unit crank out results to maximize throughput. Figure 5 shows the inputs and outputs both units will have. Each one will receive two sources and the source of the reservation station from both reservation stations. The reason there are four inputs for data is because there are two reservation stations in charge of feeding the arithmetic units data. The unit will pick from which ever is available first. The clear bit will indicate to the reservation station that the data was chosen and the line can be cleared for new input. The output will be twice the bit length of the input. Additionally the tag of the source reservation station will be sent out for the parties that have interest in the updated tags. These parties essentially include most of the main blocks shown in Figure 1.

2.3.1 Adder

The adder unit is directly connected to the adder reservation stations. It will wait on either A1 or A2 to signal that the data inside is ready to be calculated. As soon as the addition is completed the result along with the tag is sent out on the bus where the interested parties can read and update their information.

2.3.2 Multiplier

The multiplying unit is directly connected to the multiplier reservation stations. It will wait on either M1 or M2 to signal that the data inside is ready to be calculated. As soon as the multiplication is completed the result along with the tag is sent out on the bus where the interested parties can read and update their information. Valid Src1 Tag Src1 Data Src2 Tag Src2 Data Valid Bit Bit M M Valid Src1 Tag Src1 Data Src2 Tag Src2 Data Valid Bit Bit Valid Src1 Tag Src1 Data Src2 Tag Src2 Data Valid Bit Bit A A Valid Src1 Tag Src1 Data Src2 Tag Src2 Data Valid Bit Bit

2.6.2 Reservation Station and Register Bookkeeping

In order to designate a reservation station, both stations for a particular unit must be free for use. For the instruction dispatch unit to be able to allocate reservation stations to an instruction it must know which reservation stations are free. Therefore there must be a local structure in the control that keeps track of which tags represent which registers as well as which reservation stations are free.

2.6.3 Data Dependency Hazard Avoidance

There are two types of data dependency relations that will be dealt with in this design. Those are read after write (RAW) and write after write (WAW). The third dependency relationship is not dealt with due to the primitive logic that will reside at the register file. The register file for this project will not save state in terms of the program counter. And because there will be no control hazards in this project such as page faults or divide-by- zero, there will be no need to go back to a previous state for the register values. As for the two dependencies that will be taken care of, the logic in the dispatch unit must be wary of how reservation stations are assigned. For a RAW, we will see that the result from the first instruction is the source for the second instruction. Thus the tag assigned for the completion of the first instruction will be what is waiting in the reservation station. Take Figure 6 for example. As soon as the arithmetic unit is done computing the first addition, it will put the data value and the tag onto the bus. The waiting reservation will see the tag on the bus and fill in its source information. Additionally the other tag might have already been filled as soon as the register file saw that the instruction needed the R1 value for the second instruction’s source. We see for this example that A1 was chosen as the reservation station for the addition. The control logic in the dispatch unit knew to put tag A1 onto the bus for R0 in the second instruction. Figure 6 : RAW example. In the WAW dependency we see that the result from the first instruction is really not the register receiving the data but just the tag which will be used in the latter instruction. This shows the beauty of Tomasulo’s algorithm where the programmers view of a register is completely decoupled from the actual hardware. Figure 7 : WAW example. R0 = R1 + R R3 = R0 + R A A1 = R1 + R R3 = A1 + R A R0 = R1 + R R0 = R0 + R A A1 = R1 + R R0 = A1 + R A

2.6.4 Structural Hazard Avoidance

A structural hazard is the case where reservation stations are completely filled up for a particular operand. Take for instance the scenario where three additions are sent back-to- back. After the first two additions, both reservation stations will be fill, most likely waiting for certain tags to have the data filled in. When this happens, the hardware will do the worse thing imaginable: stall. The testing of this design will show the scenario when all the reservation stations are filled and the dispatch unit must stall and wait for a reservation station to fill up. Yet there will be the case where only one of the two instructions can be dispatched, although it will not be out of order dispatching.

2.7 Instruction Queue

The instruction queue in this design will be constant. Instructions will include an operand, a destination register, and two sources. It will be up to the dispatch unit to rename these registers as it sees fit to decouple the programmer’s view of registers from the actual hardware.

2.7.1 Program Counter

The program counter (PC) will tell the instruction queue what instruction is next to be dispatched. The PC will be a simple counter that will update according to feedback given by the dispatch logic. The dispatch logic may dispatch both, one, or none of the instructions, and thus the instruction queue’s PC must update accordingly. The response will happen every positive clock cycle. Figure 8 shows the feedback connection from a top level perspective. It should also be noted this design will not implement branches of any sort. The instructions will go straight through. Figure 8 : Dispatch unit and instruction queue interface.

Dispatch Unit PC Instruction Queue

Figure 10 : Data and tag race condition. Register File Dispatch Control Reservation Stations Adder Multiplier






Instruction Queue Reservation Stations Instruction One Instruction Two Tag M0 going out on bus for source tag Tag M0’s data sent out on same clock cycle

3 Detailed Design

This section contains a RTL level description of the units which will be implemented. Section 4 will go into the implementation details of what is shown in this section. RTL diagrams for adder reservation stations, instruction queue, instruction dispatch control, register file, adder, and multiplier are shown in this section.

3.1 Adder Reservation Stations

Figure 11 shows the inputs and outputs of a reservation station. The first set of inputs is the tag, data, and data ready of both the adder and multiplier. Because the reservation station will be waiting to fill in different tags and both multiplication and addition results apply, these connections are needed. The instructions are being watched to see when their tag is being used. Once a tag is seen on the instruction bus, the sources are put into the reservation stations. It is then the job of the reservation station to fill in those values. It is the job of the dispatch unit to know which reservation stations are being used and which are free. Another input connection comes from the register file unit. This will supply data for different tags and associate registers with tag names. The outputs of the reservation station go directly to the adder. The adder will have a chip enable bit to tell the reservation when it is done calculating and ready for new input. The reservation station can reply with a data ready bit and the source data and the associated tag. This tag is essentially put on the output bus from the adder after completion of the adding procedure. Figure 11 : RTL design of a generic reservation station.

3.2 Multiplier Reservation Stations

Figure 11 shows what a reservation station looks like. A reservation is identical for both addition reservation stations and for multiplication reservation stations. The only thing that differs is the tag name for each station. As previously stated, M0 and M1 are the designated names for the multiplier reservation stations. Reference the description of the previous subsection for information on input and output ports. Reservation Station tag_name_in add_tag_in src_1_data_out src_2_data_out src_tag_out add_data_in mul_data_in mul_tag_in instr_1_src_1_tag_in instr_1_src_2_tag_in instr_2_src_1_tag_in instr_2_src_2_tag_in reg_file_tag_in reg_file_data_in ce_in dr_out mul_dr_in add_dr_in instr_1_dr_in instr_2_dr_in reg_file_dr_in clear_in instr_1_dest_tag_in instr_2_dest_tag_in

Figure 13 : Instruction dispatch RTL level description.

3.5 Register File

The register file’s job is to ensure that the registers receiver the correct values. This includes synchronizing the output destinations of the instruction input. It must assign the registers the correct tags and output the values of the source registers that it holds. Those that are sent out on the bus are tags which could not have already been snooped upon by the reservations because they occurred on previous instructions. The register file will have to queue its output because many registers may need to be outputted from a single instruction. Figure 14 shows the RTL level description of the register file unit. Figure 14 : Register file RTL level description.

3.6 Adder Unit

The adder unit is simple in comparison to the previous units mentioned. Two values are taken in when the data is ready and the previous addition has completed. The output is the result of the addition and the tag associated with that result. The tag is the name of the Instruction Dispatch add_tag_in add_data_in mul_data_in mul_tag_in instr_1_src_1_tag_out instr_1_src_2_tag_out instr_2_src_1_tag_out reg_file_tag_in reg_file_data_in mul_dr_in add_dr_in instr_1_ce_out instr_2_ce_out reg_file_dr_in instr_2_src_2_tag_in instrq_ce_out instrq_instr_use_out instrq_instr_1_in instrq_instr_2_in instrq_dr_in instr_2_dest_reg_out instr_1_dest_reg_out instr_2_dest_tag_out instr_1_dest_tag_out Register File add_tag_in add_data_in mul_data_in mul_tag_in instr_1_src_1_tag_in instr_1_src_2_tag_in instr_2_src_1_tag_in instr_2_src_2_tag_in reg_file_tag_out reg_file_data_out mul_dr_in add_dr_in instr_1_dr_in instr_2_dr_in reg_file_ce_out instr_2_dest_tag_in instr_1_dest_tag_in instr_1_dest_reg_in instr_1_dest_reg_in

reservation station the sources were grabbed from. See Figure 15 for the RTL level description. Figure 15 : RTL of an adding unit.

3.7 Multiplier Unit

The multiplier unit is simple like the adder unit. Two values are taken in when the data is ready and the previous multiplication has completed. The output is the result of the multiplication and the tag associated with that result. The tag is the name of the reservation station the sources were grabbed from. Figure 16 : RTL level description of a multiplier unit. Adder Unit rs_1_data_1_in rs_1_data_2_in rs_1_tag_in rs_1_dr_in rs_1_ce_out data_out tag_out rs_2_data_1_in rs_2_ce_out rs_2_dr_in rs_2_data_2_in rs_2_tag_in rs_1_clear_out rs_2_clear_out Multiplier Unit rs_1_data_1_in rs_1_data_2_in rs_1_tag_in rs_1_dr_in rs_1_ce_out data_out tag_out rs_2_data_1_in rs_2_ce_out rs_2_dr_in rs_2_data_2_in rs_2_tag_in rs_1_clear_out rs_2_clear_out

Figure 18 : Reservation station bookkeeping. Figure 19 : Register to tag translation internal structure.

4.3 Register File

The register file keeps track of four different registers. For each of these registers, data and the utmost recent tag is kept. It watches the instruction input to assign the destination of an operand tag. The only noteworthy item of discussion of the register file was the fact it was the only unit using an internal queue. The queue was three spots long. This was needed for the cases where one instruction (or two) needed to output different register values onto the bus. One caveat is the case where an instruction has two source registers that were of the same register, only one data item was enqueued.

R
R
R
R

Register isBusy? 1 bit R R R R 4 bits Register Current Tag XXXX XXXX XXXX XXXX

4.4 Adder and Multiplier

The adder and the multiplier were the same unit only using different operands. An internal toggling switch was used to tell which reservation station to look at first. This was done to provide fairness in use of the reservation stations.

5 Testing

Testing took on selecting useful functions for demonstration. The units were unit tested before doing system testing. This methodology was a bottom up approach. Where the smaller units were created in full and then slowly built upon each other. The instruction queue was not implemented but was needed for driving the system. Thus the instruction queue was simulated in the testing bench. This allowed to easier test cases because the instructions were malleable.  Two phased clocking  Two instruction dispatch  RAW data dependency  WAW data dependency  Reservation station bookkeeping in instruction dispatch unit  Reservation station reuse  Correct tag assignment in register file  Queuing in register file Appendix A contains the timing diagrams that are mentioned in this testing section. These diagrams are hand annotated to point out things of interest. The testing methodologies used include analyzing waveforms as well as using the display function to print to screen. As many code paths were tested to show correct functionality.

6 Conclusion

This project has designed and implemented a super scalar dispatch unit utilizing reservation stations to maximize throughput of instruction execution. Many units must work in unison to ensure that data is coherent after instructions are executed. Although WAR was not addressed here due to a lack of a completion file, WAW and RAW were. Tomasulo’s algorithm of abstracting registers from actual registers in hardware led to the appearance of having more registers than actually on the die. By the use of tags the instructions can be ran with the use of reservation stations to essentially fill in the blanks, where the blanks are the data values of the tags. While the dispatch unit is in charge of the assigning source values tags based on the availability of reservation stations, the register file was in charge of setting the correct tags for the destinations (registers). This algorithm is clean and fast whereas the undergraduate pipelined process became complex and sloppy.