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; } }
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); }
/// <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; }
public void unregisterDevice(LogicDevice dev) { Netlist.Remove(dev); }