* @param fileName The name of the compact device file
* @return True if operation was successful, false otherwise.
*/
public boolean readDeviceFromCompactFile(String fileName){
try {
Hessian2Input his = FileTools.getInputStream(fileName);
int size;
//=======================================================//
/* public static final String deviceFileVersion; */
//=======================================================//
String check = his.readString();
if(!check.equals(deviceFileVersion)){
MessageGenerator.briefErrorAndExit("Error, the current version " +
"of RAPIDSMITH is not compatible with the device " +
"file(s) present on this installation. Delete the 'device' " +
"directory and run the Installer again to regenerate new " +
"device files.\nCurrent RAPIDSMITH device file " +
"version: " + deviceFileVersion +", existing device file " +
"version: " + check + ".");
}
//=======================================================//
/* public int tileRows; */
//=======================================================//
rows = his.readInt();
//=======================================================//
/* public int tileColumns; */
//=======================================================//
columns = his.readInt();
//=======================================================//
/* - wirePool - */
//=======================================================//
WireConnection[] wires = new WireConnection[his.readInt()];
for(int i=0; i < wires.length; i++){
int part1 = his.readInt();
int part2 = his.readInt();
wires[i] = new WireConnection(0x7FFFFFFF&part1,part2 >> 16,(part2 << 16) >> 16,(part1 & 0x80000000) == 0x80000000);
}
//=======================================================//
/* - wireArrayPool - */
//=======================================================//
size = his.readInt();
ArrayList<WireConnection[]> wireArrays = new ArrayList<WireConnection[]>(size);
for(int i=0; i < size; i++){
int len = his.readInt();
WireConnection[] tmp = new WireConnection[len];
for(int j=0; j < len; j++){
tmp[j] = wires[his.readInt()];
}
wireArrays.add(tmp);
}
//Create a set of Integer objects to avoid duplication
Integer[] allInts = new Integer[getFamilyWireCount(fileName)];
for (int i = 0; i < allInts.length; i++) {
allInts[i] = new Integer(i);
}
//=======================================================//
/* - wireConnectionPool - */
//=======================================================//
size = his.readInt();
ArrayList<WireArrayConnection> wireConnections = new ArrayList<WireArrayConnection>();
for(int i=0; i < size; i++){
wireConnections.add(new WireArrayConnection(his.readInt(),his.readInt()));
}
//=======================================================//
/* - tileSinksPool - */
//=======================================================//
size = his.readInt();
ArrayList<HashMap<Integer,SinkPin>> sinks = new ArrayList<HashMap<Integer,SinkPin>>();
for(int i=0; i < size; i++){
int length = his.readInt();
HashMap<Integer,SinkPin> tmp = new HashMap<Integer,SinkPin>();
for(int j = 0; j < length; j++){
tmp.put(allInts[his.readInt()], new SinkPin(his.readInt(),his.readInt()));
}
sinks.add(tmp);
}
//=======================================================//
/* - tileSourcesPool - */
//=======================================================//
size = his.readInt();
ArrayList<int[]> sources = new ArrayList<int[]>();
for(int i=0; i < size; i++){
sources.add(FileTools.readIntArray(his));
}
//=======================================================//
/* - tileWiresPool - */
//=======================================================//
size = his.readInt();
ArrayList<WireHashMap> wireMaps = new ArrayList<WireHashMap>(size);
for(int i=0; i < size; i++){
wireMaps.add(FileTools.readWireHashMap(his,wireArrays,wireConnections));
}
//=======================================================//
/* public Tile[][] tiles; */
//=======================================================//
createTileArray();
tileMap = new HashMap<String, Tile>();
String[] tileNames = FileTools.readStringArray(his);
int[] tileTypes = FileTools.readIntArray(his);
int[] tileSinks = FileTools.readIntArray(his);
int[] tileSources = FileTools.readIntArray(his);
int[] tileWires = FileTools.readIntArray(his);
int[] primitiveSiteCount = FileTools.readIntArray(his);
TileType[] typeValues = TileType.values();
int index = 0;
for(Tile[] tileArray : tiles){
for(Tile t : tileArray){
// Name
t.setName(tileNames[index]);
// Type
t.setType(typeValues[tileTypes[index]]);
// Sinks
t.setSinks(sinks.get(tileSinks[index]));
// Sources
t.setSources(sources.get(tileSources[index]));
// Wires
t.setWireHashMap(wireMaps.get(tileWires[index]));
// Populate tileMap
tileMap.put(tileNames[index], t);
// Populate Device reference
t.setDevice(this);
index++;
}
}
//=======================================================//
/* public String partName; */
//=======================================================//
partName = his.readString();
//=======================================================//
/* - primitivePinPool - */
//=======================================================//
size = his.readInt();
ArrayList<HashMap<String,Integer>> primitivePinMaps = new ArrayList<HashMap<String,Integer>>();
for(int i=0; i < size; i++){
primitivePinMaps.add(FileTools.readHashMap(his, allInts));
}
//=======================================================//
/* public HashMap<String,Primitive> primitives; */
//=======================================================//
size = his.readInt();
PrimitiveType[] typeValues2 = PrimitiveType.values();
int idx = 0;
int zeros = 0;
for(Tile[] tileArray : tiles){
for(Tile t : tileArray){
if(primitiveSiteCount[idx] == 0){
t.setPrimitiveSites(null);
zeros++;
}
else{
PrimitiveSite[] p = new PrimitiveSite[primitiveSiteCount[idx]];
for(int i = 0; i < primitiveSiteCount[idx]; i++){
p[i] = FileTools.readPrimitiveSite(his, this, primitivePinMaps, typeValues2);
primitiveSites.put(p[i].getName(), p[i]);
}
t.setPrimitiveSites(p);
}
idx++;
}
}
//=======================================================//
/* public HashMap<Wire,PIPRouteThrough> routeThroughMap; */
//=======================================================//
size = his.readInt();
for(int i=0; i < size; i++){
PIPRouteThrough prt = new PIPRouteThrough(typeValues2[his.readInt()],his.readInt(),his.readInt());
routeThroughMap.put(wires[his.readInt()], prt);
}
//=======================================================//
/* - populateDeviceTileMap - */
//=======================================================//
reconstructTileMap();
his.close();
}
catch (FileNotFoundException e){
return false;
}
catch (IOException e){