Example #1
0
        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;
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
 public OutputGateAddress(Gate gate, int port)
     : base(gate, port)
 {
 }
Example #6
0
 public GateAddress(Gate gate, int port)
 {
     Gate = gate;
     Port = port;
 }
Example #7
0
 public OutputGateAddress(Gate gate, int port)
     : base(gate, port)
 {
 }
Example #8
0
 public GateAddress(Gate gate, int port)
 {
     Gate = gate;
     Port = port;
 }