Skip to content

Commit

Permalink
Merge pull request #340 from byuccl/betterReverse2
Browse files Browse the repository at this point in the history
Improved XDLRC parsing and much faster device file generation (2)
  • Loading branch information
DallonTG authored Feb 22, 2018
2 parents 36e5edc + c12497a commit 3457f6b
Show file tree
Hide file tree
Showing 33 changed files with 2,281 additions and 1,032 deletions.
Binary file modified devices/artix7/xc7a100tcsg324_db.dat
Binary file not shown.
Binary file removed devices/artix7/xc7a100tcsg324_info.dat
Binary file not shown.
Binary file modified devices/kintexu/xcku025ffva1156_db.dat
Binary file not shown.
Binary file removed devices/kintexu/xcku025ffva1156_info.dat
Binary file not shown.
Binary file removed docs/TechReport/TechReport.synctex.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 9 additions & 12 deletions docs/TechReport/techReportChapters/installingNewDevices.tex
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,17 @@ \subsection{Creating New Device Files for Supported Families}

\vspace{.3cm}

\noindent Once the device installer is done executing, the compact devices files
are stored in the corresponding family directory of the RapidSmith2 ``devices''
folder. For example, the device files generated from the example part
\textit{xc7a100tcsg324-3} are stored in the ``artix7'' sub-directory.
\autoref{lst:apdxADeviceFiles} shows the two device files that are created
after the device installer is run. The file ending in ``\_db.dat'' contains the
serialized \texttt{Device} data structures for RapidSmith2. The file ending in
``\_info.dat'' contains additional serialized data (such as reverse wire
connections) that can be optionally loaded with the device.

