Docsity

The Completion File Project 4 - Advanced Computer Architecture | ECE 254A, Study Guides, Projects, Research of Electrical and Electronics Engineering

Partial preview of the text

Download The Completion File Project 4 - Advanced Computer Architecture | ECE 254A and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

Project Four:

The Completion File

Navraj Chohan

ECE 254A

Fall 2006

Abstract

In the previous project Tomasulo’s algorithm was described and implemented. The algorithm abstracted registers from actual hardware and used tags to achieve the usage of many local memory locations. Yet it is still presented the programmer with a set number of conceptual registers adhering to the instruction set architecture (i.e. MIPS). This algorithm took care of RAW and WAW fundamentally through its design. But WAR was not taken care of. The previous projects implementation did not take care of WAR during hazards which could arise from page faults and floating point exceptions. When programmers received a segmentation fault the registers did not contain the correct values. This project will solve this problem by designing and implementing a completion file to go along with the super scalar implementation from the previous project. Thus when exceptions occur the programmers will be presented with the correct register values thereafter.

  • Abstract................................................................................................................................
  • Table of Figures...................................................................................................................
  • 1 Introduction.......................................................................................................................
    • 2.1 Two Phased Clocking................................................................................................
    • 2.2 Reservation Stations...................................................................................................
      • 2.2.1 Floating Point Reservation Station.....................................................................
      • 2.2.2 Adder Reservation Station..................................................................................
    • 2.3 Arithmetic Units.........................................................................................................
      • 2.3.1 Adder...................................................................................................................
      • 2.3.2 Floating Point Unit..............................................................................................
    • 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 Completion File.......................................................................................................
      • 2.8.1 Searching for Source Values.............................................................................
      • 2.8.2 Output Queuing.................................................................................................
    • 2.9 Race Conditions.......................................................................................................
  • 2.10 Cache Unit.................................................................................................................
  • 3 Detailed Design...............................................................................................................
    • 3.1 Adder Reservation Stations......................................................................................
    • 3.2 Floating Point Reservation Stations.........................................................................
    • 3.3 Instruction Queue.....................................................................................................
    • 3.4 Instruction Dispatch Control....................................................................................
    • 3.5 Completion File.......................................................................................................
    • 3.6 Adder Unit...............................................................................................................
    • 3.7 Floating Point Unit...................................................................................................
    • 4.1 Reservation Stations.................................................................................................
    • 4.2 Instruction Dispatch Unit.........................................................................................
    • 4.3 Completion File.......................................................................................................
    • 4.4 Adder and Floating Point Unit.................................................................................
  • 6 Conclusion......................................................................................................................
  • Figure 1: High level design view......................................................................................... Table of Figures
  • Figure 2: Two phased clocking............................................................................................
  • Figure 3: Floating point 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: WAR example....................................................................................................
  • Figure 9: Dispatch unit and instruction queue interface....................................................
  • Figure 10: Conceptual image of completion file...............................................................
  • Figure 11: Up to date register values.................................................................................
  • Figure 12: Exception throwing..........................................................................................
  • Figure 13: Data and tag race condition..............................................................................
  • Figure 14: RTL design of a generic reservation station.....................................................
  • Figure 15: Instruction queue RTL level description..........................................................
  • Figure 16: Instruction dispatch RTL level description......................................................
  • Figure 17: Completion file RTL level description.............................................................
  • Figure 18: RTL of an adding unit......................................................................................
  • Figure 19: RTL level description of a floating point unit..................................................
  • Figure 20: Reservation station line implementation..........................................................
  • Figure 21: Reservation station bookkeeping......................................................................
  • Figure 22: Register to tag translation internal structure.....................................................

1 Introduction

The completion file in addition to Tomasulo’s algorithm takes care of the three data dependencies RAW, WAW, and WAR, both in normal operation and during exceptions such as page faults and divide-by-zero exceptions. The design of the previous project will be modified to include the addition of the completion file. The dispatch unit will issue two instructions per clock cycle unless there is a control or structural hazard. This project will have a bus for each arithmetic unit. Each arithmetic unit will also have two reservation stations feeding it sources for computation. There will be many additional signals included for exception handling from and to the completion file. 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.

Figure 1 : High level design view.

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. (^1) This description was taken from the advance cache project because the same methods for fast design apply here as well. Completion File Dispatch Control Reservation Stations Adder Floating Point






Instruction Queue Reservation Stations Instruction One Instruction Two Cache Logic A Logic A Logic BLogic B CLK Latch Latch

2.2 Reservation Stations

The description and the functionality of the reservation stations have not changed and are not affected by the addition of a completion file. 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 Floating Point Reservation Station

