file: main.cc
/* VLSI CAD Project 3 */
/* Placement Tool */
/* Recursive MinCut */
/* Fall 2000 Anno Domini */
/* Written by Suraj Sudhir */
/* ssudhir@ece.cmu.edu */
#include "main.h"
// chip data
int ChipX, ChipY; //Chip Dimensions
float K1, K2; //Delay Constants
int GatesInSite, PinsInSite;//per site constraints
double G; // square root of GatesInSite
int NumGates, NumNets; //global - total # of gates, nets
gateList *GateArr; //holds all nets connected to each gate
int *gateX, *gateY; //holds the (x,y) coordinates of each gate
int *tempX1, *tempX2; //temporarily hold (x,y) during horiz
int *tempY1, *tempY2; //and vert cuts
netList *NetArr; //holds all gates connected to each net
int *GatesPerNet; //number of gates per net;
int *gatePart; //partition where the gate lies.
int *tempPart1, *tempPart2; //for cutline selection -
//temporarily hold partition info
padList *PadArr; //pad connected to each net, if any
int *PadsPerNet; //total pads to that net
int NumPinsConnNets; //total pins
pinList *PinConnList; //nets connected by pin
int NumTimingPaths; //number of components in each timing path
timingList *TimingPaths; // each timing path
double *netLen; //length of each net
double *netDelay; //delay on each net
double TotalWireLen; //total wire length, of course
// other globals
int Rotate = 0; //alternately cut horiz/vert if both cuts
//yield equal wirelength
wishGui myGui; //Tcl/Tk stuff
char OpFileName[20] = "output"; //default;
int FirstRound = 1; //initialise hMetis only once
/////////////////////////////////////////////////
// performance parameters given at command line//
/////////////////////////////////////////////////
// number of partitions, for k-way
int NumPartitions = 2;
//how to handle balance correction during partitioning
int CapacityFix = FIRST;
//do the cutting step by step ? (debug)
int StepThru = 1;
//how many times to repeat mincut
int NumIters = 1;
//Metis Seed
int Seed = 654321;
//Average net weight
int NetWeight = 6;
//initializing scheme
int InitScheme = 1;
//optimize for...
int Optimization = MIN_WIRELENGTH;
//minimize critical path ?
int CriticalPathMinimize = 0;
////////////////////////////////
// main function of the placer//
////////////////////////////////
void main(int argc, char *argv[])
{
FILE *PinFile, *INetFile, *ONetFile;
int i,j;
if (argc == 1)
printUsage();
if (argc < 5)
{
cout << "ERROR: improper invocation of placer\n";
printUsage();
}
i=1;
while (i < argc)
{
switch (argv[i][1])
{
case 'p': PinFile = fopen(argv[++i],"r");
if(!PinFile)
{
cout << "PinFile " << argv[i] << "does not exist" << endl;
exit(1);
}
break;
case 'i': INetFile = fopen(argv[++i],"r");
if(!INetFile)
{
cout << "Input Netlist File " << argv[i] << "does not exist" << endl;
exit(1);
}
break;
case 'w': NumPartitions = atoi(argv[++i]);
break;
case 'c': CapacityFix = atoi(argv[++i]);
break;
case 's': StepThru = atoi(argv[++i]);
break;
case 'o': strcpy ( OpFileName, argv[++i] );
break;
case 't': NumIters = atoi(argv[++i]);
break;
case 'd': Seed = atoi(argv[++i]);
break;
case 'n': NetWeight = atoi(argv[++i]);
break;
case 'I': InitScheme = atoi(argv[++i]);
break;
case 'O': Optimization = atoi(argv[++i]);
break;
case 'C': CriticalPathMinimize = atoi(argv[++i]);
break;
default:i++;
}
}
/* read the netlist file */
readNetList(INetFile);
/* read the pins file */
readPinFile(PinFile);
G = sqrt(GatesInSite);
printf("G = %f\n",G);
/* get the path */
myGui.SetPath(__WISH_PATH__);
/* start the gui */
if(myGui.Start("simpleGui.tcl", -600, -600, 600, 600)== ERROR)
cerr<<"Error in Starting GUI \n";
/* start Metis */
MetisIntfc metis(NumGates,NumPinsConnNets,NumNets);
/* initial quadratic placement */
//quadPlace ( 0, 1, 1, ChipX-2, ChipY-2 );
/*recursive mincut to place the gates */
while (NumIters--)
{
recursiveMinCut(metis, 0, 1, 1, ChipX-2, ChipY-2);
initParts();
FirstRound = 1;
}
fflush(stdout);
free(tempX1); free(tempY1);
free(tempX2); free(tempY2);
computeWireDelay();
//write the output file
writeOutput();
while (1)
{
drawChip();
int i=0;
for(;i<50000000;i++);
int graphical_request = myGui.ProcessWishReq();
if(graphical_request == ERROR)
exit(0);
else if(graphical_request == 3)
{
// switch Animation
cerr<<"\n Asked to switch Animation"<<endl;
//animate = !animate;
}
else if (graphical_request == 1)
{
cerr<<"\n Asked to quit"<<endl;
break;
}
}
myGui.End();
}
//print the program usage
void printUsage()
{
cout << "VLSI CAD Course 18-760: " << endl;
cout << "Chip Placement Tool" << endl;
cout << "Usage: placer -p pinfile -i netlist {-s step -c balancing " << endl;
cout << " criteria -d seed -t iterations -w num_partitions " << endl;
cout << " -o outputfile -I initial placement -O optimization" << endl;
cout << " -n netweights -C cricicalpathmin" << endl;
cout << "-s : 0=nostep, 1=step" << endl;
cout << "-c : 1=move first gate, 2=move last gate, 3=random gate" << endl;
cout << " 4=least increase in wirelen, 5=most increase in wirelen" << endl;
cout << "-d : whatever value you please!" << endl;
cout << "-t : 0 or more" << endl;
cout << "-n : 1=constant, 2=unconstrained, 3=constrained" << endl;
cout << "-w : 2=twoway, 4=fourway. nothing else..." << endl;
cout << "-I : 1=all gates at (1,1), 2=all gates at (n,n), " << endl;
cout << " 3=all gates at (n/2,n/2), 4=gates spread out evenly" << endl;
cout << "-O : 1=congestion, 2=wirelength, 3=delay" << endl;
cout << "-C : 0=no minimization, 1=minimize" << endl;
exit(0);
}
C++ to HTML Conversion by ctoohtml