tile.setDevice(this);
}
}
try{
FileOutputStream fos = new FileOutputStream(fileName);
Hessian2Output h2os = new Hessian2Output(fos);
Deflation deflate = new Deflation();
Hessian2Output hos = deflate.wrap(h2os);
/* DEBUG */ Long[] locations = new Long[2];
/* DEBUG */ locations[1] = fos.getChannel().position();
/* DEBUG */ System.out.println("\n");
MessageGenerator.printHeader("File Usage Statistics");
//=======================================================//
/* public static final String deviceFileVersion; */
//=======================================================//
hos.writeString(deviceFileVersion);
/* DEBUG */ debugWritingSize(hos,fos,"deviceFileVersion",locations);
//=======================================================//
/* public int tileRows; */
//=======================================================//
hos.writeInt(rows);
/* DEBUG */ debugWritingSize(hos,fos,"tileRows",locations);
//=======================================================//
/* public int tileColumns; */
//=======================================================//
hos.writeInt(columns);
/* DEBUG */ debugWritingSize(hos,fos,"tileColumns",locations);
//=======================================================//
/* - wirePool - */
//=======================================================//
hos.writeInt(wirePool.getEnumerations().size());
for(WireConnection w : wirePool.getEnumerations()){
int mask = w.isPIP() ? 0x80000000 : 0x0;
hos.writeInt(mask | (w.getWire()));
hos.writeInt((w.getRowOffset() << 16) | (w.getColumnOffset() & 0xFFFF));
}
/* DEBUG */ debugWritingSize(hos,fos,"wirePool",locations);
//=======================================================//
/* - wireArrayPool - */
//=======================================================//
hos.writeInt(wireArrayPool.getEnumerations().size());
for(WireArray wireArray : wireArrayPool.getEnumerations()){
hos.writeInt(wireArray.array.length);
/*if(wireArray.array.length > 128){
System.out.println("Bad Assumption");
System.exit(1);
}*/
for(WireConnection w : wireArray.array){
hos.writeInt(wirePool.getEnumerationValue(w));
}
}
/* DEBUG */ debugWritingSize(hos,fos,"wireArrayPool",locations);
//=======================================================//
/* - wireConnectionPool - */
//=======================================================//
hos.writeInt(wireConnectionPool.getEnumerations().size());
for(WireArrayConnection wc : wireConnectionPool.getEnumerations()){
hos.writeInt(wc.wire);
hos.writeInt(wc.wireArrayEnum);
}
/* DEBUG */ debugWritingSize(hos,fos,"wireConnectionPool",locations);
//=======================================================//
/* - tileSinksPool - */
//=======================================================//
hos.writeInt(tileSinksPool.getEnumerations().size());
for(TileSinks s : tileSinksPool.getEnumerations()){
hos.writeInt(s.sinks.size());
for(Integer key: s.sinks.keySet()) {
SinkPin sp = s.sinks.get(key);
hos.writeInt(key);
hos.writeInt(sp.switchMatrixSinkWire);
hos.writeInt(sp.switchMatrixTileOffset);
}
}
/* DEBUG */ debugWritingSize(hos,fos,"tileSinksPool",locations);
//=======================================================//
/* - tileSourcesPool - */
//=======================================================//
hos.writeInt(tileSourcesPool.getEnumerations().size());
for(TileSources s : tileSourcesPool.getEnumerations()){
FileTools.writeIntArray(hos, s.sources);
}
/* DEBUG */ debugWritingSize(hos,fos,"tileSourcesPool",locations);
//=======================================================//
/* - tileWiresPool - */
//=======================================================//
hos.writeInt(tileWiresPool.getEnumerations().size());
for(TileWires tw : tileWiresPool.getEnumerations()){
FileTools.writeWireHashMap(hos, tw.wires, wireArrayPool, wireConnectionPool);
}
/* DEBUG */ debugWritingSize(hos,fos,"tileWiresPool",locations);
//=======================================================//
/* public Tile[][] tiles; */
//=======================================================//
int index = 0;
String[] tileNames = new String[rows*columns];
int[] tileTypes = new int[rows*columns];
int[] tileSinks = new int[rows*columns];
int[] tileSources = new int[rows*columns];
int[] tileWires = new int[rows*columns];
int[] primitiveSitesCount = new int[rows*columns];
for(Tile[] tileArray : tiles){
for(Tile t : tileArray){
// Name
tileNames[index] = t.getName();
// Type
tileTypes[index] = t.getType().ordinal();
// Sinks
tileSinks[index] = tileSinksPool.getEnumerationValue(new TileSinks(t.getSinks()));
// Sources
tileSources[index] = tileSourcesPool.getEnumerationValue(new TileSources(t.getSources()));
// Wires
tileWires[index] = tileWiresPool.getEnumerationValue(new TileWires(t.getWireHashMap()));
// PrimitiveSites Count
primitiveSitesCount[index] = t.getPrimitiveSites() == null ? 0 : t.getPrimitiveSites().length;
index++;
}
}
FileTools.writeStringArray(hos, tileNames);
FileTools.writeIntArray(hos, tileTypes);
FileTools.writeIntArray(hos, tileSinks);
FileTools.writeIntArray(hos, tileSources);
FileTools.writeIntArray(hos, tileWires);
FileTools.writeIntArray(hos, primitiveSitesCount);
/* DEBUG */ debugWritingSize(hos,fos,"tiles[][]",locations);
//=======================================================//
/* public String partName; */
//=======================================================//
//FileTools.writeString(dos, partName);
hos.writeString(partName);
/* DEBUG */ debugWritingSize(hos,fos,"partName",locations);
//=======================================================//
/* - primitivePinPool - */
//=======================================================//
hos.writeInt(primitivePinPool.getEnumerations().size());
for(PrimitivePinMap map : primitivePinPool.getEnumerations()){
FileTools.writeHashMap(hos, map.pins);
}
/* DEBUG */ debugWritingSize(hos,fos,"primitivePinPool",locations);
//=======================================================//
/* public HashMap<String,Primitive> primitives; */
//=======================================================//
hos.writeInt(primitiveSites.values().size());
for(Tile[] tileArray : tiles){
for(Tile t : tileArray){
if(t.getPrimitiveSites() != null){
for(PrimitiveSite p : t.getPrimitiveSites()){
FileTools.writePrimitiveSite(hos, p, this, primitivePinPool);
}
}
}
}
/* DEBUG */ debugWritingSize(hos,fos,"primitives",locations);
//=======================================================//
/* public HashMap<Wire,PIPRouteThrough> routeThroughMap; */
//=======================================================//
hos.writeInt(routeThroughMap.size());
for(WireConnection w : routeThroughMap.keySet()){
PIPRouteThrough p = routeThroughMap.get(w);
hos.writeInt(p.getType().ordinal());
hos.writeInt(p.getInWire());
hos.writeInt(p.getOutWire());
hos.writeInt(wirePool.getEnumerationValue(w));
}
/* DEBUG */ debugWritingSize(hos,fos,"routeThroughMap",locations);
/* DEBUG */ System.out.println("------------------------------------------");
/* DEBUG */ System.out.printf("%10d bytes : %s\n\n",(fos.getChannel().position()),"Total");
hos.close();
fos.close();
}
catch (IOException e){
return false;
}