final submission
This commit is contained in:
		
							parent
							
								
									b06e33f8de
								
							
						
					
					
						commit
						c25175fceb
					
				
										
											Binary file not shown.
										
									
								
							|  | @ -48,7 +48,7 @@ public class Processor { | ||||||
| 		OFUnit = new OperandFetch(this, IF_OF_Latch, OF_EX_Latch, IF_EnableLatch); | 		OFUnit = new OperandFetch(this, IF_OF_Latch, OF_EX_Latch, IF_EnableLatch); | ||||||
| 		EXUnit = new Execute(this, OF_EX_Latch, EX_MA_Latch, EX_IF_Latch); | 		EXUnit = new Execute(this, OF_EX_Latch, EX_MA_Latch, EX_IF_Latch); | ||||||
| 		MAUnit = new MemoryAccess(this, EX_MA_Latch, MA_RW_Latch); | 		MAUnit = new MemoryAccess(this, EX_MA_Latch, MA_RW_Latch); | ||||||
| 		RWUnit = new RegisterWrite(this, MA_RW_Latch, IF_EnableLatch); | 		RWUnit = new RegisterWrite(this, MA_RW_Latch, IF_EnableLatch, EX_MA_Latch); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public void printState(int memoryStartingAddress, int memoryEndingAddress) | 	public void printState(int memoryStartingAddress, int memoryEndingAddress) | ||||||
|  |  | ||||||
|  | @ -26,8 +26,6 @@ public class Execute implements Element{ | ||||||
| 	 | 	 | ||||||
| 	public void performEX() | 	public void performEX() | ||||||
| 	{ | 	{ | ||||||
| 		// storing x31 here itself to not to complicate. |  | ||||||
| 		// TODO:remove this later in pipeline |  | ||||||
| 		if(OF_EX_Latch.isEX_enable()&& !OF_EX_Latch.isEX_busy()) | 		if(OF_EX_Latch.isEX_enable()&& !OF_EX_Latch.isEX_busy()) | ||||||
| 		{ | 		{ | ||||||
| 
 | 
 | ||||||
|  | @ -74,7 +72,6 @@ public class Execute implements Element{ | ||||||
| 		OperationType alu_op = OF_EX_Latch.getInstruction().getOperationType(); | 		OperationType alu_op = OF_EX_Latch.getInstruction().getOperationType(); | ||||||
| 		System.out.println("ALU OP: " + alu_op); | 		System.out.println("ALU OP: " + alu_op); | ||||||
| 		boolean noma = false; | 		boolean noma = false; | ||||||
| 		Statistics.setNumberOfInstructions(Statistics.getNumberOfInstructions() + 1); |  | ||||||
| 		switch(alu_op) | 		switch(alu_op) | ||||||
| 		{ | 		{ | ||||||
| 			case add: alu_result = op1 + op2; break; | 			case add: alu_result = op1 + op2; break; | ||||||
|  | @ -178,9 +175,7 @@ public class Execute implements Element{ | ||||||
| 					EX_IF_Latch.setPC(alu_result-1); | 					EX_IF_Latch.setPC(alu_result-1); | ||||||
| 					noma = true; | 					noma = true; | ||||||
| 					containingProcessor.getOFUnit().setProceed(false); | 					containingProcessor.getOFUnit().setProceed(false); | ||||||
| 					// System.out.println("hello world"); |  | ||||||
| 				} | 				} | ||||||
| 				// System.out.println("hello world2"); |  | ||||||
| 			} | 			} | ||||||
| 			break; | 			break; | ||||||
| 			case bgt: | 			case bgt: | ||||||
|  | @ -197,7 +192,6 @@ public class Execute implements Element{ | ||||||
| 			break; | 			break; | ||||||
| 			case end: | 			case end: | ||||||
| 			{ | 			{ | ||||||
| 				// containingProcessor.getRegisterFile().setProgramCounter(containingProcessor.getRegisterFile().getProgramCounter()-1); |  | ||||||
| 				containingProcessor.getOFUnit().setisEnd(true); | 				containingProcessor.getOFUnit().setisEnd(true); | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -6,6 +6,7 @@ import generic.Event; | ||||||
| import generic.MemoryReadEvent; | import generic.MemoryReadEvent; | ||||||
| import generic.MemoryResponseEvent; | import generic.MemoryResponseEvent; | ||||||
| import generic.Simulator; | import generic.Simulator; | ||||||
|  | import generic.Statistics; | ||||||
| import processor.Clock; | import processor.Clock; | ||||||
| import processor.Processor; | import processor.Processor; | ||||||
| 
 | 
 | ||||||
|  | @ -54,9 +55,6 @@ public class InstructionFetch implements Element{ | ||||||
| 						return; | 						return; | ||||||
| 					} | 					} | ||||||
| 					int currentPC = containingProcessor.getRegisterFile().getProgramCounter(); | 					int currentPC = containingProcessor.getRegisterFile().getProgramCounter(); | ||||||
| 					// int newInstruction = containingProcessor.getMainMemory().getWord(currentPC); |  | ||||||
| 					// IF_OF_Latch.setInstruction(newInstruction); |  | ||||||
| 					// containingProcessor.getRegisterFile().setProgramCounter(currentPC + 1); |  | ||||||
| 					 | 					 | ||||||
| 					Simulator.getEventQueue().addEvent( | 					Simulator.getEventQueue().addEvent( | ||||||
| 						new MemoryReadEvent( | 						new MemoryReadEvent( | ||||||
|  | @ -93,6 +91,7 @@ public class InstructionFetch implements Element{ | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		MemoryResponseEvent event = (MemoryResponseEvent) e; | 		MemoryResponseEvent event = (MemoryResponseEvent) e; | ||||||
|  | 		Statistics.setNumberOfInstructions(Statistics.getNumberOfInstructions()+1); | ||||||
| 		IF_OF_Latch.setInstruction(event.getValue()); | 		IF_OF_Latch.setInstruction(event.getValue()); | ||||||
| 		containingProcessor.getRegisterFile().setProgramCounter(containingProcessor.getRegisterFile().getProgramCounter() + 1); | 		containingProcessor.getRegisterFile().setProgramCounter(containingProcessor.getRegisterFile().getProgramCounter() + 1); | ||||||
| 		IF_OF_Latch.setOF_enable(true); | 		IF_OF_Latch.setOF_enable(true); | ||||||
|  |  | ||||||
|  | @ -39,7 +39,6 @@ public class MemoryAccess implements Element { | ||||||
| 			{ | 			{ | ||||||
| 				int val_store = containingProcessor.getRegisterFile().getValue( | 				int val_store = containingProcessor.getRegisterFile().getValue( | ||||||
| 				instruction.getSourceOperand1().getValue()); | 				instruction.getSourceOperand1().getValue()); | ||||||
| 				// containingProcessor.getMainMemory().setWord(alu_result, val_store); |  | ||||||
| 				Simulator.getEventQueue().addEvent( | 				Simulator.getEventQueue().addEvent( | ||||||
| 					new MemoryWriteEvent( | 					new MemoryWriteEvent( | ||||||
| 						Clock.getCurrentTime()+Configuration.mainMemoryLatency, | 						Clock.getCurrentTime()+Configuration.mainMemoryLatency, | ||||||
|  | @ -54,7 +53,6 @@ public class MemoryAccess implements Element { | ||||||
| 			} | 			} | ||||||
| 			else if (op_type==OperationType.load) | 			else if (op_type==OperationType.load) | ||||||
| 			{ | 			{ | ||||||
| 				// int load_result = containingProcessor.getMainMemory().getWord(alu_result); |  | ||||||
| 				Simulator.getEventQueue().addEvent( | 				Simulator.getEventQueue().addEvent( | ||||||
| 					new MemoryReadEvent( | 					new MemoryReadEvent( | ||||||
| 						Clock.getCurrentTime()+Configuration.mainMemoryLatency, | 						Clock.getCurrentTime()+Configuration.mainMemoryLatency, | ||||||
|  | @ -72,17 +70,13 @@ public class MemoryAccess implements Element { | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public void handleEvent(Event e) { | 	public void handleEvent(Event e) { | ||||||
| 		// TODO Auto-generated method stub |  | ||||||
| 		if(e instanceof ExecutionCompleteEvent) { | 		if(e instanceof ExecutionCompleteEvent) { | ||||||
| 			// MemoryResponseEvent event = (MemoryResponseEvent) e; |  | ||||||
| 			// MA_RW_Latch.setLoad_result(event.getValue()); |  | ||||||
| 			EX_MA_Latch.setMA_busy(false); | 			EX_MA_Latch.setMA_busy(false); | ||||||
| 			MA_RW_Latch.setRW_enable(true); | 			MA_RW_Latch.setRW_enable(true); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 		MemoryResponseEvent event=(MemoryResponseEvent) e; | 		MemoryResponseEvent event=(MemoryResponseEvent) e; | ||||||
| 		MA_RW_Latch.setLoad_result(event.getValue()); | 		MA_RW_Latch.setLoad_result(event.getValue()); | ||||||
| 		EX_MA_Latch.setMA_busy(false); |  | ||||||
| 		MA_RW_Latch.setRW_enable(true); | 		MA_RW_Latch.setRW_enable(true); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -33,7 +33,8 @@ public class OperandFetch { | ||||||
| 		queue.add(-1); | 		queue.add(-1); | ||||||
| 		queue.add(-1); | 		queue.add(-1); | ||||||
| 		queue.add(-1); | 		queue.add(-1); | ||||||
| 		// queue.add(-1); | 		queue.add(-1); | ||||||
|  | 		queue.add(-1); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	boolean checkdatahazard(int[] operands) { | 	boolean checkdatahazard(int[] operands) { | ||||||
|  | @ -200,21 +201,16 @@ public class OperandFetch { | ||||||
| 			OF_EX_Latch.setEX_enable(noDataHazard); | 			OF_EX_Latch.setEX_enable(noDataHazard); | ||||||
| 			if(!noDataHazard){ | 			if(!noDataHazard){ | ||||||
| 				IF_EnableLatch.setFreeze(true); | 				IF_EnableLatch.setFreeze(true); | ||||||
| 				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); | 
 | ||||||
| 			updateQueue(addtoqueue); | 			updateQueue(addtoqueue); | ||||||
| 		} | 		} | ||||||
| 		else if (!Proceed) { | 		else if (!Proceed) { | ||||||
| 			// Proceed = true; |  | ||||||
| 			// updateQueue(addtoqueue); |  | ||||||
| 			OF_EX_Latch.setEX_enable(false); | 			OF_EX_Latch.setEX_enable(false); | ||||||
| 			// System.out.println("\n\nControl Hazard - Interlock\n\n"); |  | ||||||
| 		}else{ | 		}else{ | ||||||
| 			OF_EX_Latch.setEX_enable(false); | 			OF_EX_Latch.setEX_enable(false); | ||||||
| 		} | 		} | ||||||
| 		// updateQueue(addtoqueue); |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public void setisEnd(boolean isEnd) { | 	public void setisEnd(boolean isEnd) { | ||||||
|  |  | ||||||
|  | @ -9,12 +9,14 @@ public class RegisterWrite { | ||||||
| 	Processor containingProcessor; | 	Processor containingProcessor; | ||||||
| 	MA_RW_LatchType MA_RW_Latch; | 	MA_RW_LatchType MA_RW_Latch; | ||||||
| 	IF_EnableLatchType IF_EnableLatch; | 	IF_EnableLatchType IF_EnableLatch; | ||||||
|  | 	EX_MA_LatchType EX_MA_Latch; | ||||||
| 	 | 	 | ||||||
| 	public RegisterWrite(Processor containingProcessor, MA_RW_LatchType mA_RW_Latch, IF_EnableLatchType iF_EnableLatch) | 	public RegisterWrite(Processor containingProcessor, MA_RW_LatchType mA_RW_Latch, IF_EnableLatchType iF_EnableLatch, EX_MA_LatchType eX_MA_Latch) | ||||||
| 	{ | 	{ | ||||||
| 		this.containingProcessor = containingProcessor; | 		this.containingProcessor = containingProcessor; | ||||||
| 		this.MA_RW_Latch = mA_RW_Latch; | 		this.MA_RW_Latch = mA_RW_Latch; | ||||||
| 		this.IF_EnableLatch = iF_EnableLatch; | 		this.IF_EnableLatch = iF_EnableLatch; | ||||||
|  | 		this.EX_MA_Latch = eX_MA_Latch; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public void performRW() | 	public void performRW() | ||||||
|  | @ -27,6 +29,7 @@ public class RegisterWrite { | ||||||
| 			boolean proceed = true; | 			boolean proceed = true; | ||||||
| 			if (op_type==OperationType.load) | 			if (op_type==OperationType.load) | ||||||
| 			{ | 			{ | ||||||
|  | 				EX_MA_Latch.setMA_busy(false); | ||||||
| 				int load_result = MA_RW_Latch.getLoad_result(); | 				int load_result = MA_RW_Latch.getLoad_result(); | ||||||
| 				int rd = instruction.getDestinationOperand().getValue(); | 				int rd = instruction.getDestinationOperand().getValue(); | ||||||
| 				containingProcessor.getRegisterFile().setValue(rd, load_result); | 				containingProcessor.getRegisterFile().setValue(rd, load_result); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 karthikmurakonda
						karthikmurakonda