assignment completed

Co-authored-by: SriRam Mudragada <iam-msr@users.noreply.github.com>
This commit is contained in:
karthikmurakonda 2022-10-07 15:16:05 +05:30
parent e59b707dae
commit f87bdb7500
7 changed files with 26 additions and 19 deletions

2
.vscode/launch.json vendored
View File

@ -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",

View File

@ -0,0 +1,2 @@
Number of instructions executed = 277
Number of cycles taken = 277

View File

@ -1,2 +1,2 @@
Number of instructions executed = 10
Number of cycles taken = 10
Number of instructions executed = 16
Number of cycles taken = 16

View File

@ -1,2 +1,2 @@
Number of instructions executed = 11
Number of cycles taken = 11
Number of instructions executed = 55
Number of cycles taken = 55

View File

@ -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:

View File

@ -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);

View File

@ -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) {