There will be two floating point 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 floating point bus for tags that have completed from the floating point 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. Figure 3 : Floating point 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 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.5 Instruction Set

The instruction set consists of two arithmetic functions, addition and division (where the exception thrown will be a divide by zero) and two memory functions (store and load which can result in a page fault). The registers in the register file will be preloaded at initialization. Because there are only four operations, the operand can be represented in two bits. This design will designate zero as addition, a one as division, a two for store, and a three for load.

2.6 Dual Instruction Dispatch

The control unit will examine the instruction queue and dispatch instructions in order. Out of order instruction dispatch is a possibility but it brings with it tons of logic. The subsections that follow will discuss the intricacies of the control logic.

2.6.1 Carry Look-Ahead Logic

Logic where one unit must wait for the other to complete causes delay. This is similar to simple ripple carry adders where each bit of the adder must wait for the previous bit addition to complete. This type of logic is time consuming. Instead we use a carry look- ahead type logic where each bit knows the information of the previous units and thus can do the logic to ascertain the outcome. While the ripple carry version is slow, it has its advantage in less logic. The carry look-ahead type logic uses up much more logic, especially as the width of the procedure grows. This design will use carry look-ahead logic when dealing with the assignment of reservation stations to minimize the delay. As mentioned many times before, transistors are cheap, but time is not.

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 were two types of data dependency relations that were dealt with in the previous design. Those were read after write (RAW) and write after write (WAW). The third dependency relationship, write after read (WAR) which was not dealt with due to the primitive logic that resided at the register file will now be added. The completion file for this project will now save state in terms of the program counter. And because there will be control hazards in this project such as page faults or divide-by-zero, there will be a need to go back to a previous state for the register values. As for the two dependencies that were taken care of, the logic in the dispatch unit was wary of how reservation stations were assigned. For a RAW, the result from the first instruction was the source for the second instruction. Thus the tag assigned for the completion of the first instruction became what was waiting in the reservation station. Figure 6 shows this. As soon as the arithmetic unit was done computing the first addition, it put the data value and the tag onto the bus. The waiting reservation saw the tag on the bus and filled in its source

information. Additionally the other tag might have already been filled as soon as the register file (the primitive logic used in the previous project) saw that the instruction needed the R1 value for the second instruction’s source. In this example 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 programmer’s view of a register is completely decoupled from the actual hardware. Figure 7 : WAW example. Once a signal is received the programmers would not get the correct values from the registers during a WAR. The register file was unable to keep track of values at certain PC values. The completion file fixes this by keeping state across PC. Figure 8 shows a WAR. The register in question with this example is R2. It is first read in the first instruction and written to in the second instruction. The hazard can occur when the first instruction causes an exception. The second instruction may complete before a fully system halt can occur. Thus, when the registers are presented to the programmer after execution the R value will be the incorrect value—the second instruction. The completion file deals with this data dependency and control hazard. More on this in the section describing the completion file. Figure 8 : WAR 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 R0 = R1 + R R2 = R0 + R A A1 = R1 + R R2 = A1 + R A

2.8 Completion File

The complete file, which was formerly called the register file, will keep track of four registers: R0, R1, R2, R3, and their respective tags. Where the completion file differs from the register file is the fact that state is kept across the program counter. By doing this, when an interruption occurs in the form of an exception, the completion file can run to completion to the instruction that caused the exception and report back the correct register values. These register values are thus up to date in regard to where the exception occurred. Previously if there was to be an exception the register file would report back quasi correct values or the registers; values that were held around the instruction which caused the exception. The file must watch both instruction lines and output the necessary register values, as well as update any values after they have been shipped out by the arithmetic units. Figure 10 shows a conceptual image of what a completion file contains. The completion file, like its predecessor, the register file, is in charge of assigning the correct tags to the correct registers. When the completion file snoops instructions that are using the tags that are for R0, R1, R2, or R3, it will output the register tag and its value to the correct PC slot. As mentioned before, a source register is not necessarily a registers in hardware, but simply a name of a value which could come from several locations. Thus not all sources require the register file to output a value. Figure 10 : Conceptual image of completion file. The number of slots are finite, and therefore we must garbage collect those slots which have completed. Those up to date values are stored into a local register file. When looking up the most up to date value for a register, we search upward from a designated pointer. Because the completion file is a circular buffer, we may find ourselves searching from any of the slots upward and then down and up to the slot we started from. The figure below shows where values are stored to facilitate garbage collection of slots and for looking up register values that have been garbage collected. There is also another pointer which points to the level of completion. This pointer comes in handy when an exception is thrown. The completion file will then allow instructions to keep executing until the completion pointer points to the instruction causing the fault. The instruction field will be the field which is filled into to indicate there has been a fault. After all instructions up to the completion pointer have completed, the register values are dumped PC Instruction Dest Register Value Tag Complete bit Garbage bit Slot 1 Slot 2 Slot 3 Slot 4 Slot 5 Slot 6 Slot 7 Slot 8

