implemented discrete event simulation in execute stage
This commit is contained in:
parent
42f0925c13
commit
e8e0b9ab4a
|
@ -1,4 +1,4 @@
|
||||||
Number of instructions executed = 7609
|
Number of instructions executed = 29
|
||||||
Number of cycles taken = 11172
|
Number of cycles taken = 1169
|
||||||
Number of data hazards = 0
|
Number of data hazards = 0
|
||||||
Number of control hazards = 176
|
Number of control hazards = 10
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Number of instructions executed = 926
|
Number of instructions executed = 277
|
||||||
Number of cycles taken = 1169
|
Number of cycles taken = 11172
|
||||||
Number of data hazards = 0
|
Number of data hazards = 0
|
||||||
Number of control hazards = 10
|
Number of control hazards = 176
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
package processor.pipeline;
|
package processor.pipeline;
|
||||||
import processor.Processor;
|
import processor.Processor;
|
||||||
|
import configuration.Configuration;
|
||||||
|
import generic.Element;
|
||||||
|
import generic.Event;
|
||||||
|
import generic.ExecutionCompleteEvent;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
|
import generic.Simulator;
|
||||||
import generic.Statistics;
|
import generic.Statistics;
|
||||||
import generic.Instruction.OperationType;
|
import generic.Instruction.OperationType;
|
||||||
import generic.Operand.OperandType;
|
import generic.Operand.OperandType;
|
||||||
|
|
||||||
public class Execute {
|
public class Execute implements Element{
|
||||||
Processor containingProcessor;
|
Processor containingProcessor;
|
||||||
OF_EX_LatchType OF_EX_Latch;
|
OF_EX_LatchType OF_EX_Latch;
|
||||||
EX_MA_LatchType EX_MA_Latch;
|
EX_MA_LatchType EX_MA_Latch;
|
||||||
|
@ -24,8 +28,34 @@ public class Execute {
|
||||||
{
|
{
|
||||||
// storing x31 here itself to not to complicate.
|
// storing x31 here itself to not to complicate.
|
||||||
// TODO:remove this later in pipeline
|
// TODO:remove this later in pipeline
|
||||||
if(OF_EX_Latch.isEX_enable())
|
if(OF_EX_Latch.isEX_enable()&& !OF_EX_Latch.isEX_busy())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
OperationType alu_op = OF_EX_Latch.getInstruction().getOperationType();
|
||||||
|
long latency = 0;
|
||||||
|
switch (alu_op) {
|
||||||
|
case mul:
|
||||||
|
case muli:
|
||||||
|
latency = Configuration.multiplier_latency;
|
||||||
|
break;
|
||||||
|
case div:
|
||||||
|
case divi:
|
||||||
|
latency = Configuration.divider_latency;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
latency = Configuration.ALU_latency;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Simulator.getEventQueue().addEvent(new ExecutionCompleteEvent(latency, this, this));
|
||||||
|
OF_EX_Latch.setEX_busy(true);
|
||||||
|
EX_MA_Latch.setMA_enable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleEvent(Event e) {
|
||||||
int op1 = OF_EX_Latch.getOp1();
|
int op1 = OF_EX_Latch.getOp1();
|
||||||
int op2 = OF_EX_Latch.getOp2();
|
int op2 = OF_EX_Latch.getOp2();
|
||||||
int imm = OF_EX_Latch.getImm();
|
int imm = OF_EX_Latch.getImm();
|
||||||
|
@ -166,7 +196,6 @@ public class Execute {
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("ALU RESULT: " + alu_result+"\n\n");
|
System.out.println("ALU RESULT: " + alu_result+"\n\n");
|
||||||
|
@ -179,6 +208,6 @@ public class Execute {
|
||||||
}else{
|
}else{
|
||||||
Statistics.setControlhazards(Statistics.getControlhazards()+2); // stall 2 cycles
|
Statistics.setControlhazards(Statistics.getControlhazards()+2); // stall 2 cycles
|
||||||
}
|
}
|
||||||
}
|
OF_EX_Latch.setEX_busy(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package processor.pipeline;
|
package processor.pipeline;
|
||||||
|
|
||||||
|
import generic.Element;
|
||||||
|
import generic.Event;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
import processor.Processor;
|
import processor.Processor;
|
||||||
import generic.Instruction.OperationType;
|
import generic.Instruction.OperationType;
|
||||||
|
|
||||||
public class MemoryAccess {
|
public class MemoryAccess implements Element {
|
||||||
Processor containingProcessor;
|
Processor containingProcessor;
|
||||||
EX_MA_LatchType EX_MA_Latch;
|
EX_MA_LatchType EX_MA_Latch;
|
||||||
MA_RW_LatchType MA_RW_Latch;
|
MA_RW_LatchType MA_RW_Latch;
|
||||||
|
@ -41,4 +43,10 @@ public class MemoryAccess {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleEvent(Event e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ public class OF_EX_LatchType {
|
||||||
boolean EX_enable;
|
boolean EX_enable;
|
||||||
Instruction instruction;
|
Instruction instruction;
|
||||||
int op1, op2, imm;
|
int op1, op2, imm;
|
||||||
|
boolean EX_busy=false;
|
||||||
|
|
||||||
public OF_EX_LatchType()
|
public OF_EX_LatchType()
|
||||||
{
|
{
|
||||||
|
@ -53,5 +54,12 @@ public class OF_EX_LatchType {
|
||||||
EX_enable = eX_enable;
|
EX_enable = eX_enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEX_busy() {
|
||||||
|
return EX_busy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEX_busy(boolean isEX_busy) {
|
||||||
|
this.EX_busy = isEX_busy;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,10 +195,14 @@ public class OperandFetch {
|
||||||
System.out.println("\n\nData Hazard - Interlock\n\n");
|
System.out.println("\n\nData Hazard - Interlock\n\n");
|
||||||
Statistics.setDatahazards(Statistics.getDatahazards() + 1);
|
Statistics.setDatahazards(Statistics.getDatahazards() + 1);
|
||||||
}
|
}
|
||||||
|
OF_EX_Latch.setEX_enable(true);
|
||||||
}
|
}
|
||||||
else if (!Proceed) {
|
else if (!Proceed) {
|
||||||
// Proceed = true;
|
// Proceed = true;
|
||||||
System.out.println("\n\nControl Hazard - Interlock\n\n");
|
OF_EX_Latch.setEX_enable(false);
|
||||||
|
// System.out.println("\n\nControl Hazard - Interlock\n\n");
|
||||||
|
}else{
|
||||||
|
OF_EX_Latch.setEX_enable(false);
|
||||||
}
|
}
|
||||||
updateQueue(addtoqueue);
|
updateQueue(addtoqueue);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue