





























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






























1 Introduction
The performance of pipelined processors is limited by data dependencies. In order to achieve the high performance, mechanisms must exist to alleviate the effects of data dependencies. Both hardware and software solutions exist to the data dependency problem. Software solutions use code scheduling techniques (combined with a large set of registers) to increase the distance between dependent instructions and to provide interlocks. Most hardware solutions are based on Tomasulo’s algorithm. 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 introduced the concept of reservation stations where an instruction can wait for its operands and allow subsequent instructions to proceed, thereby allowing out-of-order execution. In his approach the common data bus and register tagging scheme which permits simultaneous execution independent instructions while preserving the essential precedence inherent in the instruction stream. The common data bus improves performance by efficiently utilizing the execution units without requiring specially optimized code. Presently the reservation stations form the core of a dependency-resolution mechanism that must exist in order to preserve program dependencies. In this project I implemented the two instructions per clock instruction dispatch unit which efficiently handles the data hazards due to data dependencies among different instructions and structural hazards due to limited resource. In this project I implemented the whole system in Verilog and used Mentor Graphics’ ModelSim tool to simulate it. The rest of this project report is organized as follows. The brief overview of different data dependencies and hazards are explained in section 2, and section 3 will describe the dynamic scheduling and Tomasulo’s algorithm. The top level design is described in section 4 and section 5 will go into a detailed explanation of the design, listing out signals and presenting block diagrams of individual module. Section 6 will discuss the verification methodologies and the test cases used to show the implementation met the specifications. The simulation snapshots and the Verilog code can be found in Appendix A and Appendix B respectively.
2 Concept of Dependences and Hazards
All processor since about 1985 use pipelining to overlap the execution of instructions and improve performance. The CPI(cycle per instruction) for a pipelined processor is the sum of the base CPI and all contributions from stalls.
Pipeline CPI = Ideal pipeline CPI+ Structural stalls + Data hazards stalls + Control stalls
The ideal pipeline CPI is a measure of maximum performance attainable by the implementation. By reducing each of the terms of the right-hand side, one minimizes the overall pipeline CPI.
To exploit the instruction-level parallelism one must determine which instruction can be executed in parallel. If two instructions are parallel, they can execute simultaneously in a pipeline without causing any stalls, assuming the pipeline has sufficient resources so that no structural hazards exist. If two instructions are dependent, they are not parallel and must be executed in order. So, it is very important to determine whether an instruction is dependent on another.
There are three different types of dependences: data dependences (also called true data dependences), name dependences and control dependences.
An instruction j is data dependent on instruction i if either of the following holds:
Name dependence occurs when two instructions use the same register or memory location, called a name , but there is no flow of data between the instructions associated with that name. There are two types of name dependences between an instruction i that precedes instruction j in program order:
Control dependence determines the ordering of an instruction i , with respect to a branch instruction so that the instruction i executed in correct program order and only when it should be.
In this project we are not focusing on control dependences.
3 Dynamic Scheduling using Thomasulo’s Approach
A major limitation of simple pipelining techniques is that they use in-order instruction issue and execution. Instructions are issued in program order and if an instruction is stalled in the pipeline, no later instruction can proceed. Thus if there is a dependence between two closely spaced instructions in the pipeline, this will lead to a hazard and a stall will result. If there are multiple functional units, these units could lie idle. No new instructions are fetched or issued until the dependence is cleared. It reduces the overall performance. In dynamic scheduling, the hardware rearranges the instruction execution to reduce the stalls while maintaining data flow and exception behavior. It will use in-order instruction issue but out-of-order execution (an instruction begins execution as soon as its data operands are available). All instructions pass through the issue stage in-order. However, they can be stalled or bypass in the second stage and thus enter execution out of order. Out-of-order execution introduces the possibility of WAR and WAW hazards. Dynamic scheduling offers following advantages:
Fig1: The basic structure of floating units using Thomasulo’s algorithm
The most sophisticated algorithm to allow out-of-order execution is invented by Robert Thomasulo while working for IBM in 1967. In this scheme, it tracks when operand for
instructions are available, to minimize RAW hazards, and introduces register renaming, to minimize WAW and WAR hazards by introducing the concept of reservation stations. This basis structure of a Thomasulo-based processor, including floating unit and load- store unit is shown in above figure. Each reservation station holds an instruction that has been issued and is awaiting execution at a functional unit, and either the operand values for that instruction, if they have already been computed, or else names of reservation stations that will provide the operand values.
Each instruction goes through 3 steps:
Nowadays Thomasulo’s algorithm was widely adopted in multiple-issue processors because of following advantages:
Instruction dispathch control unit
Multiplier reservation station
Instruction queue
Adder reservation station
Adder Multiplier
Registe file
Fetch reservation station
Write reservation station
Cache
Instruction line Adder line Fetch line Multiplier line
Data operands Test Bench
Dec-inst
Dec_inst
inst0 inst
Sel
Figure 2: High level design view.
In order to get maximum work done in a single clock cycle as well as to make the clock cycle as short as possible, two phased clocking is used. 3 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.
Figure 3: Two phased clocking.
Currently the design only supports 16-bits long instruction word. It has 2 arithmetic instructions such as addition and multiplication and two data transfer instruction such as load and store instructions.
The arithmetic instructions addition and multiplication have same format. The first 4 most significant bits (MSB) represents functional opcode. For addition and multiplication opcodes are 1 and 3 respectively. The next 4 bits (bit 11 down to bit 8) represent destination register id and last 8 bits for register operand 1 and operand 2. Please see the below figure and table for detail understanding.
Figure 4: Arithmetic instruction set.
Field Bits Description Opcode 15:12 Opcode for different arithmetic operation ADD:= MULT:= Result 11:8 Destination register Operand1 7:4 Source register 1 Operand2 3:0 Source register 2
Table1: Arithmetic instruction fields.
Logic A Logic B
CLK
Latch Latch
Figure 6: Dispatch unit and instruction queue interface.
The instruction dispatch control unit will get instruction from the instruction queue and dispatch instructions in order. Out of order instruction dispatch is a possibility but it will increase the hardware complexity significantly. The subsections that follow will discuss the intricacies of the control logic.
The instruction dispatch unit used the concept of 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. The carry look-ahead type logic uses up much more logic as compared to simple ripple carry adders. This design will use carry look-ahead logic when dealing with the assignment of reservation stations to minimize the delay. Since the transistors are cheap so it’s worth while to go for this approach to improve the performance.
The instruction dispatch unit to be able to allocate correct reservation stations to an instruction it must know the status of each reservation stations at least one clock before. Otherwise it can generate a race condition. Consider the case where an instruction source tag goes out to the bus and within that same clock cycle that tag is completed, the receiving reservation station must grab the data for that tag but that tag is cleared so it will produce erroneous results. 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.
The concept of data dependency and different types of hazards are explained in section 2. The RAW hazard is elegantly handled by dispatch control unit. For a RAW, 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. For example there are two instructions: Instruction 1: R1= R2+R Instruction 2: R0=R1+R Assume that initially add reservation stations A1 and A2 are empty and R2 and R3 values are in register file. The instruction dispatch control unit assigned A1 reservation station for addition operation of instruction1 with operands tag R2 and R3 which will come from the register file. Since the second instruction depends on the result of instruction 1. So instruction 2 assigned the reservation station A2 for second instruction and passed the tag of reservation station A1 as one operand and R2 for other operand which is coming from register file. 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 operand might have already been filled as soon as the register file saw that the instruction needed the R2 value for the second instruction’s source. Also, register file added the tag of reservation station A1 and A2 to R1 and R0 registers respectively which indicates this register waits for the result of A1 and A2 reservation stations. Please see the below figure for RAW example.
Figure 7: RAW example.
The reservation station is a place where a single instruction waits for sources to be ready. In this design there will be four types of reservation stations: adder reservation station, multiplier reservation station, fetch reservation station and write reservation station. The reservation stations 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 functional unit when the functional unit is ready.
There will be two adder reservation stations which will buffer two addition operations that need to be performed. The reservation station will monitor the dispatch instruction buses and if it finds an instruction for that reservation station then it stores the tags of data operands and waits for the operands. It monitors the data buses as soon as it gets the data with matching tag it loads to the data field of the reservation station. It checks the data bus for output from different functional unit such as added, multiplier, load and store and register file. In this design, there are two adder reservation stations A1 and A2. Please see the different fields of reservation stations in below figure and table.
Figure 10: Adder reservation stations.
Field Bits Description Valid 1 25 Valid bit for operand 1 Valid 2 24 Valid bit for operant 2 Source1 Tag 23:20 Tag for operand Source1 Data 19:12 Data field of operand 1 Source 2 Tag 11:8 Tag for operand Source 2 Data 7:0 Data field of operand 2
There will be two multiplier reservation stations which will buffer two multiplication operations that need to be performed. The reservation station will monitor the dispatch instruction buses and if it finds an instruction for that reservation station then it stores the tags of data operands and waits for the operands. It monitors the data buses as soon as it gets the data with matching tag it loads to the data field of the reservation station. It checks the data bus for output from different functional unit such as added, multiplier, load and store and register file. In this design, there are two multiplier reservation stations
M1 and M2. Please see the different fields of reservation stations in below figure and table.
Figure 11: Multiplier reservation stations.
Field Bits Description Valid 1 25 Valid bit for operand 1 Set as soon as operand1 is available Valid 2 24 Valid bit for operant 2 Set as soon as operand2 is available Source1 Tag 23:20 Tag for operand Source1 Data 19:12 Data field of operand 1 Source 2 Tag 11:8 Tag for operand Source 2 Data 7:0 Data field of operand 2 Table 3: Multiplier reservation station fields
There will be two fetch reservation stations which will buffer two fetch operations that need to be performed. The reservation station will monitor the dispatch instruction buses and if it finds an instruction for that reservation station then it loads memory address for fetch operation. In this design, there are two fetch reservation stations F1 and F2. For simplicity I used absolute addressing and assume that cache hit during memory fetch operation. Please see the different fields of reservation stations in below figure and brief description in given table.
Figure 12: Fetch reservation stations.
Field Bits Description Valid 16 Valid bit for operand 1 Address 15:8 Absolute memory address Data 7:0 Fetch data Table 3: Fetch reservation station fields
Arithmetic Unit
Select reservation station Source data 1 Reservation station 1
Source data 1 Reservation station 2
Source data 2 Reservation station 1
Source data 2 Reservation station 2
Results with reservation tags
Figure 14: Arithmetic unit conceptual view of reservation station inputs and result output.
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.
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.
The data transfer unit is responsible for load and store function. For simplicity we only consider the cache hit during memory access for load and store operation. The load and store operations have latency of 2 clock cycles.
There are 2 instruction buses to concurrently dispatch 2 instructions per clock by dispatch control unit. All the reservation stations are connected to this bus and monitor each instruction. There are separate data buses for broad casting the result of function units and as soon as broadcasting data tags matches with waiting data tag it loads the data required data to the corresponding reservation stations and similarly update it to the register file.
There are 4 registers in a register file R0, R1, R2 R3. The register file will keep trace of their respective tags. The register 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. The conceptual diagram of the register file is shown in below figure. The register file is in charge of assigning the correct tags to the correct registers. When the register file monitors instructions that are using the tags that are for R0, R1, R2, or R3 for source register, it will output the register tag and its value. For example, if some instruction asks for R1 register value it will be send by the register file along with tags. It also writes the tags of destination register. In below figure the R0 register is waiting for the result of adder reservation station A1. 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 15: Conceptual view of register file.
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 or two out going connection per register value and so multiple registers must wait in a FIFO order to be outputted.