and the instruction dispatch is notified of the fault as well as which instruction caused the fault via the program counter. Figure 11 : Up to date register values.

2.8.1 Searching for Source Values

The search algorithm to find the corresponding tags on a source request from the adder or floating point unit operates by searching from where the current pointer is upward until it hits the complete pointer. In the case were the complete pointer and the current pointer points to the same line, the values are taken directly from the register file. If a value for a register is not found in the structure after searching upward, the register file is referenced for the value of the register.

2.8.2 Output Queuing

If the scenario where two instructions come in and more than one source must be output a queue is used to get the necessary data out. The register value only has one out going connection per register value and so multiple registers must wait in a FIFO order to be outputted.

2.8.3 Exceptions

There are two types of exceptions that the completion file will deal with: page faults, and floating-point exceptions. A page fault occurs when the virtual address given does not mapped to real memory, or a memory violation. A floating-point exception can occur in situations where an operation tries to divide by zero, or say an operation tries to take the root square of negative one. Additionally it can be the case where the operation is legal but the numbers in the operation are too large to calculate, causing an overflow. Page faults will be dealt out by the cache unit along with a cache tag, where the floating point exceptions will come from the flowing point unit along with a reservation station tag. Figure 12 shows where the exceptions can originate from.

XXXX
XXXX
XXXX
XXXX

R R R R Register Value

Figure 13 : Data and tag race condition.

2.10 Cache Unit

The cache unit has an output bus and two cache reservation stations. This unit is in charge of interfacing with the main memory. The completion file has a direct connection to the cache unit and buffers instructions to it and also deals with page faults directly. The instruction unit learns about page faults, not from the cache unit directly, but through the completion file which waits for instructions to complete up to the instruction which caused the exception. For the second version of Tomasulo’s algorithm two additional tags were added, C0 and C1. These tags are kept by the cache unit and are output to a bus when the operation has completed. The completion file then updates its local 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, completion file, adder, cache, and floating point unit are shown in this section.

3.1 Adder Reservation Stations

Figure 14 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 floating point unit. Because the reservation station will be waiting to fill in different tags and both floating point 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 completion 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. There has been a new addition of cache tags to the unit. These tags come from the cache unit with the corresponding data. Figure 14 : RTL design of a generic reservation station.

3.2 Floating Point Reservation Stations

Figure 14 shows what a reservation station looks like. A reservation is identical for both addition reservation stations and for floating point reservation stations. The only thing Reservation Station tag_name_in add_tag_in src_1_data_out src_2_data_out src_tag_out add_data_in fp_data_in fp_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 comp_file_tag_in comp_file_data_in ce_in dr_out fp_dr_in add_dr_in instr_1_dr_in instr_2_dr_in comp_file_dr_in clear_in instr_1_dest_tag_in instr_2_dest_tag_in cache_data_in cache_tag_in cache_dr_in

instruction queue does not know a priori how many instructions will be used because it is the dispatch unit which keeps track of tags, reservation stations, and registers. Figure 16 shows the RTL level description of the instruction dispatch unit. As you can see there are many inputs, all of whom must be processed in parallel. Figure 16 : Instruction dispatch RTL level description.

3.5 Completion File

The completion file’s job is to ensure that the registers receive 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 17 shows the RTL level description of the completion file unit. Figure 17 : Completion file RTL level description. Instruction Dispatch add_tag_in add_data_in fp_data_in fp_tag_in instr_1_src_1_tag_out instr_1_src_2_tag_out instr_2_src_1_tag_out comp_file_tag_in comp_file_data_in fp_dr_in add_dr_in instr_1_ce_out instr_2_ce_out 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 comp_file_dr_in comp_file_pc_in cache_data_in cache_tag_in cache_dr_in comp_file_except_in Completion File add_tag_in add_data_in fp_data_in fp_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 comp_file_tag_out comp_file_data_out fp_dr_in add_dr_in instr_1_dr_in instr_2_dr_in comp_file_ce_out instr_2_dest_tag_in instr_1_dest_tag_in comp_file_except_out comp_file_pc_out cache_tag_in cache_data_in cache_dr_in instr_1_dest_reg_in instr_1_dest_reg_in

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 reservation station the sources were grabbed from. See Figure 18 for the RTL level description. Figure 18 : RTL of an adding 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