protected override void DoCommandAction() { FPGATypes.AssertBackendType(FPGATypes.BackendType.ISE); NetlistContainer netlistContainer = GetNetlistContainer(); // extract net names as we may not remve during iteration List <XDLNet> netNamesToDecompose = new List <XDLNet>(); foreach (string netName in NetNames) { XDLNet n = (XDLNet)netlistContainer.GetNet(netName); netNamesToDecompose.Add(n); } foreach (XDLNet net in netNamesToDecompose) { foreach (XDLPip pip in net.Pips) { XDLNet arc = new XDLNet(net.Name + "_" + pip.Location + "_" + pip.From + "_" + pip.To); // TODO what about attributes arc.Add(pip); netlistContainer.Add(arc); } net.ClearPips(); if (net.NetPinCount == 0) { netlistContainer.Remove(new Predicate <Net>(n => n.Name.Equals(net.Name))); } } }
protected override void DoCommandAction() { NetlistContainer netlistContainer = GetNetlistContainer(); Regex netFilter = new Regex(NetNameRegexp, RegexOptions.Compiled); // output to be removed nets for later writing them to file foreach (Net netToRemove in netlistContainer.Nets.Where(n => netFilter.IsMatch(n.Name))) { OutputManager.WriteOutput(netToRemove.ToString()); } netlistContainer.Remove(new Predicate<Net>(n => netFilter.IsMatch(n.Name))); }
protected override void DoCommandAction() { NetlistContainer netlistContainer = GetNetlistContainer(); Regex filter = new Regex(InstanceNameRegexp, RegexOptions.Compiled); // output to be removed nets for later writing them to file foreach (Instance inst in netlistContainer.Instances.Where(n => filter.IsMatch(n.Name))) { OutputManager.WriteOutput(inst.ToString()); } netlistContainer.Remove(new Predicate <Instance>(n => filter.IsMatch(n.Name))); }
private void FuseTCLNets(NetlistContainer netlistContainer) { Queue <Net> netsWithOutpin = FindNetsWithOutpin(netlistContainer); Dictionary <string, Net> netsToConsiderForFusing = FindNetsToConsiderForFusing(netlistContainer); // build mapping: Location -> XDLNet WEITER HIER Dictionary <string, Dictionary <string, List <Net> > > candidateLocations = BuildLocationNetMapping(netlistContainer); int startSize = netsWithOutpin.Count; while (netsWithOutpin.Count > 0) { TCLNet current = (TCLNet)netsWithOutpin.Dequeue(); if (current.Name.Contains("p2s")) { } ProgressInfo.Progress = (int)((double)(startSize - netsWithOutpin.Count) / (double)startSize * 100); while (netsToConsiderForFusing.Count > 0) { Dictionary <string, Net> fusedNets = new Dictionary <string, Net>(); Dictionary <string, LocationOutsideNet> fusePoints = new Dictionary <string, LocationOutsideNet>(); // route from end of antennas foreach (LocationOutsideNet los in AllLocationsOutsideNet(current)) { Location loc = los.Location; if (!candidateLocations.ContainsKey(loc.Tile.Location)) { continue; } if (!candidateLocations[loc.Tile.Location].ContainsKey(loc.Pip.Name)) { Dictionary <string, List <Net> > debug = candidateLocations[loc.Tile.Location]; continue; } List <string> netNamesToRemove = new List <string>(); foreach (Net n in candidateLocations[loc.Tile.Location][loc.Pip.Name]) { if (!fusedNets.ContainsKey(n.Name) && !n.Name.Equals(current.Name) && netsToConsiderForFusing.ContainsKey(n.Name)) { fusedNets.Add(n.Name, n); fusePoints.Add(n.Name, los); netNamesToRemove.Add(n.Name); //((TCLRoutingTreeNode)los.RoutingElement).Children.Add() } } candidateLocations[loc.Tile.Location][loc.Pip.Name].RemoveAll(net => netNamesToRemove.Contains(net.Name)); } // TDOO see "and check for branches branches" foreach (TCLNet net in fusedNets.Values) { OutputManager.WriteOutput("Fusing " + current.Name + " with " + net.Name + " @" + fusePoints[net.Name].ToString()); //this.OutputManager.WriteOutput(net.ToString()); //this.OutputManager.WriteOutput(net.Foo()); //this.OutputManager.WriteOutput("------------------------------------------------"); //netlistContainer.RemoveNet(net.Name); netlistContainer.Remove(delegate(Net n) { return(n.Name.Equals(net.Name)); }); netsToConsiderForFusing.Remove(net.Name); foreach (NetPin np in net.NetPins) { current.Add(np); } current.FlattenNet(); net.FlattenNet(); foreach (TCLRoutingTreeNode child in net.RoutingTree.Root.Children) { current.RoutingTree.Root.Children.Add(child); } } // no futher fusions made, continue with next net if (fusedNets.Count == 0) { break; } } } }
private void FuseXDLNets(NetlistContainer netlistContainer) { Queue <Net> netsWithOutpin = FindNetsWithOutpin(netlistContainer); Dictionary <string, Net> netsToConsiderForFusing = FindNetsToConsiderForFusing(netlistContainer); // build mapping: Location -> XDLNet Dictionary <string, Dictionary <string, List <Net> > > candidateLocations = BuildLocationNetMapping(netlistContainer); int startSize = netsWithOutpin.Count; while (netsWithOutpin.Count > 0) { XDLNet current = (XDLNet )netsWithOutpin.Dequeue(); ProgressInfo.Progress = (int)((double)(startSize - netsWithOutpin.Count) / (double)startSize * 100); while (netsToConsiderForFusing.Count > 0) { Dictionary <string, XDLNet> fusedNets = new Dictionary <string, XDLNet>(); Dictionary <string, Location> fusePoints = new Dictionary <string, Location>(); // route from end of antennas foreach (LocationOutsideNet los in AllLocationsOutsideNet(current)) { Location loc = los.Location; if (!candidateLocations.ContainsKey(loc.Tile.Location)) { continue; } if (!candidateLocations[loc.Tile.Location].ContainsKey(loc.Pip.Name)) { continue; } List <string> netNamesToRemove = new List <string>(); foreach (XDLNet n in candidateLocations[loc.Tile.Location][loc.Pip.Name]) { if (!fusedNets.ContainsKey(n.Name) && !n.Name.Equals(current.Name) && netsToConsiderForFusing.ContainsKey(n.Name)) { fusedNets.Add(n.Name, n); fusePoints.Add(n.Name, loc); netNamesToRemove.Add(n.Name); } } candidateLocations[loc.Tile.Location][loc.Pip.Name].RemoveAll(net => netNamesToRemove.Contains(net.Name)); } // and check for branches branches foreach (XDLPip pip in current.Pips) { if (!candidateLocations.ContainsKey(pip.Location)) { continue; } if (!candidateLocations[pip.Location].ContainsKey(pip.From)) { continue; } List <string> netNamesToRemove = new List <string>(); foreach (XDLNet n in candidateLocations[pip.Location][pip.From]) { if (!fusedNets.ContainsKey(n.Name) && !n.Name.Equals(current.Name) && netsToConsiderForFusing.ContainsKey(n.Name)) { fusedNets.Add(n.Name, n); fusePoints.Add(n.Name, new Location(FPGA.FPGA.Instance.GetTile(pip.Location), new Port(pip.From))); netNamesToRemove.Add(n.Name); } } candidateLocations[pip.Location][pip.From].RemoveAll(net => netNamesToRemove.Contains(net.Name)); } foreach (XDLNet net in fusedNets.Values) { // do not add comments to pips or nets to save memory // TODO nur die nasen dranhaengen, die vom current treiber erreichbar sind // TODO attribute fusionieren current.Add(net, false, ""); //current.Add(net, true, "taken from " + net.Name); if (!string.IsNullOrEmpty(net.Header)) { if (net.Header.Contains("vcc") || net.Header.Contains("gnd")) { OutputManager.WriteWarning("Attribute lost: " + net.Header); } } OutputManager.WriteOutput("Fusing " + current.Name + " with " + net.Name + " @" + fusePoints[net.Name].ToString()); //this.OutputManager.WriteOutput(net.ToString()); //this.OutputManager.WriteOutput(net.Foo()); //this.OutputManager.WriteOutput("------------------------------------------------"); //netlistContainer.RemoveNet(net.Name); netlistContainer.Remove(delegate(Net n) { return(n.Name.Equals(net.Name)); }); netsToConsiderForFusing.Remove(net.Name); } // no futher fusions made, continue with next net if (fusedNets.Count == 0) { break; } } } }
protected void AutoClearModuleSlotBeforeInstantiation(LibraryElement libraryElement, IEnumerable <Tile> upperLeftAnchors, int progressStart = 0, int progressShare = 100) { FPGATypes.AssertBackendType(FPGATypes.BackendType.ISE, FPGATypes.BackendType.Vivado); if (libraryElement.ResourceShape == null) { throw new ArgumentException("Library element " + libraryElement.Name + " does not provide any module shape information"); } NetlistContainer nlc = GetNetlistContainer(); Dictionary <string, bool> targetLocations = new Dictionary <string, bool>(); foreach (string originalTileIdnetifier in libraryElement.ResourceShape.GetContainedTileIdentifier().Where(s => !s.StartsWith("NULL"))) { bool validTargetTileFound = false; foreach (Tile anchor in upperLeftAnchors) { string targetLocation = ""; bool success = libraryElement.GetTargetLocation(originalTileIdnetifier, anchor, out targetLocation); if (!targetLocations.ContainsKey(targetLocation)) { targetLocations.Add(targetLocation, true); } if (success) { validTargetTileFound = true; } } if (!validTargetTileFound) { OutputManager.WriteWarning("Could not relocate " + originalTileIdnetifier); } } int netsDone = 0; switch (FPGA.FPGA.Instance.BackendType) { case FPGATypes.BackendType.ISE: foreach (XDLNet net in nlc.Nets.Where(n => !n.ReadOnly)) { ProgressInfo.Progress = progressStart + (int)((double)netsDone++ / (double)nlc.NetCount * progressShare); RemovePipsFromNet((XDLContainer)nlc, targetLocations, net); } // remove all nets that are now empty nlc.Remove(new Predicate <Net>(n => n.PipCount == 0 && n.InpinCount == 0 && n.OutpinCount == 0)); break; case FPGATypes.BackendType.Vivado: foreach (TCLNet net in nlc.Nets) { ProgressInfo.Progress = (int)((double)netsDone++ / (double)nlc.NetCount * 100); // only flatten in we will really remove something, otherwise keep the tree structure to save processing later if (net.RoutingTree.GetAllRoutingNodes().Any(n => !n.VirtualNode && TileSelectionManager.Instance.IsSelected(n.Tile))) { net.FlattenNet(); net.Remove(node => !node.VirtualNode && TileSelectionManager.Instance.IsSelected(node.Tile)); net.Remove(new Predicate <NetPin>(np => TileSelectionManager.Instance.IsSelected(np.TileName))); // remove the outpins instance if it is selected if (net.OutpinInstance != null) { if (TileSelectionManager.Instance.IsSelected(net.OutpinInstance.Location)) { net.OutpinInstance = null; } } } } break; } // handle instances equally (XDL and TCL), only nets differ nlc.Remove(inst => targetLocations.ContainsKey(inst.Location)); }
public override void Undo() { NetlistContainer netlistContainer = GetNetlistContainer(); netlistContainer.Remove(new Predicate <Net>(n => n.Name.Equals(NetName))); }