public static Tuple<TronicSequence, List<And>> FlowBank(int MaxFlowStorage, int MinDelay, int MaxDelay) { TronicSequence ts = new TronicSequence(); List<And> stubs = new List<And>(MaxFlowStorage); DataBlock Zero = ts.NewDataBlock("Zero", "0"); DataBlock One = ts.NewDataBlock("One", "1"); int DelayDelta = MinDelay - MaxDelay/ MaxFlowStorage; if (DelayDelta < 1) { DelayDelta = 1; } for (int i = 0; i < MaxFlowStorage; i++) { DataBlock Timespan = ts.NewDataBlock("Timespan", MinDelay + i * DelayDelta + ""); TronicSequence Else = new TronicSequence(); DataBlock ElseGate = Else.NewDataBlock("Gate " + i, "1"); Else.And(Zero.In, null, ElseGate.Out) .Delay(Timespan.In) .And(One.In, null, ElseGate.Out, "Flow Bank Stub"); stubs.Add((And)Else.GetCurrent().Item1); ts.IfLTE(ElseGate.In, null, "Choice " + i, Else); } return Tuple.Create(ts, stubs); }
public static TronicSequence Ringbuffer(List<string> values) { TronicSequence ts = new TronicSequence(); DataBlock current = ts.NewDataBlock("0", values[0]); DataBlock next = ts.NewDataBlock("1", values[0]); ts.And(next.In, null, current.Out, "0"); for (int i = 1; i < values.Count; i++) { current = next; next = ts.NewDataBlock(i+1 + "", values[i]); ts.And(next.In, null, current.Out, i + ""); } ts.And(ts.data[0].In, null, next.Out, values.Count + ""); return ts; }