46 static void Io_NtkBuildLayout( FILE * pFile1, FILE *pFile2,
Abc_Ntk_t * pNtk,
double aspectRatio,
double whiteSpace,
unsigned coreCellArea );
47 static void Io_NtkWriteScl( FILE * pFile,
unsigned numCoreRows,
double layoutWidth );
48 static void Io_NtkWritePl( FILE * pFile,
Abc_Ntk_t * pNtk,
unsigned numTerms,
double layoutHeight,
double layoutWidth );
58 static inline double Abc_Rint(
double x ) {
return (
double)(int)x; }
80 if ( pNtkTemp == NULL )
82 fprintf( stdout,
"Writing BOOK has failed.\n" );
103 FILE * pFileNodes, * pFileNets, * pFileAux;
104 FILE * pFileScl, * pFilePl, * pFileWts;
106 unsigned coreCellArea=0;
112 strcpy(FileExt, FileName);
113 pFileNodes = fopen(
strcat(FileExt,
".nodes"),
"w" );
114 strcpy(FileExt, FileName);
115 pFileNets = fopen(
strcat(FileExt,
".nets"),
"w" );
116 strcpy(FileExt, FileName);
117 pFileAux = fopen(
strcat(FileExt,
".aux"),
"w" );
120 if ( (pFileNodes == NULL) || (pFileNets == NULL) || (pFileAux == NULL) )
123 fprintf( stdout,
"Io_WriteBook(): Cannot open the output files.\n" );
126 fprintf( pFileAux,
"RowBasedPlacement : %s.nodes %s.nets %s.scl %s.pl %s.wts",
127 FileName, FileName, FileName, FileName, FileName );
150 if ( pNtkTemp == pNtk )
156 fclose( pFileNodes );
159 strcpy(FileExt, FileName);
160 pFileScl = fopen(
strcat(FileExt,
".scl"),
"w" );
161 strcpy(FileExt, FileName);
162 pFilePl = fopen(
strcat(FileExt,
".pl"),
"w" );
163 strcpy(FileExt, FileName);
164 pFileWts = fopen(
strcat(FileExt,
".wts"),
"w" );
188 unsigned numTerms, numNodes, coreCellArea=0;
195 printf(
"NumNodes : %d\t", numNodes );
196 printf(
"NumTerminals : %d\n", numTerms );
197 fprintf( pFile,
"UCLA nodes 1.0\n");
198 fprintf( pFile,
"NumNodes : %d\n", numNodes );
199 fprintf( pFile,
"NumTerminals : %d\n", numTerms );
241 fprintf( pFile,
"i%s_input\t",
Abc_ObjName(pNet) );
242 fprintf( pFile,
"terminal ");
249 fprintf( pFile,
"o%s_output\t",
Abc_ObjName(pNet) );
250 fprintf( pFile,
"terminal ");
274 if (NodesOrPl ==
NODES)
275 fprintf( pFile,
" %d %d\n", 6, 1 );
305 fprintf( pFile,
"name\t" );
307 if(NodesOrPl ==
NODES)
333 if(NodesOrPl ==
NODES)
335 fprintf( pFile,
" %d %d\n", sizex, sizey );
415 printf(
"NumPins : %d\n\n", numPin );
416 fprintf( pFile,
"UCLA nets 1.0\n");
418 fprintf( pFile,
"NumPins : %d\n", numPin );
453 fprintf( pFile,
"i%s_input I\n",
Abc_ObjName(pNet) );
472 fprintf( pFile,
"name I : " );
475 fprintf( pFile,
"%.2f %.2f\n", .0, .0 );
481 fprintf( pFile,
"o%s_output O\n",
Abc_ObjName(pNet) );
500 fprintf( pFile,
"name O : " );
503 fprintf( pFile,
"%.2f %.2f\n", .0, .0 );
522 double targetLayoutArea = coreCellArea/(1.0-(whiteSpace/100.0));
523 unsigned numCoreRows=(aspectRatio>0.0) ? (
Abc_Rint(sqrt(targetLayoutArea/aspectRatio)/
coreHeight)) : 0;
526 double layoutHeight = numCoreRows *
coreHeight;
527 double layoutWidth =
Abc_Rint(targetLayoutArea/layoutHeight);
528 double actualLayoutArea = layoutWidth * layoutHeight;
530 printf(
"Core cell height(==site height) is %d\n", coreHeight );
531 printf(
"Total core cell width is %d giving an ave width of %f\n", totalWidth, (
double)(totalWidth/numCoreCells));
532 printf(
"Target Dimensions:\n" );
533 printf(
" Area : %f\n", targetLayoutArea );
534 printf(
" WS%% : %f\n", whiteSpace );
535 printf(
" AR : %f\n", aspectRatio );
536 printf(
"Actual Dimensions:\n" );
537 printf(
" Width : %f\n", layoutWidth );
538 printf(
" Height: %f (%d rows)\n", layoutHeight, numCoreRows);
539 printf(
" Area : %f\n", actualLayoutArea );
540 printf(
" WS%% : %f\n", 100*(actualLayoutArea-coreCellArea)/actualLayoutArea );
541 printf(
" AR : %f\n\n", layoutWidth/layoutHeight );
544 Io_NtkWritePl( pFilePl, pNtk, numTerms, layoutHeight, layoutWidth );
561 char * rowOrients[2] = {
"N",
"FS"};
563 double sitewidth=1.0;
568 fprintf( pFile,
"UCLA scl 1.0\n\n" );
569 fprintf( pFile,
"Numrows : %d\n\n", numCoreRows );
571 for( rowId=0 ; rowId<numCoreRows ; rowId++, origin_y +=
coreHeight )
573 fprintf( pFile,
"CoreRow Horizontal\n" );
574 fprintf( pFile,
" Coordinate : \t%d\n", origin_y);
575 fprintf( pFile,
" Height : \t%d\n",
coreHeight);
576 fprintf( pFile,
" Sitewidth : \t%d\n", (
unsigned)sitewidth );
577 fprintf( pFile,
" Sitespacing : \t%d\n", (
unsigned)spacing );
578 fprintf( pFile,
" Siteorient : \t%s\n", rowOrients[rowId%2] );
580 fprintf( pFile,
" Sitesymmetry : \t%c\n", symmetry );
582 fprintf( pFile,
" SubrowOrigin : \t%d Numsites : \t%d\n", 0, (
unsigned)layoutWidth );
583 fprintf( pFile,
"End\n" );
603 double layoutPerim = 2*layoutWidth + 2*layoutHeight;
604 double nextLoc_x, nextLoc_y;
606 unsigned termsOnTop, termsOnBottom, termsOnLeft, termsOnRight;
610 termsOnTop = termsOnBottom = (unsigned)(
Abc_Rint(numTerms*(layoutWidth/layoutPerim)));
611 termsOnLeft = numTerms - (termsOnTop+termsOnBottom);
612 termsOnRight = (unsigned)(ceil(termsOnLeft/2.0));
613 termsOnLeft -= termsOnRight;
621 assert( termsOnTop+termsOnBottom+termsOnLeft+termsOnRight == (
unsigned)
Vec_PtrSize(vOrderedTerms) );
623 printf(
"Done constructing layout region\n" );
624 printf(
"Terminals: %d\n", numTerms );
625 printf(
" Top: %d\n", termsOnTop );
626 printf(
" Bottom: %d\n", termsOnBottom );
627 printf(
" Left: %d\n", termsOnLeft );
628 printf(
" Right: %d\n", termsOnRight );
630 fprintf( pFile,
"UCLA pl 1.0\n\n" );
632 nextLoc_x = floor(.0);
633 nextLoc_y = ceil(layoutHeight + 2*
coreHeight);
634 delta = layoutWidth / termsOnTop;
635 for(t = 0; t < termsOnTop; t++)
644 fprintf( pFile,
"%d\t\t%d\t: %s /FIXED\n", (
int)
Abc_Rint(nextLoc_x), (
int)
Abc_Rint(nextLoc_y),
"FS" );
648 nextLoc_x = floor(.0);
650 delta = layoutWidth / termsOnBottom;
651 for(;t < termsOnTop+termsOnBottom; t++)
660 fprintf( pFile,
"%d\t\t%d\t: %s /FIXED\n", (
int)
Abc_Rint(nextLoc_x), (
int)
Abc_Rint(nextLoc_y),
"N" );
665 nextLoc_y = floor(.0);
666 delta = layoutHeight / termsOnLeft;
667 for(;t < termsOnTop+termsOnBottom+termsOnLeft; t++)
676 fprintf( pFile,
"%d\t\t%d\t: %s /FIXED\n", (
int)
Abc_Rint(nextLoc_x), (
int)
Abc_Rint(nextLoc_y),
"E" );
681 nextLoc_y = floor(.0);
682 delta = layoutHeight / termsOnRight;
683 for(;t < termsOnTop+termsOnBottom+termsOnLeft+termsOnRight; t++)
692 fprintf( pFile,
"%d\t\t%d\t: %s /FIXED\n", (
int)
Abc_Rint(nextLoc_x), (
int)
Abc_Rint(nextLoc_y),
"FW" );
701 fprintf( pFile,
"\t%d\t\t%d\t: %s\n", 0, 0,
"N" );
708 fprintf( pFile,
"\t%d\t\t%d\t: %s\n", 0, 0,
"N" );
727 unsigned termIdx=0, termCount=0;
728 int * pOrdered =
ABC_ALLOC(
int, numTerms);
731 Abc_Obj_t * pNeighbor = NULL, * pNextTerm;
734 for( i=0 ; i<numTerms ; i++ )
739 while( termCount < numTerms && termIdx < numTerms )
741 if( pOrdered[
Abc_ObjId(pNextTerm)] && !newNeighbor )
751 pNeighbor=
Io_NtkBfsPads( pNtk, pNextTerm, numTerms, pOrdered );
758 else if(termIdx < numTerms)
764 assert(termCount==numTerms);
765 return vOrderedTerms;
835 return ( foundNeighbor ) ? pNeighbor : pTerm;
857 return ( !
strcmp(((
char *)pNode->
pData),
"-0 1\n0- 1\n") ||
885 return ( !
strcmp(((
char *)pNode->
pData),
"00 1\n") );
963 return ( !
strcmp(((
char *)pNode->
pData),
"01 1\n10 1\n") || !
strcmp(((
char *)pNode->
pData),
"10 1\n01 1\n") );
987 return ( !
strcmp(((
char *)pNode->
pData),
"11 1\n00 1\n") || !
strcmp(((
char *)pNode->
pData),
"00 1\n11 1\n") );
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
static int Abc_NodeIsNor2(Abc_Obj_t *pNode)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static int Abc_NtkIsComb(Abc_Ntk_t *pNtk)
ABC_DLL void * Abc_FrameReadLibGen()
static int Abc_NtkHasSop(Abc_Ntk_t *pNtk)
static Abc_Ntk_t * Abc_NtkExdc(Abc_Ntk_t *pNtk)
static void Io_NtkWriteLatchNode(FILE *pFile, Abc_Obj_t *pLatch, int NodesOrPl)
static int Abc_NodeIsXor2(Abc_Obj_t *pNode)
static int Abc_NodeIsAnd2(Abc_Obj_t *pNode)
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
ABC_DLL int Abc_SopIsOrType(char *pSop)
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
ABC_DLL int Abc_NodeIsConst0(Abc_Obj_t *pNode)
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
static unsigned Io_NtkWriteNodeGate(FILE *pFile, Abc_Obj_t *pNode)
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
static void Io_NtkWriteIntNet(FILE *pFile, Abc_Obj_t *pNode)
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
static unsigned Io_NtkWriteNodes(FILE *pFile, Abc_Ntk_t *pNtk)
DECLARATIONS ///.
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Mio_Gate_t * Mio_LibraryReadAnd2(Mio_Library_t *pLib)
static int Abc_ObjIsPi(Abc_Obj_t *pObj)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
#define ABC_ALLOC(type, num)
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
static void Io_NtkBuildLayout(FILE *pFile1, FILE *pFile2, Abc_Ntk_t *pNtk, double aspectRatio, double whiteSpace, unsigned coreCellArea)
static int Abc_NtkWhiteboxNum(Abc_Ntk_t *pNtk)
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
static int Vec_PtrSize(Vec_Ptr_t *p)
static Abc_Obj_t * Io_NtkBfsPads(Abc_Ntk_t *pNtk, Abc_Obj_t *pCurrEntry, unsigned numTerms, int *pOrdered)
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
for(p=first;p->value< newval;p=p->next)
static void Vec_PtrRemove(Vec_Ptr_t *p, void *Entry)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
static double Abc_Rint(double x)
ABC_DLL int Abc_NodeIsBuf(Abc_Obj_t *pNode)
Mio_Gate_t * Mio_LibraryReadNand2(Mio_Library_t *pLib)
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
static int Abc_NodeIsNand2(Abc_Obj_t *pNode)
#define ABC_NAMESPACE_IMPL_END
void Io_WriteBookLogic(Abc_Ntk_t *pNtk, char *FileName)
FUNCTION DEFINITIONS ///.
#define Abc_NtkForEachNet(pNtk, pNet, i)
STRUCTURE DEFINITIONS ///.
#define Abc_NtkForEachLatch(pNtk, pObj, i)
static void Io_NtkWriteNets(FILE *pFile, Abc_Ntk_t *pNtk)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
double Mio_GateReadArea(Mio_Gate_t *pGate)
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
ABC_DLL int Abc_NodeIsInv(Abc_Obj_t *pNode)
static unsigned Io_NtkWriteIntNode(FILE *pFile, Abc_Obj_t *pNode, int NodesOrPl)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static void Io_NtkWritePiPoNodes(FILE *pFile, Abc_Ntk_t *pNtk)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
static int Abc_NodeIsXnor2(Abc_Obj_t *pNode)
#define ABC_CALLOC(type, num)
static void Io_NtkWriteScl(FILE *pFile, unsigned numCoreRows, double layoutWidth)
void Io_WriteBook(Abc_Ntk_t *pNtk, char *FileName)
static int Abc_ObjIsPo(Abc_Obj_t *pObj)
ABC_DLL int Abc_NodeIsConst1(Abc_Obj_t *pNode)
ABC_DLL int Abc_SopIsAndType(char *pSop)
static void Io_NtkWritePl(FILE *pFile, Abc_Ntk_t *pNtk, unsigned numTerms, double layoutHeight, double layoutWidth)
static int Abc_NodeIsOr2(Abc_Obj_t *pNode)
#define Abc_NtkForEachPo(pNtk, pPo, i)
static int Abc_NtkBlackboxNum(Abc_Ntk_t *pNtk)
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
static int Abc_ObjIsTerm(Abc_Obj_t *pObj)
char * Mio_GateReadName(Mio_Gate_t *pGate)
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
#define Abc_NtkForEachPi(pNtk, pPi, i)
static int Abc_NtkNetNum(Abc_Ntk_t *pNtk)
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
static Vec_Ptr_t * Io_NtkOrderingPads(Abc_Ntk_t *pNtk, Vec_Ptr_t *vTerms)