public static List <PICCommand> LoadListFromFile(string file) { string[] lines = File.ReadAllLines(file); List <PICCommand> result = new List <PICCommand>(); foreach (string line in lines) { if (String.IsNullOrWhiteSpace(line)) { continue; } var v = splitLine(line); if (v == null) { return(null); } uint?pos = ParseHex(v.Item1); uint?cmd = ParseHex(v.Item2); uint?scpos = ParseBin(v.Item3); string txt = v.Item4; if (pos == null || cmd == null || scpos == null) { continue; } PICCommand pic_cmd = PICComandHelper.CreateCommand(txt, scpos.Value, pos.Value, cmd.Value); if (pic_cmd == null) { return(null); } result.Add(pic_cmd); } return(result); }
public static PICCommand[] LoadFromFile(string file) { List <PICCommand> list = LoadListFromFile(file); if (list == null || list.Count <= 0) { return(null); } PICCommand[] result = new PICCommand[list.Count]; for (int p = 0; p < list.Count; p++) { if (list[p].Position != p) { return(null); } result[p] = list[p]; } return(result); }
private void run() { HardReset(); while (Mode != PICControllerMode.FINISHED) { uint currCmdCycleCount = 1; //################ //# MISC # //################ Frequency.Inc(); if (GetPC() >= CommandList.Length) // PC > Commandcount { Mode = PICControllerMode.FINISHED; continue; } HandleIncomingEvents(); //################ //# DEBUGGING # //################ if (Mode == PICControllerMode.FINISHED) { continue; } if (Mode == PICControllerMode.PAUSED) { Thread.Sleep(0); // Release Control continue; } if (Mode == PICControllerMode.CONTINUE) { Mode = PICControllerMode.RUNNING; } else if (Mode == PICControllerMode.SKIPONE) { Mode = PICControllerMode.PAUSED; } else { if (breakpoints[GetPC()]) { Mode = PICControllerMode.PAUSED; continue; // Continue so the current Cmd is NOT executed } } //################ //# FETCH # //################ PICCommand cmd = CommandList[GetPC()]; UnreleasedSleep((int)SimulationSpeed); if (!IsInSleep) { //################ //# INCREMENT PC # //################ SetPC_13Bit(GetPC() + 1); //################ //# EXECUTE # //################ cmd.Execute(this); currCmdCycleCount = cmd.GetCycleCount(this); //################ //# AFTERMATH # //################ Tmr0.Update(this, currCmdCycleCount); Clocks[0].Update(this); Clocks[1].Update(this); Clocks[2].Update(this); Clocks[3].Update(this); } //################ //# OTHERS # //################ Interrupt.Update(); Cycles += currCmdCycleCount; WatchDog.Update(this, currCmdCycleCount); } Mode = PICControllerMode.WAITING; }