You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
972 B

package processor.pipeline;
import processor.Processor;
public class InstructionFetch {
Processor containingProcessor;
IF_EnableLatchType IF_EnableLatch;
IF_OF_LatchType IF_OF_Latch;
EX_IF_LatchType EX_IF_Latch;
public InstructionFetch(Processor containingProcessor, IF_EnableLatchType iF_EnableLatch, IF_OF_LatchType iF_OF_Latch, EX_IF_LatchType eX_IF_Latch)
{
this.containingProcessor = containingProcessor;
this.IF_EnableLatch = iF_EnableLatch;
this.IF_OF_Latch = iF_OF_Latch;
this.EX_IF_Latch = eX_IF_Latch;
}
public void performIF()
{
if(IF_EnableLatch.isIF_enable())
{
int currentPC = containingProcessor.getRegisterFile().getProgramCounter();
int newInstruction = containingProcessor.getMainMemory().getWord(currentPC);
IF_OF_Latch.setInstruction(newInstruction);
containingProcessor.getRegisterFile().setProgramCounter(currentPC + 1);
IF_EnableLatch.setIF_enable(false);
IF_OF_Latch.setOF_enable(true);
}
}
}