assignment completed
Co-authored-by: SriRam Mudragada <iam-msr@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									e59b707dae
								
							
						
					
					
						commit
						f87bdb7500
					
				| 
						 | 
				
			
			@ -9,7 +9,7 @@
 | 
			
		|||
            "name": "Launch Current File",
 | 
			
		||||
            "request": "launch",
 | 
			
		||||
            "mainClass": "${file}",
 | 
			
		||||
            "args": ["assignment-4/src/configuration/config.xml", "assignment-4/src/hello.txt", "assignment-4/supporting_files/test_cases/evenorodd.out"]
 | 
			
		||||
            "args": ["assignment-4/src/configuration/config.xml", "assignment-4/src/hello.txt", "assignment-4/supporting_files/test_cases/descending.out"]
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "type": "java",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
Number of instructions executed = 277
 | 
			
		||||
Number of cycles taken = 277
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +1,2 @@
 | 
			
		|||
Number of instructions executed = 10
 | 
			
		||||
Number of cycles taken = 10
 | 
			
		||||
Number of instructions executed = 16
 | 
			
		||||
Number of cycles taken = 16
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,2 +1,2 @@
 | 
			
		|||
Number of instructions executed = 11
 | 
			
		||||
Number of cycles taken = 11
 | 
			
		||||
Number of instructions executed = 55
 | 
			
		||||
