| @@ -8,7 +8,7 @@ class InstructionFetch extends MultiIOModule { | |||||
| val testHarness = IO( | val testHarness = IO( | ||||
| new Bundle { | new Bundle { | ||||
| val IMEMsetup = Input(new IMEMsetupSignals) | val IMEMsetup = Input(new IMEMsetupSignals) | ||||
| val PC = Output(UInt()) | |||||
| val PC = Output(UInt()) | |||||
| } | } | ||||
| ) | ) | ||||
| @@ -46,21 +46,11 @@ class InstructionFetch extends MultiIOModule { | |||||
| instruction := IMEM.io.instruction.asTypeOf(new Instruction) | instruction := IMEM.io.instruction.asTypeOf(new Instruction) | ||||
| /** | /** | ||||
| * Setup. | |||||
| * | |||||
| * When you have added an instruction signal to this module you | |||||
| * should ensure that it is set to NOP during program loading. | |||||
| * | |||||
| * If not you will end up issuing instructions during program load | |||||
| * which will start executing before memory, registers and programs | |||||
| * are fully loaded. | |||||
| * Setup. You should not change this code. | |||||
| */ | */ | ||||
| when(testHarness.IMEMsetup.setup) { | when(testHarness.IMEMsetup.setup) { | ||||
| PC := 0.U | PC := 0.U | ||||
| // TODO: You should probably set the instruction to Instruction.NOP here. | |||||
| // throw new Exception("Just making sure you're seeing the line above.\nYou can delete this exception now, it's found at line 64 at IF.scala") | |||||
| instruction := Instruction.NOP | |||||
| } | } | ||||
| } | } | ||||
| @@ -22,14 +22,17 @@ class Instruction extends Bundle(){ | |||||
| def immediateJType = Cat(instruction(31), instruction(19, 12), instruction(20), instruction(30, 25), instruction(24, 21), 0.U(1.W)).asSInt | def immediateJType = Cat(instruction(31), instruction(19, 12), instruction(20), instruction(30, 25), instruction(24, 21), 0.U(1.W)).asSInt | ||||
| def immediateZType = instruction(19, 15).zext | def immediateZType = instruction(19, 15).zext | ||||
| def bubble(): Instruction = { | |||||
| val bubbled = Wire(new Instruction) | |||||
| bubbled.instruction := instruction | |||||
| bubbled.instruction(6, 0) := BitPat.bitPatToUInt(BitPat("b0010011")) | |||||
| bubbled | |||||
| } | |||||
| } | } | ||||
| object Instruction { | object Instruction { | ||||
| def bubble(i: Instruction) = | |||||
| i.opcode := BitPat.bitPatToUInt(BitPat("b0010011")) | |||||
| def default: Instruction = { | |||||
| def NOP: Instruction = { | |||||
| val w = Wire(new Instruction) | val w = Wire(new Instruction) | ||||
| w.instruction := 0.U | |||||
| w.instruction := BitPat.bitPatToUInt(BitPat("b00000000000000000000000000010011")) | |||||
| w | w | ||||
| } | } | ||||
| } | } | ||||