public void SelectAlternateExecutionTimings() { ExecutionTimings = ParametersVariant.AlternateExecutionTimings; }
private static void CheckTimings(string instrIds, InstructionExecutionVariant instructionExecutionVariant) { int tstates = 0; for (int mcycle = 1; mcycle <= instructionExecutionVariant.MachineCyclesCount; mcycle++) { tstates += instructionExecutionVariant.MachineCycles[mcycle - 1].TStates; // Check machine cycle types // 1. OCF or IN is mandatory for cycle 1 if (mcycle == 1 && instructionExecutionVariant.MachineCycles[mcycle - 1].Type != MachineCycleType.OCF) { throw new Exception("Instruction does not start with OCF " + instrIds); } // 2. OCF is forbidden after cycle 2 unless in case of four bytes opcodes if (mcycle > 2 && instructionExecutionVariant.MachineCycles[mcycle - 1].Type == MachineCycleType.OCF && (mcycle != 4 || instructionExecutionVariant.MachineCycles[mcycle - 2].Type != MachineCycleType.OD)) { throw new Exception("Too many OCF in instruction " + instrIds); } // 3. ODL is always followed by ODH if (instructionExecutionVariant.MachineCycles[mcycle - 1].Type == MachineCycleType.ODL && instructionExecutionVariant.MachineCycles[mcycle].Type != MachineCycleType.ODH) { throw new Exception("ODL is always followed by ODH " + instrIds); } // 4. MWL is always followed by MWH if (instructionExecutionVariant.MachineCycles[mcycle - 1].Type == MachineCycleType.MWL && instructionExecutionVariant.MachineCycles[mcycle].Type != MachineCycleType.MWH) { throw new Exception("MWL is always followed by MWH " + instrIds); } // 5. MRL is always followed by MRH if (instructionExecutionVariant.MachineCycles[mcycle - 1].Type == MachineCycleType.MRL && instructionExecutionVariant.MachineCycles[mcycle].Type != MachineCycleType.MRH) { throw new Exception("MRL is always followed by MRH " + instrIds); } // 6. SWH is always followed by SWL if (instructionExecutionVariant.MachineCycles[mcycle - 1].Type == MachineCycleType.SWH && instructionExecutionVariant.MachineCycles[mcycle].Type != MachineCycleType.SWL) { throw new Exception("SWH is always followed by SWL " + instrIds); } // 7. SRL is always followed by SRH if (instructionExecutionVariant.MachineCycles[mcycle - 1].Type == MachineCycleType.SRL && instructionExecutionVariant.MachineCycles[mcycle].Type != MachineCycleType.SRH) { throw new Exception("SRL is always followed by SRH " + instrIds); } // 8. Check minimum duration if ((instructionExecutionVariant.MachineCycles[mcycle - 1].Type == MachineCycleType.OCF || instructionExecutionVariant.MachineCycles[mcycle - 1].Type == MachineCycleType.PR || instructionExecutionVariant.MachineCycles[mcycle - 1].Type == MachineCycleType.PW) && instructionExecutionVariant.MachineCycles[mcycle - 1].TStates < 4) { throw new Exception("OCF,PR,PW must last at least 4 Tstates " + instrIds); } else if (instructionExecutionVariant.MachineCycles[mcycle - 1].TStates < 3) { throw new Exception("Machine cycles must last at least 4 Tstates " + instrIds); } else if (instructionExecutionVariant.MachineCycles[mcycle - 1].TStates > 6) { throw new Exception("Machine cycles can last at most 6 Tstates " + instrIds); } } if (tstates != instructionExecutionVariant.TStatesCount) { throw new Exception("Problem of timings with instruction " + instrIds); } }
public Instruction(int instructionTypeIndex, int instructionTypeParamVariant) { Type = Z80InstructionTypes.Table[instructionTypeIndex]; ParametersVariant = Type.ParametersVariants[instructionTypeParamVariant]; ExecutionTimings = ParametersVariant.ExecutionTimings; }