Skip to content

Commit

Permalink
Changed how timing delay files loaded to ensure proper loading in sta…
Browse files Browse the repository at this point in the history
…ndalone jar.
  • Loading branch information
clavin-xlnx committed Dec 11, 2019
1 parent c8cad7b commit db484e7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
5 changes: 1 addition & 4 deletions src/com/xilinx/rapidwright/timing/DelayModelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

package com.xilinx.rapidwright.timing;

import com.xilinx.rapidwright.util.FileTools;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
Expand Down Expand Up @@ -60,8 +58,7 @@ class DelayModelBuilder {
* Prepare the appropriate input file for {@link #getDelayModel(String, String, String)}
*/
public static DelayModel getDelayModel(String series) {
String fileName = FileTools.getRapidWrightPath() + File.separator +
TimingModel.TIMING_DATA_DIR + File.separator +series+
String fileName = TimingModel.TIMING_DATA_DIR + File.separator +series+
File.separator + "intrasite_delay_terms.txt";
return getDelayModel("small", "text", fileName);
}
Expand Down
12 changes: 7 additions & 5 deletions src/com/xilinx/rapidwright/timing/DelayModelSourceFromText.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

package com.xilinx.rapidwright.timing;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -36,6 +36,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.xilinx.rapidwright.util.FileTools;

/**
* An implementation of DelayModelSource, used to provide data source to DelayModel class.
*/
Expand Down Expand Up @@ -210,16 +212,16 @@ private void storeIntraSiteDelayArc(String siteName, String line) {
* Parse and dispatch each line of the given file to either storeLogicDelayArc or storeIntraSiteDelayArc.
* @param fileName Specify the text file to load logic and intra-site delays from.
*/
private void read(String fileName) {
private void readIntraSiteDelays(String fileName) {

FileInputStream inputStream = null;
InputStream inputStream = null;
Scanner sc = null;

String siteName = null;
String belName = null;

try {
inputStream = new FileInputStream(fileName);
inputStream = FileTools.getRapidWrightResourceInputStream(fileName);
sc = new Scanner(inputStream, "UTF-8");
while (sc.hasNextLine()) {
// Make canonical from "," without spaces
Expand Down Expand Up @@ -285,7 +287,7 @@ public DelayModelSourceFromText(String fileName) {
logicDelays = new ArrayList<DelayEntry>();
intraSiteDelays = new ArrayList<DelayEntry>();
configCodeMap = new HashMap<String, Short>();
read(fileName);
readIntraSiteDelays(fileName);
}

// ************************ helper methods ***********************
Expand Down
23 changes: 13 additions & 10 deletions src/com/xilinx/rapidwright/timing/TimingModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -225,8 +226,7 @@ public void build() {
}
forDebugTimingGroupByPorts = new LinkedHashMap<>();
String series = device.getSeries().name().toLowerCase();
String fileName = FileTools.getRapidWrightPath() + File.separator +
TimingModel.TIMING_DATA_DIR + File.separator +series+
String fileName = TimingModel.TIMING_DATA_DIR + File.separator +series+
File.separator + "intersite_delay_terms.txt";
if (!readDelayTerms(fileName)) {
throw new RuntimeException("Error reading file:" + fileName);
Expand Down Expand Up @@ -456,9 +456,9 @@ protected List<TimingGroup> determineGroups(List<Node> nodes, List<IntentCode> n
*/
protected boolean readDelayTerms(String filename) {
boolean result = true;
BufferedReader br;
InputStream in = FileTools.getRapidWrightResourceInputStream(filename);
try {
br = new BufferedReader(new FileReader(filename));
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String line = "";
int lineCntr = 0;
while ((line=br.readLine()) != null) {// && line.length() != 0) {
Expand Down Expand Up @@ -544,13 +544,16 @@ protected boolean readDelayTerms(String filename) {
else if (split[0].equalsIgnoreCase("FAR_MAX")) FAR_MAX =(int) Math.floor(value);

else {
if (split.length == 2)
System.err.println("Bad formatted line:"+lineCntr+": \""+split[0]+"\"");
else
System.err.println("Unrecognized term on line:"+lineCntr+": \""+split[0]+"\"");
System.exit(1);
String errMessage;
if (split.length == 2) {
errMessage = "Bad formatted line:"+lineCntr+": \""+split[0]+"\"";
} else {
errMessage = "Unrecognized term on line:"+lineCntr+": \""+split[0]+"\"";
}
throw new RuntimeException("ERROR: " + errMessage);
}
}
br.close();
} catch (IOException e) {
e.printStackTrace();
result = false;
Expand Down

0 comments on commit db484e7

Please sign in to comment.