From 4b294189e2e0aa4ae910efc0a36a5e02a5a89f1c Mon Sep 17 00:00:00 2001 From: Jeffrey Goeders Date: Tue, 6 Jun 2017 20:25:44 -0600 Subject: [PATCH 01/10] Check if constraints list is null before writing out constraints to Xdc --- .../ece/rapidSmith/interfaces/vivado/VivadoInterface.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java index cca15d21..03b12e66 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java @@ -220,9 +220,10 @@ private static void writeConstraintsXdc(CellDesign design, String xdcOut) throws + "# Generated by RapidSmith v.2.0 on %02d/%02d/%02d at %02d:%02d:%02d\n" + "##############################################################\n\n", time.getMonthValue(), time.getDayOfMonth(), time.getYear(), time.getHour(), time.getMinute(), time.getSecond())); - - for (XdcConstraint constraint : design.getVivadoConstraints()) { - fileout.write(constraint + "\n"); + if (design.getVivadoConstraints() != null) { + for (XdcConstraint constraint : design.getVivadoConstraints()) { + fileout.write(constraint + "\n"); + } } } } From 13467b1ac05225cb7f1fa29349d50864aebee13d Mon Sep 17 00:00:00 2001 From: Jeffrey Goeders Date: Fri, 9 Jun 2017 14:49:50 -0600 Subject: [PATCH 02/10] Add method to get a list of all possible site types for a device --- .../byu/ece/rapidSmith/device/SiteType.java | 4 ++ .../interfaces/vivado/XdcReader.java | 62 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java diff --git a/src/main/java/edu/byu/ece/rapidSmith/device/SiteType.java b/src/main/java/edu/byu/ece/rapidSmith/device/SiteType.java index 9e890dc4..6af1788d 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/device/SiteType.java +++ b/src/main/java/edu/byu/ece/rapidSmith/device/SiteType.java @@ -84,6 +84,10 @@ public static SiteType valueOf(FamilyType family, String name) { return familyTypes.computeIfAbsent(name, k -> new SiteType(family, k, nextOrdinal++)); } } + + public static Map getSiteTypes(FamilyType family) { + return types.get(family); + } private static class SiteTypeReplace implements Serializable { private static final long serialVersionUID = 4803134026521902169L; diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java new file mode 100644 index 00000000..6fbf8e57 --- /dev/null +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java @@ -0,0 +1,62 @@ +package edu.byu.ece.rapidSmith.interfaces.vivado; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; + +import edu.byu.ece.rapidSmith.design.subsite.CellDesign; + +public class XdcReader { + static public ArrayList parseXdcFile(String filePath) throws IOException { + File f = new File(filePath); + if ((!f.exists()) || (!f.isFile())) { + throw new IOException("XDC file path does not exist (" + filePath + ")"); + } + + ArrayList constraints = new ArrayList(); + + BufferedReader reader = new BufferedReader(new FileReader(filePath)); + + String line = null; + while ((line = reader.readLine()) != null) { + XdcConstraint constraint = parseLine(line); + if (constraint != null) + constraints.add(constraint); + } + + reader.close(); + + return constraints; + + } + + private CellDesign design; + + public XdcReader(CellDesign design) { + assert design != null; + this.design = design; + } + + public void parseXdcFileIntoDesign(String filePath) throws IOException { + ArrayList constraints = parseXdcFile(filePath); + + for (XdcConstraint constraint : constraints) { + design.addVivadoConstraint(constraint); + } + } + + static private XdcConstraint parseLine(String line) throws IOException { + line = line.trim(); + + if (line.equals("")) + return null; + + if (line.matches("\\s*#.*")) + return null; + + XdcConstraint constraint = new XdcConstraint(line, ""); + return constraint; + } +} From 3d009b43921276ffef74d48e4c9c24d0038de915 Mon Sep 17 00:00:00 2001 From: Jeffrey Goeders Date: Fri, 9 Jun 2017 14:51:06 -0600 Subject: [PATCH 03/10] Add XDC file reader class, and extend XdcConstraint class to have ability to parse pin package constraints --- .../interfaces/vivado/VivadoInterface.java | 1 + .../interfaces/vivado/XdcConstraint.java | 52 +++++++++++++++++++ .../interfaces/vivado/XdcReader.java | 14 ++++- 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java index 03b12e66..3c3df0de 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java @@ -220,6 +220,7 @@ private static void writeConstraintsXdc(CellDesign design, String xdcOut) throws + "# Generated by RapidSmith v.2.0 on %02d/%02d/%02d at %02d:%02d:%02d\n" + "##############################################################\n\n", time.getMonthValue(), time.getDayOfMonth(), time.getYear(), time.getHour(), time.getMinute(), time.getSecond())); + if (design.getVivadoConstraints() != null) { for (XdcConstraint constraint : design.getVivadoConstraints()) { fileout.write(constraint + "\n"); diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java index 8cd8647e..fbded6aa 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java @@ -20,6 +20,9 @@ package edu.byu.ece.rapidSmith.interfaces.vivado; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * This class holds design constraints found in the constraints.xdc file. * TODO: Make these constraints easier to work with @@ -31,9 +34,23 @@ public final class XdcConstraint { private final String command; private final String options; + XdcConstraintPinPackage constraintPinPackage = null; + + private static final Pattern patternPinPackage = Pattern.compile("\\s*set_property\\s+PACKAGE_PIN\\s+(\\w+)\\s+\\[\\s*get_ports\\s+(.*?)\\s*\\]\\s*;?$"); + + public XdcConstraint(String command, String options){ this.command = command; this.options = options; + + String str = toString().trim(); + + // Pin Package? + Matcher matcher = patternPinPackage.matcher(str); + if (matcher.find()) { + constraintPinPackage = new XdcConstraintPinPackage(); + return; + } } /** @@ -57,4 +74,39 @@ public String getOptions() { public String toString(){ return command + " " + options; } + + /** + * @return The XDC pin package constraint instance + */ + public XdcConstraintPinPackage getPinPackageConstraint() { + return constraintPinPackage; + } + + public class XdcConstraintPinPackage { + + private String pinName; + private String netName; + + XdcConstraintPinPackage() { + Matcher matcher = patternPinPackage.matcher(XdcConstraint.this.toString().trim()); + + assert matcher.find(); + pinName = matcher.group(1); + netName = matcher.group(2); + } + + /** + * @return The name of the pin that the net is constrainted to (eg. D7) + */ + public String getPinName() { + return pinName; + } + + /** + * @return The name of the net that is constrainted to a pin. + */ + public String getNetName() { + return netName; + } + } } diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java index 6fbf8e57..dce05ef7 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java @@ -2,6 +2,7 @@ import java.io.BufferedReader; import java.io.File; +import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; @@ -9,10 +10,17 @@ import edu.byu.ece.rapidSmith.design.subsite.CellDesign; public class XdcReader { + + + /** + * @param filePath Path of XDC file to read constraints from + * @return List of XDC constraints + * @throws IOException If XDC file does not exist + */ static public ArrayList parseXdcFile(String filePath) throws IOException { File f = new File(filePath); if ((!f.exists()) || (!f.isFile())) { - throw new IOException("XDC file path does not exist (" + filePath + ")"); + throw new FileNotFoundException("XDC file path does not exist (" + filePath + ")"); } ArrayList constraints = new ArrayList(); @@ -39,6 +47,10 @@ public XdcReader(CellDesign design) { this.design = design; } + /** + * @param filePath Path of XDC file to read constraints from + * @throws IOException If XDC file does not exist + */ public void parseXdcFileIntoDesign(String filePath) throws IOException { ArrayList constraints = parseXdcFile(filePath); From c524f58834cbfd6549acd855b46839a428000e35 Mon Sep 17 00:00:00 2001 From: Date: Mon, 19 Mar 2018 13:25:43 -0600 Subject: [PATCH 04/10] Created xdcConstraintsInterface --- .../interfaces/vivado/VivadoInterface.java | 43 ++-------- .../interfaces/vivado/XdcConstraint.java | 27 +++--- .../vivado/XdcConstraintsInterface.java | 86 +++++++++++++++++++ .../interfaces/vivado/XdcReader.java | 8 +- 4 files changed, 106 insertions(+), 58 deletions(-) create mode 100644 src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java index 48132085..b1e71185 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java @@ -96,8 +96,10 @@ public static VivadoCheckpoint loadRSCP (String rscp, boolean storeAdditionalInf design.setImplementationMode(mode); // parse the constraints into RapidSmith - parseConstraintsXDC(design, rscpPath.resolve("constraints.xdc").toString()); - + String constraintsFile = rscpPath.resolve("constraints.xdc").toString(); + XdcConstraintsInterface constraintsInterface = new XdcConstraintsInterface(design, device); + constraintsInterface.parseConstraintsXDC(constraintsFile); + // re-create the placement and routing information String placementFile = rscpPath.resolve("placement.rsc").toString(); XdcPlacementInterface placementInterface = new XdcPlacementInterface(design, device); @@ -117,42 +119,7 @@ public static VivadoCheckpoint loadRSCP (String rscp, boolean storeAdditionalInf return vivadoCheckpoint; } - - /** - * Loads Vivado constraints into the specified {@link CellDesign}. For now, these constraints are - * loaded as two strings, a command and a list of arguments. There is no attempt right now to - * intelligently handle these constraints, and they are included so the user has access to them. - * TODO: Update how we handle constraints files to make them easier to move - * - * @param design {@link CellDesign} - * @param constraintPath File location of the constraints file. Typically rscpDirectory/constraints.rsc is the constraints file. - */ - private static void parseConstraintsXDC(CellDesign design, String constraintPath) { - - try (BufferedReader br = new BufferedReader(new FileReader(constraintPath))) { - - String line = null; - // add the design constraints to the design - while ((line = br.readLine()) != null) { - - String trimmed = line.trim(); - - // Skip commented lines - if (trimmed.startsWith("#") || trimmed.length() < 1) - continue; - - // assuming a space after the command TODO: make sure this assumption is correct - int index = trimmed.indexOf(" "); - String command = trimmed.substring(0, index); - String options = trimmed.substring(index + 1); - design.addVivadoConstraint(new XdcConstraint(command, options)); - } - - } catch (IOException e) { - throw new Exceptions.ParseException(e); - } - } - + /** * Export the RapidSmith2 design into an existing TINCR checkpoint file. * diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java index fbded6aa..b4f781f7 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java @@ -33,23 +33,18 @@ public final class XdcConstraint { private final String command; private final String options; - - XdcConstraintPinPackage constraintPinPackage = null; - - private static final Pattern patternPinPackage = Pattern.compile("\\s*set_property\\s+PACKAGE_PIN\\s+(\\w+)\\s+\\[\\s*get_ports\\s+(.*?)\\s*\\]\\s*;?$"); - + private XdcConstraintPackagePin constraintPackagePin; + private static final Pattern patternPinPackage = Pattern.compile("\\s*set_property\\s+PACKAGE_PIN\\s+(\\w+)\\s+\\[\\s*get_ports\\s+(.*?)\\s*\\]\\s*;?$"); public XdcConstraint(String command, String options){ this.command = command; this.options = options; - + + // Set the package pin if this constraint includes one. String str = toString().trim(); - - // Pin Package? Matcher matcher = patternPinPackage.matcher(str); if (matcher.find()) { - constraintPinPackage = new XdcConstraintPinPackage(); - return; + constraintPackagePin = new XdcConstraintPackagePin(); } } @@ -78,16 +73,16 @@ public String toString(){ /** * @return The XDC pin package constraint instance */ - public XdcConstraintPinPackage getPinPackageConstraint() { - return constraintPinPackage; + public XdcConstraintPackagePin getPinPackageConstraint() { + return constraintPackagePin; } - public class XdcConstraintPinPackage { + public class XdcConstraintPackagePin { private String pinName; private String netName; - - XdcConstraintPinPackage() { + + XdcConstraintPackagePin() { Matcher matcher = patternPinPackage.matcher(XdcConstraint.this.toString().trim()); assert matcher.find(); @@ -103,7 +98,7 @@ public String getPinName() { } /** - * @return The name of the net that is constrainted to a pin. + * @return The name of the net that is constrained to a pin. */ public String getNetName() { return netName; diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java new file mode 100644 index 00000000..0aa49652 --- /dev/null +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2016 Brigham Young University + * + * This file is part of the BYU RapidSmith Tools. + * + * BYU RapidSmith Tools is free software: you may redistribute it + * and/or modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * BYU RapidSmith Tools is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License is included with the BYU + * RapidSmith Tools. It can be found at doc/LICENSE.GPL3.TXT. You may + * also get a copy of the license at . + */ + +package edu.byu.ece.rapidSmith.interfaces.vivado; + +import edu.byu.ece.rapidSmith.design.subsite.*; +import edu.byu.ece.rapidSmith.device.*; +import edu.byu.ece.rapidSmith.util.Exceptions; + +import java.io.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.function.Function; +import java.util.regex.Pattern; +import java.util.stream.Stream; + +import static edu.byu.ece.rapidSmith.util.Exceptions.ImplementationException; +import static edu.byu.ece.rapidSmith.util.Exceptions.ParseException; + +/** + * This class is used for parsing XDC constraint files and adding them into a RS2 design. + * + * @author Dallon Glick, Dr. Jeffrey Goeders + * + */ +public class XdcConstraintsInterface { + private final CellDesign design; + + public XdcConstraintsInterface(CellDesign design, Device device) { + this.design = design; + } + + private void parseConstraintsLine(String line) { + // assuming a space after the command TODO: make sure this assumption is correct + int index = line.indexOf(" "); + String command = line.substring(0, index); + String options = line.substring(index + 1); + design.addVivadoConstraint(new XdcConstraint(command, options)); + } + + /** + * Loads Vivado constraints into the specified {@link CellDesign}. For now, these constraints are + * loaded as two strings, a command and a list of arguments. There is not much of an attempt right now to + * intelligently handle these constraints, and they are included so the user has access to them. + * TODO: Update how we handle constraints files to make them easier to move + * @param xdcFile constraints.xdc file + * @throws IOException + */ + public void parseConstraintsXDC(String xdcFile) throws IOException { + LineNumberReader br = new LineNumberReader(new BufferedReader(new FileReader(xdcFile))); + String line; + + while ((line = br.readLine()) != null) { + String trimmed = line.trim(); + + // Skip empty and commented lines + // TODO: Is line.equals("") really needed? + if (line.equals("") || line.matches("\\s*#.*")) + continue; + + parseConstraintsLine(trimmed); + } + + br.close(); + } + +} diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java index dce05ef7..34ccb3b5 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java @@ -10,7 +10,7 @@ import edu.byu.ece.rapidSmith.design.subsite.CellDesign; public class XdcReader { - + private CellDesign design; /** * @param filePath Path of XDC file to read constraints from @@ -23,11 +23,11 @@ static public ArrayList parseXdcFile(String filePath) throws IOEx throw new FileNotFoundException("XDC file path does not exist (" + filePath + ")"); } - ArrayList constraints = new ArrayList(); + ArrayList constraints = new ArrayList<>(); BufferedReader reader = new BufferedReader(new FileReader(filePath)); - String line = null; + String line; while ((line = reader.readLine()) != null) { XdcConstraint constraint = parseLine(line); if (constraint != null) @@ -40,7 +40,7 @@ static public ArrayList parseXdcFile(String filePath) throws IOEx } - private CellDesign design; + public XdcReader(CellDesign design) { assert design != null; From 061760b488084100d9e6205ca0a43d20cf87d48c Mon Sep 17 00:00:00 2001 From: Date: Mon, 19 Mar 2018 16:37:00 -0600 Subject: [PATCH 05/10] More parsing of package pins. Added getPortConstraintsMap() method to CellDesign --- .../rapidSmith/design/subsite/CellDesign.java | 29 ++++++ .../interfaces/vivado/VivadoCheckpoint.java | 7 +- .../interfaces/vivado/XdcConstraint.java | 6 +- .../vivado/XdcConstraintsInterface.java | 95 ++++++++++++++++--- 4 files changed, 115 insertions(+), 22 deletions(-) diff --git a/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java b/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java index e8a02532..c9e13ff6 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java +++ b/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java @@ -806,6 +806,35 @@ public void addVivadoConstraint(XdcConstraint constraint) { } vivadoConstraints.add(constraint); } + + /** + * Creates a map from port cells to the site the cell is constrained to be placed on. + * @return the map from port cells to their sites + */ + public Map getPortConstraintMap() { + Map portConstraintMap = new HashMap<>(); + + for (XdcConstraint constraint : vivadoConstraints) { + if (constraint.getPinPackageConstraint() == null) + continue; + + String portName = constraint.getPinPackageConstraint().getPortName(); + String siteName = constraint.getPinPackageConstraint().getPinName(); + + // Get the port cell + Cell portCell = this.getCell(portName); + assert(portCell.isPort()); + + // Get the package pin's site + Site site = device.getSite(siteName); + assert(site != null); + + // Add to the port map + portConstraintMap.put(portCell, site); + } + + return portConstraintMap; + } /** * Creates and returns a deep copy of the current CellDesign. diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoCheckpoint.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoCheckpoint.java index 9bc56509..fbf80ed1 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoCheckpoint.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoCheckpoint.java @@ -24,13 +24,11 @@ import java.util.Map; import java.util.Set; -import edu.byu.ece.rapidSmith.design.subsite.BelRoutethrough; -import edu.byu.ece.rapidSmith.design.subsite.CellDesign; -import edu.byu.ece.rapidSmith.design.subsite.CellLibrary; -import edu.byu.ece.rapidSmith.design.subsite.CellPin; +import edu.byu.ece.rapidSmith.design.subsite.*; import edu.byu.ece.rapidSmith.device.Bel; import edu.byu.ece.rapidSmith.device.BelPin; import edu.byu.ece.rapidSmith.device.Device; +import edu.byu.ece.rapidSmith.device.Site; /** * This class packages a TINCR checkpoint so that it can be returned to the user. @@ -114,4 +112,5 @@ public void setBelPinToCellPinMap(Map pinMap) { public Map getBelPinToCellPinMap() { return this.belPinToCellPinMap; } + } diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java index b4f781f7..37cf1a4d 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java @@ -91,16 +91,16 @@ public class XdcConstraintPackagePin { } /** - * @return The name of the pin that the net is constrainted to (eg. D7) + * @return The name of the pin that the net is constrained to (eg. D7) */ public String getPinName() { return pinName; } /** - * @return The name of the net that is constrained to a pin. + * @return The name of the port that is constrained to a pin. */ - public String getNetName() { + public String getPortName() { return netName; } } diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java index 0aa49652..c968311b 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Brigham Young University + * Copyright (c) 2018 Brigham Young University * * This file is part of the BYU RapidSmith Tools. * @@ -22,19 +22,11 @@ import edu.byu.ece.rapidSmith.design.subsite.*; import edu.byu.ece.rapidSmith.device.*; -import edu.byu.ece.rapidSmith.util.Exceptions; import java.io.*; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import java.util.function.Function; -import java.util.regex.Pattern; -import java.util.stream.Stream; - -import static edu.byu.ece.rapidSmith.util.Exceptions.ImplementationException; -import static edu.byu.ece.rapidSmith.util.Exceptions.ParseException; /** * This class is used for parsing XDC constraint files and adding them into a RS2 design. @@ -44,17 +36,91 @@ */ public class XdcConstraintsInterface { private final CellDesign design; + private final Device device; public XdcConstraintsInterface(CellDesign design, Device device) { this.design = design; + this.device = device; } + /** + * Splits an XDC constraint that includes a dictionary from a single command to multiple properties + * into individual XDC constraints that include only one command and one property. + * Example 1: set_property -dict "name1 value1 ... nameN valueN" [get_ports {portName}] + * Example 2: set_property -dict {name1 value1 ... nameN valueN} [get_ports {portName}] + * @param line the constraint line to split + * @return a list of the individual constraint strings + */ + private ArrayList splitDictConstraints(String line) { + + int prefixEndIndex = line.lastIndexOf("-dict") + 5; + + // TODO: Make this work with constraints other than get_ports. + int suffixBeginIndex = line.lastIndexOf("[get_ports"); + String suffix = line.substring(suffixBeginIndex, line.length()); + String prefix = line.substring(0, line.lastIndexOf("-dict")); + + // Split up the individual properties + String properties = line.substring(prefixEndIndex, suffixBeginIndex); + properties = properties.replaceAll("[{}]", ""); + properties = properties.trim(); + + ArrayList splitConstraints = new ArrayList<>(); + String[] splitProps = properties.split("\\s+"); + + for (int i = 0; i < splitProps.length - 1; i+=2) + { + splitConstraints.add(prefix + splitProps[i] + " " + splitProps[i+1] + " " + suffix); + } + + return splitConstraints; + } + + /** + * Parses a single line from constraints.xdc, makes an XdcConstraint, and adds it to the design. + * @param line the constraint line to parse + */ private void parseConstraintsLine(String line) { - // assuming a space after the command TODO: make sure this assumption is correct - int index = line.indexOf(" "); - String command = line.substring(0, index); - String options = line.substring(index + 1); - design.addVivadoConstraint(new XdcConstraint(command, options)); + // Remove same line comments + int commentIndex = line.indexOf("#"); + line = (commentIndex != -1) ? line.substring(0, commentIndex) : line; + line = line.trim(); + line = line.replaceAll("[;]", ""); + + + int getPortsIndex = line.lastIndexOf("[get_ports"); + if (getPortsIndex != -1) { + // Remove curly braces from [get_ports ... ] suffix + String suffix = line.substring(getPortsIndex, line.length()); + suffix = suffix.replaceAll("[{}]", ""); + line = line.substring(0, line.lastIndexOf("[get_ports") - 1) + " " + suffix; + + if (line.matches("(.*)(-dict)(.*)")) { + // Split up dict constraints into individual constraints for ease of use + ArrayList splitLines = splitDictConstraints(line); + + for (String splitLine : splitLines) { + int index = splitLine.indexOf(" "); + String command = splitLine.substring(0, index); + String options = splitLine.substring(index + 1); + design.addVivadoConstraint(new XdcConstraint(command, options)); + } + } + else { + // assuming a space after the command TODO: make sure this assumption is correct + int index = line.indexOf(" "); + String command = line.substring(0, index); + String options = line.substring(index + 1); + design.addVivadoConstraint(new XdcConstraint(command, options)); + } + } + else { + // Not a constraint that ends in "[get_ports ... ] + int index = line.indexOf(" "); + String command = line.substring(0, index); + String options = line.substring(index + 1); + design.addVivadoConstraint(new XdcConstraint(command, options)); + } } /** @@ -73,7 +139,6 @@ public void parseConstraintsXDC(String xdcFile) throws IOException { String trimmed = line.trim(); // Skip empty and commented lines - // TODO: Is line.equals("") really needed? if (line.equals("") || line.matches("\\s*#.*")) continue; From 6fb1ae2584547d41197c2e28de1ae936dc57c2ea Mon Sep 17 00:00:00 2001 From: Date: Mon, 19 Mar 2018 16:49:18 -0600 Subject: [PATCH 06/10] Improved parseConstraintsLine(), renamed netName to portName in xdcConstraintPackagePin --- .../interfaces/vivado/XdcConstraint.java | 6 ++--- .../vivado/XdcConstraintsInterface.java | 24 +++++++------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java index 37cf1a4d..8c3e5c4b 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java @@ -80,14 +80,14 @@ public XdcConstraintPackagePin getPinPackageConstraint() { public class XdcConstraintPackagePin { private String pinName; - private String netName; + private String portName; XdcConstraintPackagePin() { Matcher matcher = patternPinPackage.matcher(XdcConstraint.this.toString().trim()); assert matcher.find(); pinName = matcher.group(1); - netName = matcher.group(2); + portName = matcher.group(2); } /** @@ -101,7 +101,7 @@ public String getPinName() { * @return The name of the port that is constrained to a pin. */ public String getPortName() { - return netName; + return portName; } } } diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java index c968311b..7036130c 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java @@ -87,7 +87,6 @@ private void parseConstraintsLine(String line) { line = line.trim(); line = line.replaceAll("[;]", ""); - int getPortsIndex = line.lastIndexOf("[get_ports"); if (getPortsIndex != -1) { // Remove curly braces from [get_ports ... ] suffix @@ -105,22 +104,17 @@ private void parseConstraintsLine(String line) { String options = splitLine.substring(index + 1); design.addVivadoConstraint(new XdcConstraint(command, options)); } + return; } - else { - // assuming a space after the command TODO: make sure this assumption is correct - int index = line.indexOf(" "); - String command = line.substring(0, index); - String options = line.substring(index + 1); - design.addVivadoConstraint(new XdcConstraint(command, options)); - } - } - else { - // Not a constraint that ends in "[get_ports ... ] - int index = line.indexOf(" "); - String command = line.substring(0, index); - String options = line.substring(index + 1); - design.addVivadoConstraint(new XdcConstraint(command, options)); + } + + // assuming a space after the command TODO: make sure this assumption is correct + int index = line.indexOf(" "); + String command = line.substring(0, index); + String options = line.substring(index + 1); + design.addVivadoConstraint(new XdcConstraint(command, options)); + } /** From 9ea82f810ae688f55bcff0382df4491669869103 Mon Sep 17 00:00:00 2001 From: Date: Mon, 19 Mar 2018 16:54:58 -0600 Subject: [PATCH 07/10] Moved writeConstraintsXdc() from VivadoInterface to XdcConstraintsInterface --- .../interfaces/vivado/VivadoInterface.java | 34 +++---------------- .../vivado/XdcConstraintsInterface.java | 32 ++++++++++++++--- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java index b1e71185..b29543c6 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoInterface.java @@ -152,38 +152,12 @@ public static void writeTCP(String tcpDirectory, CellDesign design, Device devic EdifInterface.writeEdif(edifOut, design); // write constraints.xdc - writeConstraintsXdc(design, Paths.get(tcpDirectory, "constraints.xdc").toString()); - + String constraintsOut = Paths.get(tcpDirectory, "constraints.xdc").toString(); + XdcConstraintsInterface constraintsInterface = new XdcConstraintsInterface(design, device); + constraintsInterface.writeConstraintsXdc(constraintsOut); + // write design.info String partInfoOut = Paths.get(tcpDirectory, "design.info").toString(); DesignInfoInterface.writeInfoFile(partInfoOut, design.getPartName()); } - - /** - * Reads the Vivado constraints from the specified {@link CellDesign} and creates a - * constraints.xdc file representing the constraints. The file is written to the newly - * created TINCR checkpoint. - * - * @param design {@link CellDesign} - * @param xdcOut Constraints.xdc file path - * @throws IOException - */ - private static void writeConstraintsXdc(CellDesign design, String xdcOut) throws IOException { - - try (BufferedWriter fileout = new BufferedWriter (new FileWriter(xdcOut))) { - - LocalDateTime time = LocalDateTime.now(); - - fileout.write(String.format("##############################################################\n" - + "# Generated by RapidSmith v.2.0 on %02d/%02d/%02d at %02d:%02d:%02d\n" - + "##############################################################\n\n", - time.getMonthValue(), time.getDayOfMonth(), time.getYear(), time.getHour(), time.getMinute(), time.getSecond())); - - if (design.getVivadoConstraints() != null) { - for (XdcConstraint constraint : design.getVivadoConstraints()) { - fileout.write(constraint + "\n"); - } - } - } - } } // END CLASS diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java index 7036130c..aa1c4c7a 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java @@ -24,6 +24,7 @@ import edu.byu.ece.rapidSmith.device.*; import java.io.*; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -31,7 +32,7 @@ /** * This class is used for parsing XDC constraint files and adding them into a RS2 design. * - * @author Dallon Glick, Dr. Jeffrey Goeders + * @author Dallon Glick, Dr. Jeffrey Goeders, Thomas Townsend * */ public class XdcConstraintsInterface { @@ -52,7 +53,6 @@ public XdcConstraintsInterface(CellDesign design, Device device) { * @return a list of the individual constraint strings */ private ArrayList splitDictConstraints(String line) { - int prefixEndIndex = line.lastIndexOf("-dict") + 5; // TODO: Make this work with constraints other than get_ports. @@ -106,7 +106,6 @@ private void parseConstraintsLine(String line) { } return; } - } // assuming a space after the command TODO: make sure this assumption is correct @@ -114,7 +113,6 @@ private void parseConstraintsLine(String line) { String command = line.substring(0, index); String options = line.substring(index + 1); design.addVivadoConstraint(new XdcConstraint(command, options)); - } /** @@ -142,4 +140,30 @@ public void parseConstraintsXDC(String xdcFile) throws IOException { br.close(); } + /** + * Reads the Vivado constraints from the {@link CellDesign} and creates a + * constraints.xdc file representing the constraints. The file is written to the newly + * created TINCR checkpoint. + * + * @param xdcOut Constraints.xdc file path + * @throws IOException + */ + public void writeConstraintsXdc(String xdcOut) throws IOException { + + try (BufferedWriter fileout = new BufferedWriter (new FileWriter(xdcOut))) { + + LocalDateTime time = LocalDateTime.now(); + + fileout.write(String.format("##############################################################\n" + + "# Generated by RapidSmith v.2.0 on %02d/%02d/%02d at %02d:%02d:%02d\n" + + "##############################################################\n\n", + time.getMonthValue(), time.getDayOfMonth(), time.getYear(), time.getHour(), time.getMinute(), time.getSecond())); + + if (design.getVivadoConstraints() != null) { + for (XdcConstraint constraint : design.getVivadoConstraints()) { + fileout.write(constraint + "\n"); + } + } + } + } } From a6d264b744b554ca2a70f4ae66a9b337418f559a Mon Sep 17 00:00:00 2001 From: Date: Thu, 22 Mar 2018 16:36:22 -0600 Subject: [PATCH 08/10] reduced scope of parser / simplified for current needs. --- .../rapidSmith/design/subsite/CellDesign.java | 6 +- .../interfaces/vivado/XdcConstraint.java | 29 +++++-- .../vivado/XdcConstraintsInterface.java | 81 +++---------------- .../interfaces/vivado/XdcReader.java | 74 ----------------- 4 files changed, 37 insertions(+), 153 deletions(-) delete mode 100644 src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java diff --git a/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java b/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java index c9e13ff6..bd2c123d 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java +++ b/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java @@ -808,12 +808,16 @@ public void addVivadoConstraint(XdcConstraint constraint) { } /** - * Creates a map from port cells to the site the cell is constrained to be placed on. + * Creates a map from port cells to the sites the cells are constrained to be placed on according to the + * imported constraints.xdc. * @return the map from port cells to their sites */ public Map getPortConstraintMap() { Map portConstraintMap = new HashMap<>(); + if (vivadoConstraints == null) + return portConstraintMap; + for (XdcConstraint constraint : vivadoConstraints) { if (constraint.getPinPackageConstraint() == null) continue; diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java index 8c3e5c4b..14e74f22 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java @@ -33,18 +33,20 @@ public final class XdcConstraint { private final String command; private final String options; + private final String comment; private XdcConstraintPackagePin constraintPackagePin; - private static final Pattern patternPinPackage = Pattern.compile("\\s*set_property\\s+PACKAGE_PIN\\s+(\\w+)\\s+\\[\\s*get_ports\\s+(.*?)\\s*\\]\\s*;?$"); - - public XdcConstraint(String command, String options){ + private static final Pattern patternPackagePin = Pattern.compile("\\s*set_property\\s+.*PACKAGE_PIN\\s+(\\w+)\\s+.*\\[\\s*get_ports*\\s+\\{?\\s*([^{}\\s]+)\\s*}?\\s*].*$"); + + public XdcConstraint(String command, String options, String comment){ this.command = command; this.options = options; + this.comment = comment; // Set the package pin if this constraint includes one. - String str = toString().trim(); - Matcher matcher = patternPinPackage.matcher(str); + String constraint = command + " " + options; + Matcher matcher = patternPackagePin.matcher(constraint); if (matcher.find()) { - constraintPackagePin = new XdcConstraintPackagePin(); + constraintPackagePin = new XdcConstraintPackagePin(matcher.group(1), matcher.group(2)); } } @@ -61,13 +63,18 @@ public String getCommandName() { public String getOptions() { return options; } + + /** + * @return the comment of the XDC constraint. null if there is no comment. + */ + public String getComment() { return comment; } /** * Formats the XDC constraint and returns it as a string. */ @Override public String toString(){ - return command + " " + options; + return (comment != null) ? command + " " + options + " " + comment : command + " " + options; } /** @@ -83,12 +90,18 @@ public class XdcConstraintPackagePin { private String portName; XdcConstraintPackagePin() { - Matcher matcher = patternPinPackage.matcher(XdcConstraint.this.toString().trim()); + String constraint = XdcConstraint.this.command + " " + XdcConstraint.this.options; + Matcher matcher = patternPackagePin.matcher(constraint); assert matcher.find(); pinName = matcher.group(1); portName = matcher.group(2); } + + XdcConstraintPackagePin(String pinName, String portName) { + this.pinName = pinName; + this.portName = portName; + } /** * @return The name of the pin that the net is constrained to (eg. D7) diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java index aa1c4c7a..4484edd8 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraintsInterface.java @@ -44,81 +44,24 @@ public XdcConstraintsInterface(CellDesign design, Device device) { this.device = device; } - /** - * Splits an XDC constraint that includes a dictionary from a single command to multiple properties - * into individual XDC constraints that include only one command and one property. - * Example 1: set_property -dict "name1 value1 ... nameN valueN" [get_ports {portName}] - * Example 2: set_property -dict {name1 value1 ... nameN valueN} [get_ports {portName}] - * @param line the constraint line to split - * @return a list of the individual constraint strings - */ - private ArrayList splitDictConstraints(String line) { - int prefixEndIndex = line.lastIndexOf("-dict") + 5; - - // TODO: Make this work with constraints other than get_ports. - int suffixBeginIndex = line.lastIndexOf("[get_ports"); - String suffix = line.substring(suffixBeginIndex, line.length()); - String prefix = line.substring(0, line.lastIndexOf("-dict")); - - // Split up the individual properties - String properties = line.substring(prefixEndIndex, suffixBeginIndex); - properties = properties.replaceAll("[{}]", ""); - properties = properties.trim(); - - ArrayList splitConstraints = new ArrayList<>(); - String[] splitProps = properties.split("\\s+"); - - for (int i = 0; i < splitProps.length - 1; i+=2) - { - splitConstraints.add(prefix + splitProps[i] + " " + splitProps[i+1] + " " + suffix); - } - - return splitConstraints; - } - /** * Parses a single line from constraints.xdc, makes an XdcConstraint, and adds it to the design. * @param line the constraint line to parse */ private void parseConstraintsLine(String line) { - // Remove same line comments - int commentIndex = line.indexOf("#"); - line = (commentIndex != -1) ? line.substring(0, commentIndex) : line; - line = line.trim(); - line = line.replaceAll("[;]", ""); - - int getPortsIndex = line.lastIndexOf("[get_ports"); - if (getPortsIndex != -1) { - // Remove curly braces from [get_ports ... ] suffix - String suffix = line.substring(getPortsIndex, line.length()); - suffix = suffix.replaceAll("[{}]", ""); - line = line.substring(0, line.lastIndexOf("[get_ports") - 1) + " " + suffix; - - if (line.matches("(.*)(-dict)(.*)")) { - // Split up dict constraints into individual constraints for ease of use - ArrayList splitLines = splitDictConstraints(line); - - for (String splitLine : splitLines) { - int index = splitLine.indexOf(" "); - String command = splitLine.substring(0, index); - String options = splitLine.substring(index + 1); - design.addVivadoConstraint(new XdcConstraint(command, options)); - } - return; - } - } - - // assuming a space after the command TODO: make sure this assumption is correct - int index = line.indexOf(" "); - String command = line.substring(0, index); - String options = line.substring(index + 1); - design.addVivadoConstraint(new XdcConstraint(command, options)); + int optIdx = line.indexOf(" "); + int cmntIdx = line.indexOf("#"); + String command = line.substring(0, optIdx); + String options = (cmntIdx != -1) ? line.substring(optIdx + 1, cmntIdx).trim() : line.substring(optIdx + 1).trim(); + String comment = (cmntIdx != -1) ? line.substring(cmntIdx) : null; + design.addVivadoConstraint(new XdcConstraint(command, options, comment)); } /** * Loads Vivado constraints into the specified {@link CellDesign}. For now, these constraints are - * loaded as two strings, a command and a list of arguments. There is not much of an attempt right now to - * intelligently handle these constraints, and they are included so the user has access to them. + * loaded as two strings, a command and a list of arguments. For package pin constraints, the pin and corresponding + * port is saved. Otherwise, there is no attempt right now to intelligently handle these constraints, and they are + * included so the user has access to them. * TODO: Update how we handle constraints files to make them easier to move * @param xdcFile constraints.xdc file * @throws IOException @@ -130,8 +73,8 @@ public void parseConstraintsXDC(String xdcFile) throws IOException { while ((line = br.readLine()) != null) { String trimmed = line.trim(); - // Skip empty and commented lines - if (line.equals("") || line.matches("\\s*#.*")) + // Skip empty and comment lines + if (trimmed.length() < 1 || trimmed.startsWith("#")) continue; parseConstraintsLine(trimmed); @@ -149,9 +92,7 @@ public void parseConstraintsXDC(String xdcFile) throws IOException { * @throws IOException */ public void writeConstraintsXdc(String xdcOut) throws IOException { - try (BufferedWriter fileout = new BufferedWriter (new FileWriter(xdcOut))) { - LocalDateTime time = LocalDateTime.now(); fileout.write(String.format("##############################################################\n" diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java deleted file mode 100644 index 34ccb3b5..00000000 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcReader.java +++ /dev/null @@ -1,74 +0,0 @@ -package edu.byu.ece.rapidSmith.interfaces.vivado; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; - -import edu.byu.ece.rapidSmith.design.subsite.CellDesign; - -public class XdcReader { - private CellDesign design; - - /** - * @param filePath Path of XDC file to read constraints from - * @return List of XDC constraints - * @throws IOException If XDC file does not exist - */ - static public ArrayList parseXdcFile(String filePath) throws IOException { - File f = new File(filePath); - if ((!f.exists()) || (!f.isFile())) { - throw new FileNotFoundException("XDC file path does not exist (" + filePath + ")"); - } - - ArrayList constraints = new ArrayList<>(); - - BufferedReader reader = new BufferedReader(new FileReader(filePath)); - - String line; - while ((line = reader.readLine()) != null) { - XdcConstraint constraint = parseLine(line); - if (constraint != null) - constraints.add(constraint); - } - - reader.close(); - - return constraints; - - } - - - - public XdcReader(CellDesign design) { - assert design != null; - this.design = design; - } - - /** - * @param filePath Path of XDC file to read constraints from - * @throws IOException If XDC file does not exist - */ - public void parseXdcFileIntoDesign(String filePath) throws IOException { - ArrayList constraints = parseXdcFile(filePath); - - for (XdcConstraint constraint : constraints) { - design.addVivadoConstraint(constraint); - } - } - - static private XdcConstraint parseLine(String line) throws IOException { - line = line.trim(); - - if (line.equals("")) - return null; - - if (line.matches("\\s*#.*")) - return null; - - XdcConstraint constraint = new XdcConstraint(line, ""); - return constraint; - } -} From cabd50b172f1f71f26f44cd0c5601a2b0052d38c Mon Sep 17 00:00:00 2001 From: Date: Thu, 22 Mar 2018 16:41:37 -0600 Subject: [PATCH 09/10] Removing unneccessary code before PR --- .../edu/byu/ece/rapidSmith/design/subsite/CellDesign.java | 8 ++------ src/main/java/edu/byu/ece/rapidSmith/device/SiteType.java | 4 ---- .../rapidSmith/interfaces/vivado/VivadoCheckpoint.java | 2 -- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java b/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java index bd2c123d..8f5c9815 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java +++ b/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java @@ -814,7 +814,6 @@ public void addVivadoConstraint(XdcConstraint constraint) { */ public Map getPortConstraintMap() { Map portConstraintMap = new HashMap<>(); - if (vivadoConstraints == null) return portConstraintMap; @@ -822,15 +821,12 @@ public Map getPortConstraintMap() { if (constraint.getPinPackageConstraint() == null) continue; - String portName = constraint.getPinPackageConstraint().getPortName(); - String siteName = constraint.getPinPackageConstraint().getPinName(); - // Get the port cell - Cell portCell = this.getCell(portName); + Cell portCell = this.getCell(constraint.getPinPackageConstraint().getPortName()); assert(portCell.isPort()); // Get the package pin's site - Site site = device.getSite(siteName); + Site site = device.getSite(constraint.getPinPackageConstraint().getPinName()); assert(site != null); // Add to the port map diff --git a/src/main/java/edu/byu/ece/rapidSmith/device/SiteType.java b/src/main/java/edu/byu/ece/rapidSmith/device/SiteType.java index 1d0b7c1a..830ff83f 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/device/SiteType.java +++ b/src/main/java/edu/byu/ece/rapidSmith/device/SiteType.java @@ -84,10 +84,6 @@ public static SiteType valueOf(FamilyType family, String name) { return familyTypes.computeIfAbsent(name, k -> new SiteType(family, k, nextOrdinal++)); } } - - public static Map getSiteTypes(FamilyType family) { - return types.get(family); - } private static class SiteTypeReplace implements Serializable { private static final long serialVersionUID = 4803134026521902169L; diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoCheckpoint.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoCheckpoint.java index fbf80ed1..0d65d7cf 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoCheckpoint.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/VivadoCheckpoint.java @@ -28,7 +28,6 @@ import edu.byu.ece.rapidSmith.device.Bel; import edu.byu.ece.rapidSmith.device.BelPin; import edu.byu.ece.rapidSmith.device.Device; -import edu.byu.ece.rapidSmith.device.Site; /** * This class packages a TINCR checkpoint so that it can be returned to the user. @@ -112,5 +111,4 @@ public void setBelPinToCellPinMap(Map pinMap) { public Map getBelPinToCellPinMap() { return this.belPinToCellPinMap; } - } From 81341b143af870f8d161979c4b59557b979dbe60 Mon Sep 17 00:00:00 2001 From: Date: Thu, 22 Mar 2018 16:50:10 -0600 Subject: [PATCH 10/10] Removed unused XDCConstraintPackagePin constructor --- .../byu/ece/rapidSmith/design/subsite/CellDesign.java | 6 +++--- .../rapidSmith/interfaces/vivado/XdcConstraint.java | 11 +---------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java b/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java index 8f5c9815..214688d1 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java +++ b/src/main/java/edu/byu/ece/rapidSmith/design/subsite/CellDesign.java @@ -818,15 +818,15 @@ public Map getPortConstraintMap() { return portConstraintMap; for (XdcConstraint constraint : vivadoConstraints) { - if (constraint.getPinPackageConstraint() == null) + if (constraint.getPackagePinConstraint() == null) continue; // Get the port cell - Cell portCell = this.getCell(constraint.getPinPackageConstraint().getPortName()); + Cell portCell = this.getCell(constraint.getPackagePinConstraint().getPortName()); assert(portCell.isPort()); // Get the package pin's site - Site site = device.getSite(constraint.getPinPackageConstraint().getPinName()); + Site site = device.getSite(constraint.getPackagePinConstraint().getPinName()); assert(site != null); // Add to the port map diff --git a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java index 14e74f22..bed83922 100644 --- a/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java +++ b/src/main/java/edu/byu/ece/rapidSmith/interfaces/vivado/XdcConstraint.java @@ -80,7 +80,7 @@ public String toString(){ /** * @return The XDC pin package constraint instance */ - public XdcConstraintPackagePin getPinPackageConstraint() { + public XdcConstraintPackagePin getPackagePinConstraint() { return constraintPackagePin; } @@ -89,15 +89,6 @@ public class XdcConstraintPackagePin { private String pinName; private String portName; - XdcConstraintPackagePin() { - String constraint = XdcConstraint.this.command + " " + XdcConstraint.this.options; - Matcher matcher = patternPackagePin.matcher(constraint); - - assert matcher.find(); - pinName = matcher.group(1); - portName = matcher.group(2); - } - XdcConstraintPackagePin(String pinName, String portName) { this.pinName = pinName; this.portName = portName;