public void AddGate(Gate gate, IEnumerable<GateConnection> connections) { // insert before checks to allow loopback Gates.Add(gate); for (int i = 0; i < gate.InputCount; i++) InputAddrs.Add(new InputGateAddress(gate, i)); for (int i = 0; i < gate.OutputCount; i++) OutputAddrs.Add(new OutputGateAddress(gate, i)); foreach (var connection in connections) { AddConnection(connection); } TopologicalOrderImpl = null; }
public void AppendGate(Gate gate, int[] wires) { Debug.Assert(gate.InputCount == gate.OutputCount); Debug.Assert(gate.InputCount == wires.Length); ISet<GateConnection> joins = new HashSet<GateConnection>(); for (int i = 0; i < wires.Length; i++) { int wire = wires[i]; if (LastGateForWire[wire] != null) joins.Add(new GateConnection(LastGateForWire[wire], gate.GetLocalInputAddress(i))); LastGateForWire[wire] = gate.GetLocalOutputAddress(i); if (FirstGateForWire[wire] == null) FirstGateForWire[wire] = gate.GetLocalInputAddress(i); WireGateList[wire].Add(gate); } Circuit.AddGate(gate, joins); }
public void AppendGate(Gate gate, int startWire) { Debug.Assert(startWire + gate.InputCount <= WireCount); // wasteful but good enough for now int[] wires = new int[gate.InputCount]; for (int i = 0; i < gate.InputCount; i++) { wires[i] = startWire + i; } AppendGate(gate, wires); }
public void RemoveGate(Gate gate) { for (int i = 0; i < gate.InputCount; i++) { var inAddr = gate.GetLocalInputAddress(i); Debug.Assert(!InputConnectionCounterparties.ContainsKey(inAddr)); InputAddrs.Remove(inAddr); } for (int i = 0; i < gate.OutputCount; i++) { var outAddr = gate.GetLocalOutputAddress(i); Debug.Assert(!OutputConnectionCounterparties.ContainsKey(outAddr)); OutputAddrs.Remove(outAddr); } Gates.Remove(gate); }
public OutputGateAddress(Gate gate, int port) : base(gate, port) { }
public GateAddress(Gate gate, int port) { Gate = gate; Port = port; }