\begin{lstlisting}[numbers=none, caption=Generated RapidSmith2 device files,
\noindent Once the device installer is done executing, the compact devices file
is stored in the corresponding family directory of the RapidSmith2 ``devices''
folder. For example, the device file generated from the example part
\textit{xc7a100tcsg324-3} is stored in the ``artix7'' sub-directory.
\autoref{lst:apdxADeviceFiles} shows the device file that is created
after the device installer is run.

\begin{lstlisting}[numbers=none, caption=Generated RapidSmith2 device file,
label=lst:apdxADeviceFiles]
[ttown523@CB461-EE09968:artix7] ls
cellLibrary.xml familyInfo.xml |\textbf{xc7a100tcsg324\_db.dat}| |\textbf{xc7a100tcsg324\_info.dat}|
cellLibrary.xml familyInfo.xml |\textbf{xc7a100tcsg324\_db.dat}|
\end{lstlisting}

\subsection{Supporting New Device Families} \label{sec:newFamilies}
Expand Down
32 changes: 8 additions & 24 deletions src/main/java/edu/byu/ece/rapidSmith/device/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package edu.byu.ece.rapidSmith.device;

import edu.byu.ece.rapidSmith.RSEnvironment;
import edu.byu.ece.rapidSmith.device.creation.ExtendedDeviceInfo;
import edu.byu.ece.rapidSmith.util.HashPool;
import edu.byu.ece.rapidSmith.primitiveDefs.PrimitiveDefList;

Expand All @@ -43,15 +42,14 @@ public class Device implements Serializable {
// Versions
//========================================================================//
/** This is the current device file version (saved in file to ensure proper compatibility) */
public static final String LATEST_DEVICE_FILE_VERSION = "1.0";
public static final String LATEST_DEVICE_FILE_VERSION = "1.1";
/** The current release of the tools */
public static final String rapidSmithVersion = "2.0.0";
private static final long serialVersionUID = 3980157455165403758L;
private static final long serialVersionUID = -5032202328911688776L;

//========================================================================//
// Class Members
//========================================================================//
private boolean extendedInfoLoaded = false;
/** The Xilinx part name of the device (ie. xc4vfx12ff668, omits the speed grade) */
private String partName;
/** The Xilinx family of this part */
Expand Down Expand Up @@ -150,29 +148,15 @@ public void setPartName(String partName) {
public void setFamily(FamilyType family) {
this.family = family;
}


@Deprecated
public boolean hasExtendedInfo() {
return extendedInfoLoaded;
return true;
}

@Deprecated
public boolean loadExtendedInfo() {
Path partFolderPath = ExtendedDeviceInfo.getExtendedInfoPath(this);
ExtendedDeviceInfo info;
try {
info = ExtendedDeviceInfo.loadCompressedFile(partFolderPath);
} catch (IOException e) {
return false;
}
for (Tile tile : getTileMap().values()) {
tile.setReverseWireConnections(info.getReversedWireMap().get(tile.getName()));
}

for (SiteType type : info.getReversedSubsiteRouting().keySet()) {
SiteTemplate template = getSiteTemplate(type);
template.setReverseWireConnections(info.getReversedSubsiteRouting().get(type));
}

extendedInfoLoaded = true;
// all info has been moved into the device. Does nothing now
return true;
}

Expand Down Expand Up @@ -724,7 +708,7 @@ public void setRouteThroughMap(Map<Integer, Map<Integer, PIPRouteThrough>> route
For Hessian compression. Avoids writing duplicate data.
*/
protected static class DeviceReplace implements Serializable {
private static final long serialVersionUID = 945509107696820354L;
private static final long serialVersionUID = -3274492099960921694L;
private String version;
private String partName;
private FamilyType family;
Expand Down
40 changes: 10 additions & 30 deletions src/main/java/edu/byu/ece/rapidSmith/device/SiteTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

package edu.byu.ece.rapidSmith.device;

import edu.byu.ece.rapidSmith.design.xdl.XdlAttribute;

import java.io.Serializable;
import java.util.*;

Expand All @@ -39,7 +37,7 @@ public final class SiteTemplate implements Serializable {
private SiteType[] compatibleTypes;
// The intrasite routing graph structure
private WireHashMap routing;
private WireHashMap reverseWireConnections;
private WireHashMap reverseRouting;
// Map of pin names to pin templates for the source pins
private Map<String, SitePinTemplate> sources;
// Map of pin names to pin templates for the sink pins
Expand All @@ -48,8 +46,6 @@ public final class SiteTemplate implements Serializable {
private transient Map<Integer, SitePinTemplate> internalWireToSitePinMap;
// Map of the site wires to the bel pin templates the wire connect to
private transient Map<Integer, BelPinTemplate> belPins;
// Map of XDL attributes that should be created for each PIP
private Map<Integer, Map<Integer, XdlAttribute>> pipAttributes;
// Map containing the bel routethrough information of the site
private Map<Integer, Set<Integer>> belRoutethroughMap;

Expand Down Expand Up @@ -142,19 +138,6 @@ public void setInternalWireToSitePinMap(Map<Integer, SitePinTemplate> internalWi
this.internalWireToSitePinMap = internalWireToSitePinMap;
}

public Map<Integer, Map<Integer, XdlAttribute>> getPipAttributes() {
return pipAttributes;
}

public XdlAttribute getPipAttribute(PIP pip) {
return pipAttributes.get(pip.getStartWire().getWireEnum())
.get(pip.getEndWire().getWireEnum());
}

public void setPipAttributes(Map<Integer, Map<Integer, XdlAttribute>> pipAttributes) {
this.pipAttributes = pipAttributes;
}

public void setBelRoutethroughs(Map<Integer, Set<Integer>> belRoutethroughs) {
this.belRoutethroughMap = belRoutethroughs;
}
Expand Down Expand Up @@ -211,29 +194,28 @@ public SitePinTemplate getSitePin(String name) {
return null;
}

public void setReverseWireConnections(WireHashMap reverseWireConnections) {
this.reverseWireConnections = reverseWireConnections;
public void setReverseRouting(WireHashMap reverseWireConnections) {
this.reverseRouting = reverseWireConnections;
}

public WireConnection[] getReverseWireConnections(int wire) {
return reverseWireConnections.get(wire);
return reverseRouting.get(wire);
}

public WireHashMap getReversedWireHashMap() {
return reverseWireConnections;
public WireHashMap getReversedRouting() {
return reverseRouting;
}

// for hessian compression
private static class SiteTemplateReplace implements Serializable {
private static final long serialVersionUID = 4409516349602480310L;
private static final long serialVersionUID = -1220446291416506054L;
private SiteType type;
private Collection<BelTemplate> belTemplates;
private SiteType[] compatibleTypes;
private WireHashMap routing;
private WireHashMap reverseWireConnections;
private WireHashMap reverseRouting;
private Collection<SitePinTemplate> sources;
private Collection<SitePinTemplate> sinks;
private Map<Integer, Map<Integer, XdlAttribute>> pipAttributes;
private Map<Integer, Set<Integer>> belRoutethroughMap;

public Object readResolve() {
Expand All @@ -247,7 +229,7 @@ public Object readResolve() {
}
template.compatibleTypes = compatibleTypes;
template.routing = routing;
template.reverseWireConnections = reverseWireConnections;
template.reverseRouting = reverseRouting;
if (sources != null) {
template.sources = new HashMap<>();
for (SitePinTemplate pin : sources) {
Expand All @@ -261,7 +243,6 @@ public Object readResolve() {
template.sinks.put(pin.getName(), pin);
}
}
template.pipAttributes = pipAttributes;
template.belRoutethroughMap = belRoutethroughMap;

return template;
Expand All @@ -274,10 +255,9 @@ public SiteTemplateReplace writeReplace() {
repl.belTemplates = belTemplates.values();
repl.compatibleTypes = compatibleTypes;
repl.routing = routing;
repl.reverseWireConnections = reverseWireConnections;
repl.reverseRouting = reverseRouting;
repl.sources = sources.values();
repl.sinks = sinks.values();
repl.pipAttributes = pipAttributes;
repl.belRoutethroughMap = belRoutethroughMap;

return repl;
Expand Down
32 changes: 2 additions & 30 deletions src/main/java/edu/byu/ece/rapidSmith/device/Tile.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public class Tile implements Serializable {
/** Unique Serialization ID */
private static final long serialVersionUID = 4859877066322216633L;
private static final long serialVersionUID = -4200781031171608914L;
private Device dev;
/** XDL Name of the tile */
private String name;
Expand Down Expand Up @@ -258,30 +258,6 @@ public void setWireHashMap(WireHashMap wires) {
this.wireConnections = wires;
}

/**
* This method adds a key/value pair to the wires HashMap.
*
* @param src The wire (or key) of the HashMap to add.
* @param dest The actual wire to add to the value or Wire[] in the HashMap.
*/
public void addConnection(int src, WireConnection dest) {
// Add the wire if it doesn't already exist
if (this.wireConnections.get(src) == null) {
WireConnection[] tmp = {dest};
this.wireConnections.put(src, tmp);
} else {
WireConnection[] currentConnections = this.wireConnections.get(src);
WireConnection[] tmp = new WireConnection[currentConnections.length + 1];
int i;
for (i = 0; i < currentConnections.length; i++) {
tmp[i] = currentConnections[i];
}
tmp[i] = dest;
Arrays.sort(tmp);
this.wireConnections.put(src, tmp);
}
}

/**
* Create Collection of TileWire objects for each wire in the tile.
* @return Collection of TileWire objects.
Expand Down Expand Up @@ -508,14 +484,12 @@ public String toString() {
}

private static class TileReplace implements Serializable {
private static final long serialVersionUID = 8084308269914591921L;
private static final long serialVersionUID = -3588973393824445640L;
private String name;
private TileType type;
private Site[] sites;
private WireHashMap wireConnections;
private WireHashMap reverseConnections;
private int[] sinks;
private int[] sources;

@SuppressWarnings("unused")
private Tile readResolve() {
Expand Down Expand Up @@ -544,8 +518,6 @@ private TileReplace writeReplace() {
repl.sites = sites;
repl.wireConnections = wireConnections;
repl.reverseConnections = reverseWireConnections;
repl.sinks = null;
repl.sources = null;

return repl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

import edu.byu.ece.rapidSmith.RSEnvironment;
import edu.byu.ece.rapidSmith.device.Device;
import edu.byu.ece.rapidSmith.device.xdlrc.XDLRCSource;

import java.io.IOException;
import java.nio.file.Path;

/**
* This class provides the base class for generating a new device and its
Expand Down Expand Up @@ -52,11 +52,11 @@ public DeviceFilesCreator(XDLRCRetriever xdlrcRetriever) {
public void createDevice() throws IOException, DeviceCreationException {
// Create XDLRC File if it already hasn't been created
System.out.println("Retrieving XDLRC file");
Path xdlrcFilePath = xdlrcRetriever.getXDLRCFile();
XDLRCSource source = xdlrcRetriever.getXDLRCSource();

// Initialize Parser
DeviceGenerator generator = new DeviceGenerator();
Device device = generator.generate(xdlrcFilePath);
Device device = generator.generate(source);

// Write the Device to File
System.out.println("Writing device to compact file");
Expand All @@ -69,11 +69,8 @@ public void createDevice() throws IOException, DeviceCreationException {

// Delete XDLRC file
System.out.println("Cleaning up XDLRC file.");
xdlrcRetriever.cleanupXDLRCFile();
xdlrcRetriever.cleanup();

// Building extended device info
System.out.println("Building extended info.");
new ExtendedDeviceInfo().buildExtendedInfo(device);
System.out.println("Finished writing extended info.");
}
}
Loading

0 comments on commit 3457f6b

Please sign in to comment.