public Instruction(Instruction i) { InAdrA = i.InAdrA; HyAdrB = i.HyAdrB; OutAdr = i.OutAdr; Instuct = i.Instuct; }
public Instruction(int MemSize, int InputSize, int OutputSize) { InAdrA = RandomAddress(true, true, false, MemSize, InputSize, OutputSize); HyAdrB = RandomAddress(true, true, false, MemSize, InputSize, OutputSize); OutAdr = RandomAddress(true, false, true, MemSize, InputSize, OutputSize); Instuct = Calcuations.GetRandom(); }
public static MemAdr RandomAddress(bool CanBeMemory, bool CanBeInput, bool CanBeOutput, int MemSize, int InputSize, int OutputSize) { MemAdr Ve = new MemAdr(); int PossibleCombos = CountPossibleCombos(CanBeMemory, CanBeInput, CanBeOutput); ChooseTypeOfAddr(ref CanBeMemory, ref CanBeInput, ref CanBeOutput, PossibleCombos); GetAdrFromType(CanBeMemory, CanBeInput, MemSize, InputSize, OutputSize, Ve); return Ve; }
public int ConvertMemAdrToInt(MemAdr Adr, int MemSize,int InputSize) { int TBR = Adr.P; if (Adr.T == 1) { TBR += MemSize; } else if (Adr.T == 2) { TBR += MemSize + InputSize; } return TBR; }
private static void GetAdrFromType(bool CanBeMemory, bool CanBeInput, int MemSize, int InputSize, int OutputSize, MemAdr Ve) { if (CanBeMemory) { Ve.T = 0; Ve.P = BetterRandom.R.Next(MemSize); } else if (CanBeInput) { Ve.T = 1; Ve.P = BetterRandom.R.Next(InputSize); } else { Ve.T = 2; Ve.P = BetterRandom.R.Next(OutputSize); } }