private bool IsPlacementValidForSingleInstantiation(bool showMessageBoxForValidPlacement) { string libraryElementName = null; Tile anchor = null; string errorMessage = null; string instanceName = null; string netlistContainerName = null; bool paramsValid = FindParametersForSingleInstantiation(out libraryElementName, out anchor, out instanceName, out netlistContainerName, out errorMessage); if (!paramsValid) { MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } StringBuilder errorList = null; bool placementOk = DesignRuleChecker.CheckLibraryElementPlacement(anchor, Library.Instance.GetElement(libraryElementName), out errorList); if (placementOk) { if (showMessageBoxForValidPlacement) { MessageBox.Show("Library element " + libraryElementName + " can be placed at " + anchor.Location, "Placement OK", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } else { MessageBox.Show("Library element " + libraryElementName + " can not be placed at " + anchor.Location + ": " + errorList.ToString(), "Placement failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(placementOk); }
private bool IsPlacementValidForMultiInstantiation() { string libElementName = null; string errorMessage = null; string instanceName = null; string netlistContainerName = null; bool paramsValid = FindParametersForMultiInstantiation(out libElementName, out instanceName, out netlistContainerName, out errorMessage); if (!paramsValid) { MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } foreach (Tile clb in TileSelectionManager.Instance.GetSelectedTiles().Where(t => IdentifierManager.Instance.IsMatch(t.Location, IdentifierManager.RegexTypes.CLB))) { StringBuilder errorList = null; LibraryElement libElement = Library.Instance.GetElement(libElementName); bool placementOk = DesignRuleChecker.CheckLibraryElementPlacement(clb, libElement, out errorList); if (!placementOk) { MessageBox.Show("Library element " + libElementName + " can not be placed at " + clb.Location + ": " + errorList.ToString(), "Placement failed", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } // placement is ok int clbsInSelection = TileSelectionManager.Instance.GetSelectedTiles().Count(t => IdentifierManager.Instance.IsMatch(t.Location, IdentifierManager.RegexTypes.CLB)); MessageBox.Show("Library element " + libElementName + " can be placed at the selected " + clbsInSelection + " position(s)", "Placement OK", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return(true); }
public override void HighLight(Graphics graphicsObj) { if (!Settings.StoredPreferences.Instance.HighLightPossibleMacroPlacements) { return; } if (FPGA.FPGA.Instance.Family.Equals(FPGATypes.FPGAFamily.Undefined)) { return; } if (!Library.Instance.Contains(m_libraryElement)) { return; } if (m_tiles.Count == 0) { m_tiles = DesignRuleChecker.GetPossibleLibraryElementPlacements(m_libraryElement); } foreach (Tile tile in m_tiles) { int upperLeftX = tile.TileKey.X * m_view.TileSize; int upperLeftY = tile.TileKey.Y * m_view.TileSize; Rectangle rect = new Rectangle(upperLeftX, upperLeftY, m_view.TileSize - 1, m_view.TileSize - 1); graphicsObj.DrawRectangle(m_pen, rect); } }
protected override void DoCommandAction() { LibraryElement libEl = Objects.Library.Instance.GetElement(LibraryElementName); List <Tile> anchors = new List <Tile>(); foreach (Tile placePos in TileSelectionManager.Instance.GetSelectedTiles().Where(t => IdentifierManager.Instance.IsMatch(t.Location, IdentifierManager.RegexTypes.CLB))) { StringBuilder errorList = null; bool placementOk = DesignRuleChecker.CheckLibraryElementPlacement(placePos, libEl, out errorList); if (placementOk) { anchors.Add(placePos); } } foreach (Tile t in anchors) { OutputManager.WriteOutput("Libary element " + libEl.Name + " can be placed at " + t.Location); } }
protected override void DoCommandAction() { string batchFile = TargetDirectory + "\\gen_bitstreams.bat"; if (!Directory.Exists(TargetDirectory)) { Directory.CreateDirectory(TargetDirectory); } if (File.Exists(batchFile)) { File.Delete(batchFile); } TextWriter tw = new StreamWriter(batchFile, true); tw.WriteLine("rm *.ncd > NUL"); tw.WriteLine("rm *.bgn > NUL"); tw.WriteLine("rm *.xwbt > NUL"); tw.WriteLine("rm *.bit > NUL"); tw.WriteLine("rm *.bin > NUL"); tw.Close(); if (Positions.All(s => string.IsNullOrEmpty(s))) { string moduleName = Path.GetFileNameWithoutExtension(Module); if (!Objects.Library.Instance.Contains(moduleName)) { AddBinaryLibraryElement addCmd = new AddBinaryLibraryElement(); addCmd.FileName = Module; CommandExecuter.Instance.Execute(addCmd); } LibraryElement libElement = Objects.Library.Instance.GetElement(moduleName); StringBuilder errorList = null; foreach (Tile tile in FPGA.FPGA.Instance.GetAllTiles().Where(t => IdentifierManager.Instance.IsMatch(t.Location, IdentifierManager.RegexTypes.CLB))) { bool placementOk = DesignRuleChecker.CheckLibraryElementPlacement(tile, libElement, out errorList); if (placementOk) { PlaceModuleAndAddBatchFileEntry(tile, batchFile); //this.OutputManager.WriteOutput("Placing " + moduleName + " to " + tile.Location); } } } else { for (int i = 0; i < Positions.Count; i++) { string[] atoms = Positions[i].Split('X', 'Y'); int x = int.Parse(atoms[1]); int y = int.Parse(atoms[2]); Tile anchor = FPGA.FPGA.Instance.GetAllTiles().Where(t => IdentifierManager.Instance.IsMatch(t.Location, IdentifierManager.RegexTypes.CLB) && t.LocationX == x && t.LocationY == y).FirstOrDefault(); if (anchor == null) { throw new ArgumentException("Could not find an anchor for " + Positions[i]); } PlaceModuleAndAddBatchFileEntry(anchor, batchFile); } } }
/// <summary> /// /// </summary> /// <param name="dir"></param> /// <param name="connectionPrimitiveName"></param> /// <param name="instance"></param> /// <param name="columns"></param> /// <param name="maxWiresPerRow"></param> /// <param name="prefix">The prefix that can be sued for subsequent AnnotateSignal commands</param> /// <returns></returns> private List <Command> GetPlacementCommands(FPGA.FPGATypes.InterfaceDirection dir, string connectionPrimitiveName, string instance, int columns, int maxWiresPerRow) { LibraryElement libElement = Objects.Library.Instance.GetElement(connectionPrimitiveName); List <Tile> tilesToReleaseWiresOn = null; List <Tile> anchors = GetAnchors(dir, columns, false, out tilesToReleaseWiresOn); Dictionary <int, List <Signal> > inputsPerColumn = new Dictionary <int, List <Signal> >(); Dictionary <int, List <Signal> > outputsPerColumn = new Dictionary <int, List <Signal> >(); //Console.WriteLine(dir); //Console.WriteLine(instance); for (int column = 0; column < columns; column++) { List <Signal> inputs = GetSignals(dir, column, "in"); List <Signal> outputs = GetSignals(dir, column, "out"); // equalize both list with open signals, the signal paramteres are dont care while (inputs.Count % maxWiresPerRow != 0 || inputs.Count < outputs.Count) { inputs.Add(new Signal("open", "in", dir, IslandName, column)); } while (outputs.Count < inputs.Count) { outputs.Add(new Signal("open", "out", dir, IslandName, column)); } inputsPerColumn[column] = inputs; outputsPerColumn[column] = outputs; } Dictionary <Tile, List <Signal> > inputsOnTile = new Dictionary <Tile, List <Signal> >(); Dictionary <Tile, List <Signal> > outputsOnTile = new Dictionary <Tile, List <Signal> >(); List <Tile> connectionPrimitiveCLBs = new List <Tile>(); // 1 collect inputs in this tile // iterate row wise for (int column = 0; column < columns; column++) { Tile currentAnchor = anchors[column]; for (int i = 0; i < inputsPerColumn[column].Count; i += maxWiresPerRow) { inputsOnTile.Add(currentAnchor, new List <Signal>()); outputsOnTile.Add(currentAnchor, new List <Signal>()); connectionPrimitiveCLBs.Add(currentAnchor); for (int j = 0; j < maxWiresPerRow; j++) { Signal input = inputsPerColumn[column][i + j]; inputsOnTile[currentAnchor].Add(input); Signal output = outputsPerColumn[column][i + j]; outputsOnTile[currentAnchor].Add(output); } currentAnchor = MoveAnchorToNextColumn(dir, currentAnchor); } } CheckMacroTiles(dir, connectionPrimitiveCLBs); string prefix = instance + connectionPrimitiveName; // do connection primitive instantiation List <Command> result = new List <Command>(); foreach (Tile anchor in connectionPrimitiveCLBs) { List <Signal> localInputs = inputsOnTile[anchor]; List <Signal> localOutputs = outputsOnTile[anchor]; // do we need to place a macro here bool placeMacro = HasNonOpenSignal(localInputs) || HasNonOpenSignal(localOutputs); if (!placeMacro) { continue; } // check that the added signal names are all identical if (localOutputs.Select(s => s.SignalNameWithoutBraces).Distinct().Count() != 1) { throw new ArgumentException("Signal names may only change at a boundary of 4. Check signal " + localInputs[0]); } if (localInputs.Select(s => s.SignalNameWithoutBraces).Distinct().Count() != 1) { throw new ArgumentException("Signal names may only change at a boundary of 4. Check signal " + localOutputs[0]); } // can we use this tile for placement? StringBuilder errorList = null; bool validPlacement = DesignRuleChecker.CheckLibraryElementPlacement(anchor, libElement, out errorList); if (!validPlacement) { throw new ArgumentException("Can not place the library element at the desired postion (check the output window)" + errorList.ToString()); } // finally, place the macro AddSingleInstantiationByTile addByTile = new AddSingleInstantiationByTile(); addByTile.AnchorLocation = anchor.Location; addByTile.AutoClearModuleSlot = false; addByTile.InstanceName = prefix + "_" + result.Count; addByTile.LibraryElementName = connectionPrimitiveName; if (result.Count == 0) { addByTile.Comment = "instantiate a connection primitive at tile " + addByTile.AnchorLocation + ". An expert may want to relocate the instantiations"; } result.Add(addByTile); AnnotateSignalNames annotateCmd = new AnnotateSignalNames(); annotateCmd.InstantiationFilter = "^" + addByTile.InstanceName; string inputSource = BuildTarget == Target.Static ? "I:" : "O:"; string outputSource = BuildTarget == Target.Static ? "O:" : "I:"; annotateCmd.PortMapping.Add(inputSource + localInputs[0].SignalNameWithoutBraces + ":external"); annotateCmd.PortMapping.Add(outputSource + localOutputs[0].SignalNameWithoutBraces + ":external"); annotateCmd.PortMapping.Add("H:H:internal"); result.Add(annotateCmd); } return(result); }