示例#1
0
        public LogicSystem(JsonNetlist tnetlist)
        {
            List <LogicDevice> ttnetlist = new List <LogicDevice>();

            for (int tnetlistIndex = 0; tnetlistIndex < tnetlist.LogicDevices.Count; tnetlistIndex++)
            {
                LogicDevice dev = new LogicDevice();
                dev = tnetlist.LogicDevices[tnetlistIndex];
                String[] portNames = new String[dev.Ports.Count];
                for (int ports = 0; ports < dev.Ports.Count; ports++)
                {
                    portNames[ports] = dev.Ports[ports].Key;
                }
                switch (tnetlist.Type[tnetlistIndex].ToLower())
                {
                case "nand2":
                    ttnetlist.Add(new NANDGate(portNames, dev.Id));
                    break;

                case "and2":
                    ttnetlist.Add(new ANDGate(portNames, dev.Id));
                    break;

                case "or2":
                    ttnetlist.Add(new ORGate(portNames, dev.Id));
                    break;

                case "nor2":
                    ttnetlist.Add(new NORGate(portNames, dev.Id));
                    break;

                case "v":
                    ttnetlist.Add(new DigitalSource(portNames, dev.Id));
                    break;

                case "s":
                    ttnetlist.Add(new DigitalSink(portNames, dev.Id));
                    break;

                case "not":
                    ttnetlist.Add(new NOTGate(portNames, dev.Id));
                    break;

                case "high":
                    ttnetlist.Add(new DigitalHigh(portNames, dev.Id));
                    break;

                case "low":
                    ttnetlist.Add(new DigitalLow(portNames, dev.Id));
                    break;

                default:
                    break;
                }
                Netlist = ttnetlist;
            }
        }
示例#2
0
        public void registerDevice(String type)
        {
            LogicDevice dev = new LogicDevice();

            switch (type.ToLower())
            {
            case "nand2":
                dev = new NANDGate(getAvailablePorts(3), getAvailableId());
                break;

            case "and2":
                dev = new ANDGate(getAvailablePorts(3), getAvailableId());
                break;

            case "nor2":
                dev = new NORGate(getAvailablePorts(3), getAvailableId());
                break;

            case "or2":
                dev = new ORGate(getAvailablePorts(3), getAvailableId());
                break;

            case "not":
                dev = new NOTGate(getAvailablePorts(2), getAvailableId());
                break;

            case "v":
                dev = new DigitalSource(getAvailablePorts(1), getAvailableId());
                break;

            case "s":
                dev = new DigitalSink(getAvailablePorts(1), getAvailableId());
                break;

            case "high":
                dev = new DigitalHigh(getAvailablePorts(1), getAvailableId());
                break;

            case "low":
                dev = new DigitalLow(getAvailablePorts(1), getAvailableId());
                break;

            default:
                break;
            }
            Netlist.Add(dev);
        }
示例#3
0
        /// <summary>
        /// Connect methods provide mechanisms to alter the netlist, so that two nodes are connected.
        /// As mentioned before, a connection is a pair of Ports with the same name.
        /// </summary>
        /// <param name="connector"></param>
        /// <param name="connectorPort"></param>
        /// <param name="connectee"></param>
        public void connectPorts(LogicDevice connector, String connectorPort, LogicDevice connectee)
        {
            KeyValuePair <String, bool> tPort = new KeyValuePair <String, bool>(connectorPort, false);

            Netlist[Netlist.IndexOf(connector)].Ports[Netlist[Netlist.IndexOf(connector)].Ports.IndexOf(tPort)] = tPort;
        }
示例#4
0
 public void unregisterDevice(LogicDevice dev)
 {
     Netlist.Remove(dev);
 }