Number of cycles taken = 55
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -100,8 +100,9 @@ public class Execute {
 | 
			
		|||
					alu_result = cur_pc + imm ;
 | 
			
		||||
					EX_IF_Latch.setIF_enable(true);
 | 
			
		||||
					
 | 
			
		||||
					EX_IF_Latch.setPC(alu_result);
 | 
			
		||||
					EX_IF_Latch.setPC(alu_result-1);
 | 
			
		||||
					noma = true;
 | 
			
		||||
					containingProcessor.getOFUnit().setProceed(false);
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
				case beq:
 | 
			
		||||
| 
						 | 
				
			
			@ -110,7 +111,7 @@ public class Execute {
 | 
			
		|||
					{
 | 
			
		||||
						EX_IF_Latch.setIF_enable(true);
 | 
			
		||||
						alu_result = cur_pc + imm;
 | 
			
		||||
						EX_IF_Latch.setPC(alu_result);
 | 
			
		||||
						EX_IF_Latch.setPC(alu_result-1);
 | 
			
		||||
						noma = true;
 | 
			
		||||
						containingProcessor.getOFUnit().setProceed(false);
 | 
			
		||||
					}
 | 
			
		||||
| 
						 | 
				
			
			@ -122,7 +123,7 @@ public class Execute {
 | 
			
		|||
					{
 | 
			
		||||
						alu_result = cur_pc + imm;
 | 
			
		||||
						EX_IF_Latch.setIF_enable(true);
 | 
			
		||||
						EX_IF_Latch.setPC(alu_result);
 | 
			
		||||
						EX_IF_Latch.setPC(alu_result-1);
 | 
			
		||||
						noma = true;
 | 
			
		||||
						containingProcessor.getOFUnit().setProceed(false);
 | 
			
		||||
					}
 | 
			
		||||
| 
						 | 
				
			
			@ -135,7 +136,7 @@ public class Execute {
 | 
			
		|||
					{
 | 
			
		||||
						alu_result = cur_pc + imm;
 | 
			
		||||
						EX_IF_Latch.setIF_enable(true);
 | 
			
		||||
						EX_IF_Latch.setPC(alu_result);
 | 
			
		||||
						EX_IF_Latch.setPC(alu_result-1);
 | 
			
		||||
						noma = true;
 | 
			
		||||
						containingProcessor.getOFUnit().setProceed(false);
 | 
			
		||||
						// System.out.println("hello world");
 | 
			
		||||
| 
						 | 
				
			
			@ -149,7 +150,7 @@ public class Execute {
 | 
			
		|||
					{
 | 
			
		||||
						alu_result = cur_pc + imm;
 | 
			
		||||
						EX_IF_Latch.setIF_enable(true);
 | 
			
		||||
						EX_IF_Latch.setPC(alu_result);
 | 
			
		||||
						EX_IF_Latch.setPC(alu_result-1);
 | 
			
		||||
						noma = true;
 | 
			
		||||
						containingProcessor.getOFUnit().setProceed(false);
 | 
			
		||||
					}
 | 
			
		||||
| 
						 | 
				
			
			@ -157,7 +158,8 @@ public class Execute {
 | 
			
		|||
				break;
 | 
			
		||||
				case end:
 | 
			
		||||
				{
 | 
			
		||||
 | 
			
		||||
					containingProcessor.getRegisterFile().setProgramCounter(containingProcessor.getRegisterFile().getProgramCounter()-1);
 | 
			
		||||
					containingProcessor.getOFUnit().setisEnd(true);
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
				default:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,11 +20,13 @@ public class InstructionFetch {
 | 
			
		|||
	public void performIF()
 | 
			
		||||
	{	if(!IF_EnableLatch.isFreeze()){
 | 
			
		||||
			if(EX_IF_Latch.isIF_enable()){
 | 
			
		||||
				containingProcessor.getRegisterFile().setProgramCounter(EX_IF_Latch.getPC());
 | 
			
		||||
				containingProcessor.getRegisterFile().setProgramCounter(EX_IF_Latch.getPC()-1);
 | 
			
		||||
				EX_IF_Latch.setIF_enable(false);
 | 
			
		||||
				IF_OF_Latch.setOF_enable(false);
 | 
			
		||||
				System.out.println("IF: PC set to " + EX_IF_Latch.getPC());
 | 
			
		||||
 | 
			
		||||
			} // if EX_IF_Latch is enabled, set PC to EX_IF_Latch's PC and wait for next cycle (1 nop)
 | 
			
		||||
			else if(IF_EnableLatch.isIF_enable())
 | 
			
		||||
			else if(IF_EnableLatch.isIF_enable() || EX_IF_Latch.isIF_enable())
 | 
			
		||||
			{
 | 
			
		||||
				int currentPC = containingProcessor.getRegisterFile().getProgramCounter();
 | 
			
		||||
				int newInstruction = containingProcessor.getMainMemory().getWord(currentPC);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -152,9 +152,6 @@ public class OperandFetch {
 | 
			
		|||
					instr.setDestinationOperand(rd);
 | 
			
		||||
					instr.setSourceOperand1(rs1);
 | 
			
		||||
				}
 | 
			
		||||
				if(opcode == 22){
 | 
			
		||||
					
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			else if (Arrays.stream(R1I_type_operators).anyMatch(x -> x == opcode)) {
 | 
			
		||||
				if(opcode != 24){
 | 
			
		||||
| 
						 | 
				
			
			@ -172,10 +169,10 @@ public class OperandFetch {
 | 
			
		|||
					// if (checkdatahazard(new int[] { rd.getValue() })) {
 | 
			
		||||
					// 	noDataHazard = false;
 | 
			
		||||
					// }else{
 | 
			
		||||
					containingProcessor.getRegisterFile().setProgramCounter(containingProcessor.getRegisterFile().getProgramCounter()-1);
 | 
			
		||||
					// containingProcessor.getRegisterFile().setProgramCounter(containingProcessor.getRegisterFile().getProgramCounter()-1);
 | 
			
		||||
					OF_EX_Latch.setInstruction(instr);
 | 
			
		||||
					OF_EX_Latch.setImm(imm);
 | 
			
		||||
					isEnd = true;
 | 
			
		||||
					// OF_EX_Latch.setImm(imm);
 | 
			
		||||
					// isEnd = true;
 | 
			
		||||
					// }
 | 
			
		||||
				}
 | 
			
		||||
				else{ // opcode == 24 jmp
 | 
			
		||||
| 
						 | 
				
			
			@ -217,6 +214,10 @@ public class OperandFetch {
 | 
			
		|||
		updateQueue(addtoqueue);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setisEnd(boolean isEnd) {
 | 
			
		||||
		this.isEnd = isEnd;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setProceed(boolean proceed) {
 | 
			
		||||
		Proceed = proceed;
 | 
			
		||||
		if (!Proceed) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue