/********************************************************************************/ /* input: A file containing sizes of length and width of pfets and nfets */ /* within a specified range and their threshold voltages */ /* */ /* output: A Max file of comparator composed of selected size of inverters */ /* found in the 'fndsizes.c' */ /* */ /* Date: Mar. 29, 2001 */ /* By: Daegyu Lee */ /* The Pennsylvania State University */ /* Department of Computer Science and Engineering */ /* Copyright Daegyu Lee 2001 */ /* Revision 0.8 */ /********************************************************************************/ #include #include #define TRUE 1 #define FALSE 0 #define SP0 7820 /* space btwn origin and left x of nMOS */ #define SP1 1000 /* length of poly6 and poly9 in x */ typedef struct RECT { int LBX, LBY, RTX, RTY; } maxRect; void Warning_Exit() { printf( "Memory allocation fail !!\n" ); exit(-1); } main( int argc, char* argv[] ) { int i, j, displaceY, numOfBit, numOfComps, junkValue; int *lp, *wp, *ln, *wn; int numOfPct, startPctX, numOfNct, startNctX; char numStr[10], outFileName[100]; FILE *fp_in, *fp_out; maxRect pdif1, pdif2, pdif3; maxRect ndif1, ndif2, ndif3; maxRect pfet1, pfet2; maxRect nfet1, nfet2; maxRect poly1, poly2, poly3, poly4, poly5, poly6, poly7, poly8, poly9, poly10, poly11; maxRect m1_1, m1_2, m1_3, m1_4, m1_5, m1_6, m1_11, m1_12, m1_13, m1_14, m1_15, m1_16, m1_17, m1_18, m1_19, m1_20, m1_21, m1_22; maxRect m2_1, m2_2, m2_3, m2_4, m2_5, m2_6, m2_7, m2_8, m2_9, m2_10; maxRect ctP[500], ctN[500]; if( argc != 2) { printf( "Usage: makeCompV2 selectedSizesFile\n" ); exit(-1); } printf( "Displacement of comparators in Y = ? (Min.:2540) " ); scanf( "%d", &displaceY ); printf( "Which bit comparator is it ? " ); scanf( "%d", &numOfBit ); fp_in = fopen( argv[1], "r" ); numOfComps = 0; while( fscanf(fp_in, "%d %d %d %d", &junkValue, &junkValue, &junkValue, &junkValue) != EOF ) { numOfComps++; } fclose( fp_in ); lp = (int *) malloc( numOfComps*sizeof(int) ); if( lp == NULL ) Warning_Exit(); wp = (int *) malloc( numOfComps*sizeof(int) ); if( wp == NULL ) Warning_Exit(); ln = (int *) malloc( numOfComps*sizeof(int) ); if( ln == NULL ) Warning_Exit(); wn = (int *) malloc( numOfComps*sizeof(int) ); if( wn == NULL ) Warning_Exit(); fp_in = fopen( argv[1], "r" ); for( i=0; i m1_1.RTX-400 ) { numOfPct--; break; } } while( TRUE ); numOfNct = 0; startNctX = m1_4.LBX+100; do { ctN[numOfNct].LBX = startNctX; ctN[numOfNct].RTX = ctN[numOfNct].LBX + 300; startNctX = ctN[numOfNct].RTX + 300; numOfNct++; if( startNctX > m1_4.RTX-400 ) { numOfNct--; break; } } while( TRUE ); fprintf( fp_out, "SECTION RECTS {\n" ); fprintf( fp_out, "layer ndif\n" ); fprintf( fp_out, "%d %d %d %d\n", ndif1.LBX, ndif1.LBY, ndif1.RTX, ndif1.RTY ); fprintf( fp_out, "%d %d %d %d\n", ndif2.LBX, ndif2.LBY, ndif2.RTX, ndif2.RTY ); fprintf( fp_out, "%d %d %d %d\n", ndif3.LBX, ndif3.LBY, ndif3.RTX, ndif3.RTY ); fprintf( fp_out, "layer pdif\n" ); fprintf( fp_out, "%d %d %d %d\n", pdif1.LBX, pdif1.LBY, pdif1.RTX, pdif1.RTY ); fprintf( fp_out, "%d %d %d %d\n", pdif2.LBX, pdif2.LBY, pdif2.RTX, pdif2.RTY ); fprintf( fp_out, "%d %d %d %d\n", pdif3.LBX, pdif3.LBY, pdif3.RTX, pdif3.RTY ); fprintf( fp_out, "layer poly\n" ); fprintf( fp_out, "%d %d %d %d\n", poly1.LBX, poly1.LBY, poly1.RTX, poly1.RTY ); fprintf( fp_out, "%d %d %d %d\n", poly2.LBX, poly2.LBY, poly2.RTX, poly2.RTY ); fprintf( fp_out, "%d %d %d %d\n", poly3.LBX, poly3.LBY, poly3.RTX, poly3.RTY ); fprintf( fp_out, "%d %d %d %d\n", poly4.LBX, poly4.LBY, poly4.RTX, poly4.RTY ); fprintf( fp_out, "%d %d %d %d\n", poly6.LBX, poly6.LBY, poly6.RTX, poly6.RTY ); fprintf( fp_out, "%d %d %d %d\n", poly7.LBX, poly7.LBY, poly7.RTX, poly7.RTY ); fprintf( fp_out, "%d %d %d %d\n", poly8.LBX, poly8.LBY, poly8.RTX, poly8.RTY ); fprintf( fp_out, "%d %d %d %d\n", poly9.LBX, poly9.LBY, poly9.RTX, poly9.RTY ); fprintf( fp_out, "%d %d %d %d\n", poly10.LBX, poly10.LBY, poly10.RTX, poly10.RTY ); fprintf( fp_out, "%d %d %d %d\n", poly11.LBX, poly11.LBY, poly11.RTX, poly11.RTY ); fprintf( fp_out, "layer nfet\n" ); fprintf( fp_out, "%d %d %d %d\n", nfet1.LBX, nfet1.LBY, nfet1.RTX, nfet1.RTY ); fprintf( fp_out, "%d %d %d %d\n", nfet2.LBX, nfet2.LBY, nfet2.RTX, nfet2.RTY ); fprintf( fp_out, "layer pfet\n" ); fprintf( fp_out, "%d %d %d %d\n", pfet1.LBX, pfet1.LBY, pfet1.RTX, pfet1.RTY ); fprintf( fp_out, "%d %d %d %d\n", pfet2.LBX, pfet2.LBY, pfet2.RTX, pfet2.RTY ); fprintf( fp_out, "layer m1\n" ); fprintf( fp_out, "%d %d %d %d\n", m1_1.LBX, m1_1.LBY, m1_1.RTX, m1_1.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_2.LBX, m1_2.LBY, m1_2.RTX, m1_2.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_3.LBX, m1_3.LBY, m1_3.RTX, m1_3.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_4.LBX, m1_4.LBY, m1_4.RTX, m1_4.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_5.LBX, m1_5.LBY, m1_5.RTX, m1_5.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_6.LBX, m1_6.LBY, m1_6.RTX, m1_6.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_11.LBX, m1_11.LBY, m1_11.RTX, m1_11.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_12.LBX, m1_12.LBY, m1_12.RTX, m1_12.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_13.LBX, m1_13.LBY, m1_13.RTX, m1_13.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_14.LBX, m1_14.LBY, m1_14.RTX, m1_14.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_15.LBX, m1_15.LBY, m1_15.RTX, m1_15.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_16.LBX, m1_16.LBY, m1_16.RTX, m1_16.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_17.LBX, m1_17.LBY, m1_17.RTX, m1_17.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_18.LBX, m1_18.LBY, m1_18.RTX, m1_18.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_19.LBX, m1_19.LBY, m1_19.RTX, m1_19.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_20.LBX, m1_20.LBY, m1_20.RTX, m1_20.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_21.LBX, m1_21.LBY, m1_21.RTX, m1_21.RTY ); fprintf( fp_out, "%d %d %d %d\n", m1_22.LBX, m1_22.LBY, m1_22.RTX, m1_22.RTY ); fprintf( fp_out, "layer m2\n" ); fprintf( fp_out, "%d %d %d %d\n", m2_1.LBX, m2_1.LBY, m2_1.RTX, m2_1.RTY ); fprintf( fp_out, "%d %d %d %d\n", m2_2.LBX, m2_2.LBY, m2_2.RTX, m2_2.RTY ); fprintf( fp_out, "%d %d %d %d\n", m2_3.LBX, m2_3.LBY, m2_3.RTX, m2_3.RTY ); fprintf( fp_out, "%d %d %d %d\n", m2_4.LBX, m2_4.LBY, m2_4.RTX, m2_4.RTY ); fprintf( fp_out, "%d %d %d %d\n", m2_5.LBX, m2_5.LBY, m2_5.RTX, m2_5.RTY ); fprintf( fp_out, "%d %d %d %d\n", m2_6.LBX, m2_6.LBY, m2_6.RTX, m2_6.RTY ); fprintf( fp_out, "%d %d %d %d\n", m2_7.LBX, m2_7.LBY, m2_7.RTX, m2_7.RTY ); fprintf( fp_out, "%d %d %d %d\n", m2_8.LBX, m2_8.LBY, m2_8.RTX, m2_8.RTY ); fprintf( fp_out, "%d %d %d %d\n", m2_9.LBX, m2_9.LBY, m2_9.RTX, m2_9.RTY ); fprintf( fp_out, "%d %d %d %d\n", m2_10.LBX, m2_10.LBY, m2_10.RTX, m2_10.RTY ); fprintf( fp_out, "layer v12\n" ); fprintf( fp_out, "%d %d %d %d\n", m1_17.LBX+90, m1_17.LBY+90, m1_17.RTX-90, m1_17.RTY-90 ); fprintf( fp_out, "%d %d %d %d\n", m1_18.LBX+90, m1_18.LBY+90, m1_18.RTX-90, m1_18.RTY-90 ); fprintf( fp_out, "%d %d %d %d\n", m1_19.LBX+90, m1_19.LBY+90, m1_19.RTX-90, m1_19.RTY-90 ); fprintf( fp_out, "%d %d %d %d\n", m1_20.LBX+90, m1_20.LBY+90, m1_20.RTX-90, m1_20.RTY-90 ); fprintf( fp_out, "layer ct\n" ); fprintf( fp_out, "%d %d %d %d\n", m1_11.LBX+140, m1_11.LBY+140, m1_11.LBX+140+300, m1_11.LBY+140+300 ); /* ct on m1_11 and poly10 */ fprintf( fp_out, "%d %d %d %d\n", m1_12.LBX+140, m1_12.LBY+140, m1_12.LBX+140+300, m1_12.LBY+140+300 ); /* ct on m1_12 and poly11 */ for( j=0; j<=numOfPct; j++ ) /* CT on Metal1 in Pdif1 */ { ctP[j].LBY = m1_1.LBY+90; ctP[j].RTY = ctP[j].LBY+300; fprintf( fp_out, "%d %d %d %d\n", ctP[j].LBX, ctP[j].LBY, ctP[j].RTX, ctP[j].RTY ); } for( j=0; j<=numOfPct; j++ ) /* CT on Metal2 in Pdif2 */ { ctP[j].LBY = m1_2.LBY+90; ctP[j].RTY = ctP[j].LBY+300; fprintf( fp_out, "%d %d %d %d\n", ctP[j].LBX, ctP[j].LBY, ctP[j].RTX, ctP[j].RTY ); } for( j=0; j<=numOfPct; j++ ) /* CT on Metal3 in Pdif3 */ { ctP[j].LBY = m1_3.LBY+90; ctP[j].RTY = ctP[j].LBY+300; fprintf( fp_out, "%d %d %d %d\n", ctP[j].LBX, ctP[j].LBY, ctP[j].RTX, ctP[j].RTY ); } for( j=0; j<=numOfNct; j++ ) /* CT on Metal4 in Ndif1 */ { ctN[j].LBY = m1_4.LBY+90; ctN[j].RTY = ctN[j].LBY+300; fprintf( fp_out, "%d %d %d %d\n", ctN[j].LBX, ctN[j].LBY, ctN[j].RTX, ctN[j].RTY ); } for( j=0; j<=numOfNct; j++ ) /* CT on Metal5 in Ndif2 */ { ctN[j].LBY = m1_5.LBY+90; ctN[j].RTY = ctN[j].LBY+300; fprintf( fp_out, "%d %d %d %d\n", ctN[j].LBX, ctN[j].LBY, ctN[j].RTX, ctN[j].RTY ); } for( j=0; j<=numOfNct; j++ ) /* CT on Metal6 in Ndif3 */ { ctN[j].LBY = m1_6.LBY+90; ctN[j].RTY = ctN[j].LBY+300; fprintf( fp_out, "%d %d %d %d\n", ctN[j].LBX, ctN[j].LBY, ctN[j].RTX, ctN[j].RTY ); } fprintf( fp_out, "} SECTION RECTS\n" ); fprintf( fp_out, "\n" ); } fclose( fp_out ); }