68static int Ver_ParseAttachBoxes(
Ver_Man_t * pMan );
75static void Ver_ParseRemoveSuffixTable(
Ver_Man_t * pMan );
77static inline int Ver_NtkIsDefined(
Abc_Ntk_t * pNtkBox ) {
assert( pNtkBox->
pName );
return Abc_NtkPiNum(pNtkBox) || Abc_NtkPoNum(pNtkBox); }
78static inline int Ver_ObjIsConnected(
Abc_Obj_t * pObj ) {
assert( Abc_ObjIsBox(pObj) );
return Abc_ObjFaninNum(pObj) || Abc_ObjFanoutNum(pObj); }
109 p->pFileName = pFileName;
111 if (
p->pReader == NULL )
117 p->vNames = Vec_PtrAlloc( 100 );
118 p->vStackFn = Vec_PtrAlloc( 100 );
119 p->vStackOp = Vec_IntAlloc( 100 );
120 p->vPerm = Vec_IntAlloc( 100 );
123 p->pDesign->pLibrary = pGateLib;
147 Vec_PtrFree(
p->vNames );
148 Vec_PtrFree(
p->vStackFn );
149 Vec_IntFree(
p->vStackOp );
150 Vec_IntFree(
p->vPerm );
170 p = Ver_ParseStart( pFileName, pGateLib );
173 p->fUseMemMan = fUseMemMan;
177 p->pDesign->pManFunc = NULL;
180 Ver_ParseInternal(
p );
182 pDesign =
p->pDesign;
200void Ver_ParseInternal(
Ver_Man_t * pMan )
212 if ( pToken == NULL )
214 if (
strcmp( pToken,
"module" ) )
216 sprintf( pMan->sError,
"Cannot read \"module\" directive." );
221 if ( !Ver_ParseModule(pMan) )
225 pMan->pProgress = NULL;
228 if ( !Ver_ParseAttachBoxes( pMan ) )
240 sprintf( pMan->sError,
"The network check has failed for network %s.", pNtk->
pName );
282 fprintf(
p->Output,
"%s: %s\n",
p->pFileName,
p->sError );
284 fprintf(
p->Output,
"%s (line %d): %s\n",
287 Ver_ParseFreeData(
p );
311 pNtkNew->
pSpec = NULL;
333 if ( !
strcmp( pName,
"1\'b0" ) || !
strcmp( pName,
"1\'bx" ) )
335 if ( !
strcmp( pName,
"1\'b1" ) )
361 pNtk->
pManFunc = pMan->pDesign->pGenlib;
365 sprintf( pMan->sError,
"The network %s appears to have both gates and assign statements. Currently such network are not allowed. One way to fix this problem might be to replace assigns by buffers from the library.", pNtk->
pName );
378 pNtk->
pManFunc = pMan->pDesign->pManFunc;
382 sprintf( pMan->sError,
"The network %s appears to have both gates and assign statements. Currently such network are not allowed. One way to fix this problem might be to replace assigns by buffers from the library.", pNtk->
pName );
406 char * pWord, Symbol;
418 sprintf( pMan->sError,
"Cannot find \"(\" after \"module\" in network %s.", pNtk->
pName );
428 }
while ( Symbol ==
',' );
435 sprintf( pMan->sError,
"Expected closing parenthesis after \"module\"." );
447 if ( !
strcmp( pWord,
"input" ) )
449 else if ( !
strcmp( pWord,
"output" ) )
451 else if ( !
strcmp( pWord,
"reg" ) )
452 RetValue = Ver_ParseSignal( pMan, pNtk,
VER_SIG_REG );
453 else if ( !
strcmp( pWord,
"wire" ) )
455 else if ( !
strcmp( pWord,
"inout" ) )
468 if ( !
strcmp( pWord,
"and" ) )
469 RetValue = Ver_ParseGateStandard( pMan, pNtk,
VER_GATE_AND );
470 else if ( !
strcmp( pWord,
"or" ) )
471 RetValue = Ver_ParseGateStandard( pMan, pNtk,
VER_GATE_OR );
472 else if ( !
strcmp( pWord,
"xor" ) )
473 RetValue = Ver_ParseGateStandard( pMan, pNtk,
VER_GATE_XOR );
474 else if ( !
strcmp( pWord,
"buf" ) )
475 RetValue = Ver_ParseGateStandard( pMan, pNtk,
VER_GATE_BUF );
476 else if ( !
strcmp( pWord,
"nand" ) )
477 RetValue = Ver_ParseGateStandard( pMan, pNtk,
VER_GATE_NAND );
478 else if ( !
strcmp( pWord,
"nor" ) )
479 RetValue = Ver_ParseGateStandard( pMan, pNtk,
VER_GATE_NOR );
480 else if ( !
strcmp( pWord,
"xnor" ) )
481 RetValue = Ver_ParseGateStandard( pMan, pNtk,
VER_GATE_XNOR );
482 else if ( !
strcmp( pWord,
"not" ) )
483 RetValue = Ver_ParseGateStandard( pMan, pNtk,
VER_GATE_NOT );
485 else if ( !
strcmp( pWord,
"dff" ) )
486 RetValue = Ver_ParseFlopStandard( pMan, pNtk );
488 else if ( !
strcmp( pWord,
"assign" ) )
489 RetValue = Ver_ParseAssign( pMan, pNtk );
490 else if ( !
strcmp( pWord,
"always" ) )
491 RetValue = Ver_ParseAlways( pMan, pNtk );
492 else if ( !
strcmp( pWord,
"initial" ) )
493 RetValue = Ver_ParseInitial( pMan, pNtk );
494 else if ( !
strcmp( pWord,
"endmodule" ) )
497 RetValue = Ver_ParseGate( pMan, pNtk, pGate );
500 else if ( !
strcmp( pWord,
"wire" ) )
505 RetValue = Ver_ParseBox( pMan, pNtk, pNtkTemp );
521 if ( Abc_NtkNodeNum(pNtk) > 0 || Abc_NtkBoxNum(pNtk) > 0 )
530 pBox = Abc_NtkCreateBlackbox(pNtk);
533 pTerm = Abc_NtkCreateBi(pNtk);
539 pTerm = Abc_NtkCreateBo(pNtk);
547 Ver_ParseRemoveSuffixTable( pMan );
566 *pnMsb = *pnLsb = -1;
567 if ( pMan->tName2Suffix == NULL )
569 if ( !
st__lookup( pMan->tName2Suffix, (
char *)pWord, (
char **)&Value ) )
571 *pnMsb = (Value >> 8) & 0xff;
572 *pnLsb = Value & 0xff;
590 if ( pMan->tName2Suffix == NULL )
594 assert( nMsb >= 0 && nMsb < 128 );
595 assert( nLsb >= 0 && nLsb < 128 );
596 Value = (nMsb << 8) | nLsb;
612void Ver_ParseRemoveSuffixTable(
Ver_Man_t * pMan )
615 char * pKey, * pValue;
616 if ( pMan->tName2Suffix == NULL )
618 st__foreach_item( pMan->tName2Suffix, gen, (
const char **)&pKey, (
char **)&pValue )
621 pMan->tName2Suffix = NULL;
637 char * pWord = *ppWord, * pTemp;
639 assert( pWord[0] ==
'[' );
641 nMsb = atoi( pWord + 1 );
643 while ( *pWord && *pWord !=
':' && *pWord !=
']' )
647 sprintf( pMan->sError,
"Cannot find closing bracket in this line." );
656 nLsb = atoi( pWord + 1 );
658 while ( *pWord && *pWord !=
']' )
662 sprintf( pMan->sError,
"Cannot find closing bracket in this line." );
670 if ( *pWord ==
'\\' )
674 while ( *pTemp && *pTemp !=
' ' )
680 assert( nMsb >= 0 && nLsb >= 0 );
704 assert( pWord[Length-1] ==
']' );
706 for ( pCur = pWord + Length - 2; pCur != pWord; pCur-- )
707 if ( *pCur ==
':' || *pCur ==
'[' )
711 sprintf( pMan->sError,
"Cannot find opening bracket in signal name %s.", pWord );
717 *pnMsb = *pnLsb = atoi(pCur+1);
723 *pnLsb = atoi(pCur+1);
725 for ( pCur = pWord + Length - 2; pCur != pWord; pCur-- )
730 sprintf( pMan->sError,
"Cannot find opening bracket in signal name %s.", pWord );
736 *pnMsb = atoi(pCur+1);
756 assert( pWord[0] >=
'1' && pWord[1] <=
'9' );
759 while ( *pWord && *pWord !=
'\'' )
763 sprintf( pMan->sError,
"Cannot find symbol \' in the constant." );
771 sprintf( pMan->sError,
"Currently can only handle binary constants." );
777 Vec_PtrClear( pMan->vNames );
778 for ( i = 0; i < nBits; i++ )
780 if ( pWord[i] !=
'0' && pWord[i] !=
'1' && pWord[i] !=
'x' )
782 sprintf( pMan->sError,
"Having problem parsing the binary constant." );
786 if ( pWord[i] ==
'x' )
787 Vec_PtrPush( pMan->vNames, (
void *)0 );
789 Vec_PtrPush( pMan->vNames, (
void *)(ABC_PTRUINT_T)(pWord[i]-
'0') );
808 char Buffer[1000], Symbol, * pWord;
809 int nMsb, nLsb, Bit, Limit, i;
818 if ( !
strcmp(pWord,
"wire") )
822 if ( pWord[0] ==
'[' && !pMan->fNameLast )
824 assert( nMsb == -1 && nLsb == -1 );
837 if ( nMsb == -1 && nLsb == -1 )
840 Ver_ParseCreatePi( pNtk, pWord );
842 Ver_ParseCreatePo( pNtk, pWord );
848 assert( nMsb >= 0 && nLsb >= 0 );
852 Limit = nMsb > nLsb? nMsb - nLsb + 1: nLsb - nMsb + 1;
853 for ( i = 0, Bit = nLsb; i < Limit; i++, Bit = nMsb > nLsb ? Bit + 1: Bit - 1 )
857 sprintf( Buffer,
"%s[%d]", pWord, Bit );
859 sprintf( Buffer,
"%s", pWord );
861 Ver_ParseCreatePi( pNtk, Buffer );
863 Ver_ParseCreatePo( pNtk, Buffer );
876 sprintf( pMan->sError,
"Cannot parse signal line (expected , or ;)." );
897 char * pWord, * pWord2;
903 if ( pWord[0] ==
'@' )
914 if (
strcmp( pWord,
"begin" ) )
919 if ( !fStopAfterOne )
926 if ( !
strcmp( pWord,
"end" ) )
933 sprintf( pMan->sError,
"Cannot read the always statement for %s (output wire is not defined).", pWord );
939 if ( Symbol !=
'<' && Symbol !=
'=' )
941 sprintf( pMan->sError,
"Cannot read the assign statement for %s (expected <= or =).", pWord );
952 if ( pWord2 == NULL )
955 if ( pWord2[0] ==
'~' )
958 pNet2 = Ver_ParseCreateInv( pNtk, pNet2 );
964 sprintf( pMan->sError,
"Cannot read the always statement for %s (input wire is not defined).", pWord2 );
969 Ver_ParseCreateLatch( pNtk, pNet2, pNet );
996 char * pWord, * pEquation;
1000 if ( pWord == NULL )
1004 if (
strcmp( pWord,
"begin" ) )
1009 if ( !fStopAfterOne )
1013 if ( pWord == NULL )
1016 if ( !
strcmp( pWord,
"end" ) )
1023 sprintf( pMan->sError,
"Cannot read the initial statement for %s (output wire is not defined).", pWord );
1029 if ( Symbol !=
'<' && Symbol !=
'=' )
1031 sprintf( pMan->sError,
"Cannot read the assign statement for %s (expected <= or =).", pWord );
1035 if ( Symbol ==
'<' )
1042 if ( pEquation == NULL )
1045 if ( Abc_ObjFaninNum(pNet) == 0 )
1047 sprintf( pMan->sError,
"Cannot find the latch to assign the initial value." );
1051 pNode = Abc_ObjFanin0(Abc_ObjFanin0(pNet));
1052 assert( Abc_ObjIsLatch(pNode) );
1054 if ( !
strcmp(pEquation,
"0") || !
strcmp(pEquation,
"1\'b0") )
1055 Abc_LatchSetInit0( pNode );
1056 else if ( !
strcmp(pEquation,
"1") || !
strcmp(pEquation,
"1\'b1") )
1057 Abc_LatchSetInit1( pNode );
1062 sprintf( pMan->sError,
"Incorrect initial value of the latch %s.",
Abc_ObjName(pNet) );
1070 if ( fStopAfterOne )
1089 char Buffer[1000], Buffer2[2000];
1092 char * pWord, * pName, * pEquation;
1095 int i, Bit, Limit, Length, fReduction;
1111 if ( pWord == NULL )
1113 if (
strcmp(pWord,
"#1") == 0 )
1119 Limit = nMsb > nLsb? nMsb - nLsb + 1: nLsb - nMsb + 1;
1120 if ( nMsb >= 0 && nLsb >= 0 && Limit > 1 )
1123 if ( !
strcmp(pWord,
"1\'h0") )
1124 strcpy( Buffer,
"1\'b0" );
1125 else if ( !
strcmp(pWord,
"1\'h1") )
1126 strcpy( Buffer,
"1\'b1" );
1132 sprintf( pMan->sError,
"Cannot read the assign statement for %s (expected equality sign).", pWord );
1138 if ( pWord == NULL )
1141 if ( !(pWord[0] >=
'0' && pWord[0] <=
'9') )
1143 sprintf( pMan->sError,
"Currently can only assign vector-signal \"%s\" to be a constant.", Buffer );
1152 Limit = nMsb > nLsb? nMsb - nLsb + 1: nLsb - nMsb + 1;
1153 if ( Limit != Vec_PtrSize(pMan->vNames) )
1155 sprintf( pMan->sError,
"The constant size (%d) is different from the signal\"%s\" size (%d).",
1156 Vec_PtrSize(pMan->vNames), Buffer, Limit );
1161 for ( i = 0, Bit = nLsb; i < Limit; i++, Bit = nMsb > nLsb ? Bit + 1: Bit - 1 )
1164 if ( Vec_PtrEntry( pMan->vNames, Limit-1-i ) )
1174 sprintf( Buffer2,
"%s[%d]", Buffer, Bit );
1178 sprintf( pMan->sError,
"Cannot read the assign statement for %s (output wire is not defined).", pWord );
1191 if ( pWord[0] ==
'{' && !pMan->fNameLast )
1196 pWord[
strlen(pWord)-1] = 0;
1197 assert( pWord[0] !=
'\\' );
1203 sprintf( pMan->sError,
"Cannot read the assign statement for %s (output wire is not defined).", pWord );
1210 sprintf( pMan->sError,
"Cannot read the assign statement for %s (expected equality sign).", pWord );
1222 if ( pEquation == NULL )
1230 Vec_PtrClear( pMan->vNames );
1231 if ( pMan->fMapped )
1233 if ( !
strcmp( pEquation,
"1\'b0" ) )
1235 else if ( !
strcmp( pEquation,
"1\'b1" ) )
1240 if ( *pEquation ==
'\\' )
1243 pEquation[
strlen(pEquation) - 1] = 0;
1247 sprintf( pMan->sError,
"Cannot read Verilog with non-trivial assignments in the mapped netlist." );
1251 Vec_PtrPush( pMan->vNames, (
void *)(ABC_PTRUINT_T)
strlen(pEquation) );
1252 Vec_PtrPush( pMan->vNames, pEquation );
1255 if ( pFunc == NULL )
1257 sprintf( pMan->sError,
"Reading assign statement for node %s has failed because the genlib library has no buffer.",
Abc_ObjName(pNet) );
1265 if ( !
strcmp(pEquation,
"0") || !
strcmp(pEquation,
"1\'b0") || !
strcmp(pEquation,
"1\'bx") )
1267 else if ( !
strcmp(pEquation,
"1") || !
strcmp(pEquation,
"1\'b1") )
1269 else if ( fReduction )
1273 if ( pFunc == NULL )
1281 pNode = Abc_NtkCreateNode( pNtk );
1282 pNode->
pData = pFunc;
1285 for ( i = 0; i < Vec_PtrSize(pMan->vNames)/2; i++ )
1288 Length = (int)(ABC_PTRUINT_T)Vec_PtrEntry( pMan->vNames, 2*i );
1289 pName = (
char *)Vec_PtrEntry( pMan->vNames, 2*i + 1 );
1293 if ( !
strcmp(pName,
"1\'h0") )
1295 else if ( !
strcmp(pName,
"1\'h1") )
1302 sprintf( pMan->sError,
"Cannot read the assign statement for %s (input wire %s is not defined).", pWord, pName );
1311 if ( Symbol ==
',' )
1313 if ( Symbol ==
';' )
1335 char * pWord, Symbol;
1345 sprintf( pMan->sError,
"Cannot parse a standard gate (expected opening parenthesis)." );
1352 pNode = Abc_NtkCreateNode( pNtk );
1359 if ( pWord == NULL )
1365 sprintf( pMan->sError,
"Net is missing in gate %s.", pWord );
1370 if ( Abc_ObjFanoutNum(pNode) == 0 )
1377 if ( Symbol ==
')' )
1380 if ( Symbol !=
',' )
1382 sprintf( pMan->sError,
"Cannot parse a standard gate %s (expected closing parenthesis).",
Abc_ObjName(Abc_ObjFanout0(pNode)) );
1390 sprintf( pMan->sError,
"Buffer or interver with multiple fanouts %s (currently not supported).",
Abc_ObjName(Abc_ObjFanout0(pNode)) );
1399 sprintf( pMan->sError,
"Cannot read standard gate %s (expected closing semicolumn).",
Abc_ObjName(Abc_ObjFanout0(pNode)) );
1432 char * pWord, Symbol;
1441 sprintf( pMan->sError,
"Cannot parse a standard gate (expected opening parenthesis)." );
1449 if ( pWord == NULL )
1453 if ( pNetLo == NULL )
1455 sprintf( pMan->sError,
"Net is missing in gate %s.", pWord );
1463 if ( Symbol ==
')' )
1465 sprintf( pMan->sError,
"Cannot parse the flop." );
1470 if ( Symbol !=
',' )
1472 sprintf( pMan->sError,
"Cannot parse the flop." );
1480 if ( pWord == NULL )
1484 if ( pNetLi == NULL )
1486 sprintf( pMan->sError,
"Net is missing in gate %s.", pWord );
1494 if ( Symbol !=
')' )
1496 sprintf( pMan->sError,
"Cannot parse the flop." );
1505 sprintf( pMan->sError,
"Cannot parse the flop." );
1511 pLatch = Ver_ParseCreateLatch( pNtk, pNetLi, pNetLo );
1512 Abc_LatchSetInit0( pLatch );
1555 Abc_Obj_t * pNetActual, * pNode, * pNode2 = NULL;
1556 char * pWord, Symbol;
1560 if ( 1 != pMan->fMapped )
1562 sprintf( pMan->sError,
"The network appears to be mapped. Use \"r -m\" to read mapped Verilog." );
1573 if ( pWord == NULL )
1585 pNode = Abc_NtkCreateNode( pNtk );
1586 pNode->
pData = pGate;
1589 pNode2 = Abc_NtkCreateNode( pNtk );
1593 Vec_IntClear( pMan->vPerm );
1606 if ( pWord == NULL )
1621 sprintf( pMan->sError,
"Cannot formal parameter %s of gate %s (expected opening parenthesis).", pWord,
Mio_GateReadName(pGate) );
1628 if ( pWord == NULL )
1631 assert( pWord[0] !=
'~' );
1644 if ( pNetActual == NULL )
1646 sprintf( pMan->sError,
"Actual net %s is missing.", pWord );
1654 sprintf( pMan->sError,
"Cannot formal parameter %s of gate %s (expected closing parenthesis).", pWord,
Mio_GateReadName(pGate) );
1660 if ( Input < nFanins )
1662 Vec_IntPush( pMan->vPerm, Input );
1667 else if ( Input == nFanins )
1669 else if ( Input == nFanins + 1 )
1677 if ( Symbol ==
')' )
1681 if ( Symbol !=
',' )
1683 sprintf( pMan->sError,
"Cannot formal parameter %s of gate %s (expected closing parenthesis).", pWord,
Mio_GateReadName(pGate) );
1691 if ( !(Abc_ObjFaninNum(pNode) == nFanins && Abc_ObjFanoutNum(pNode) == 1) )
1711 if ( i < Vec_IntSize(pMan->vPerm) )
1714 for ( i = 0; i < nFanins; i++ )
1715 Vec_IntPush( pMan->vPerm, Abc_ObjFaninId(pNode, i) );
1717 for ( i = 0; i < nFanins; i++ )
1718 Vec_IntWriteEntry( &pNode->
vFanins, Vec_IntEntry(pMan->vPerm, i), Vec_IntEntry(pMan->vPerm, i+nFanins) );
1742 char * pWord, Symbol;
1743 int fCompl, fFormalIsGiven;
1744 int i, k, Bit, Limit, nMsb, nLsb, fQuit, flag;
1748 if ( pWord == NULL )
1752 pNode = Abc_NtkCreateBlackbox( pNtk );
1753 pNode->
pData = pNtkBox;
1759 sprintf( pMan->sError,
"Cannot parse box %s (expected opening parenthesis).",
Abc_ObjName(pNode) );
1766 vBundles = Vec_PtrAlloc( 16 );
1774 Vec_PtrPush( vBundles, pBundle );
1790 if ( pWord == NULL )
1799 sprintf( pMan->sError,
"Cannot formal parameter %s of box %s (expected opening parenthesis).", pWord,
Abc_ObjName(pNode));
1810 if ( Symbol ==
'{' )
1823 if ( pWord == NULL )
1827 if ( pWord[
strlen(pWord)-1] ==
'}' )
1829 pWord[
strlen(pWord)-1] = 0;
1832 if ( pWord[0] == 0 )
1836 if ( pWord[0] >=
'1' && pWord[0] <=
'9' )
1841 for ( k = 0; k < Vec_PtrSize(pMan->vNames); k++, i++ )
1844 sprintf( Buffer,
"1\'b%d", (
int)(Vec_PtrEntry(pMan->vNames,k) != NULL) );
1846 if ( pNetActual == NULL )
1848 sprintf( pMan->sError,
"Actual net \"%s\" is missing in gate \"%s\".", Buffer,
Abc_ObjName(pNode) );
1858 if ( pWord[
strlen(pWord)-1] ==
']' && !pMan->fNameLast )
1864 if ( nMsb == -1 && nLsb == -1 )
1868 if ( pNetActual == NULL )
1870 if ( !
strncmp(pWord,
"Open_", 5) ||
1871 !
strncmp(pWord,
"dct_unconnected", 15) )
1872 pNetActual = Abc_NtkCreateNet( pNtk );
1875 sprintf( pMan->sError,
"Actual net \"%s\" is missing in box \"%s\".", pWord,
Abc_ObjName(pNode) );
1886 assert( nMsb >= 0 && nLsb >= 0 );
1887 Limit = (nMsb > nLsb) ? nMsb - nLsb + 1: nLsb - nMsb + 1;
1888 for ( Bit = nMsb, k = Limit - 1; k >= 0; Bit = (nMsb > nLsb ? Bit - 1: Bit + 1), k--, i++ )
1891 sprintf( Buffer,
"%s[%d]", pWord, Bit );
1893 if ( pNetActual == NULL )
1895 if ( !
strncmp(pWord,
"Open_", 5) ||
1896 !
strncmp(pWord,
"dct_unconnected", 15) )
1897 pNetActual = Abc_NtkCreateNet( pNtk );
1900 sprintf( pMan->sError,
"Actual net \"%s\" is missing in box \"%s\".", pWord,
Abc_ObjName(pNode) );
1916 if ( Symbol ==
'}' )
1918 if ( Symbol !=
',' )
1920 sprintf( pMan->sError,
"Cannot parse formal parameter %s of gate %s (expected comma).", pWord,
Abc_ObjName(pNode) );
1930 if ( pWord == NULL )
1934 if ( pWord[0] == 0 )
1936 pNetActual = Abc_NtkCreateNet( pNtk );
1937 Vec_PtrPush( pBundle->
vNetsActual, Abc_ObjNotCond( pNetActual, fCompl ) );
1944 if ( pNetActual == NULL )
1947 if ( nMsb == -1 && nLsb == -1 )
1950 if ( nMsb == -1 && nLsb == -1 )
1952 if ( !
strncmp(pWord,
"Open_", 5) ||
1953 !
strncmp(pWord,
"dct_unconnected", 15) )
1955 pNetActual = Abc_NtkCreateNet( pNtk );
1960 sprintf( pMan->sError,
"Actual net \"%s\" is missing in box \"%s\".", pWord,
Abc_ObjName(pNode) );
1976 Limit = (nMsb > nLsb) ? nMsb - nLsb + 1: nLsb - nMsb + 1;
1977 for ( Bit = nMsb, k = Limit - 1; k >= 0; Bit = (nMsb > nLsb ? Bit - 1: Bit + 1), k--)
1980 sprintf( Buffer,
"%s[%d]", pWord, Bit );
1982 if ( pNetActual == NULL )
1984 if ( !
strncmp(pWord,
"Open_", 5) ||
1985 !
strncmp(pWord,
"dct_unconnected", 15))
1986 pNetActual = Abc_NtkCreateNet( pNtk );
1989 sprintf( pMan->sError,
"Actual net \"%s\" is missing in box \"%s\".", pWord,
Abc_ObjName(pNode) );
2000 Vec_PtrPush( pBundle->
vNetsActual, Abc_ObjNotCond( pNetActual, fCompl ) );
2005 if ( fFormalIsGiven )
2011 sprintf( pMan->sError,
"Cannot parse formal parameter %s of box %s (expected closing parenthesis).", pWord,
Abc_ObjName(pNode) );
2020 if ( Symbol ==
')' )
2023 if ( Symbol !=
',' )
2025 sprintf( pMan->sError,
"Cannot parse formal parameter %s of box %s (expected comma).", pWord,
Abc_ObjName(pNode) );
2036 sprintf( pMan->sError,
"Cannot read box %s (expected closing semicolumn).",
Abc_ObjName(pNode) );
2078 Abc_Obj_t * pTerm, * pTermNew, * pNetAct;
2081 int i, k, j, iBundle, Length;
2083 assert( !Ver_ObjIsConnected(pBox) );
2084 assert( Ver_NtkIsDefined(pNtkBox) );
2085 assert( !Abc_NtkHasBlackbox(pNtkBox) || Abc_NtkBoxNum(pNtkBox) == 1 );
2096 if ( Vec_PtrSize(vBundles) > Abc_NtkPiNum(pNtkBox) + Abc_NtkPoNum(pNtkBox) )
2098 sprintf( pMan->sError,
"The number of actual IOs (%d) is bigger than the number of formal IOs (%d) when instantiating network %s in box %s.",
2099 Vec_PtrSize(vBundles), Abc_NtkPiNum(pNtkBox) + Abc_NtkPoNum(pNtkBox), pNtkBox->
pName,
Abc_ObjName(pBox) );
2103 Vec_PtrFree( vBundles );
2113 if ( k < Vec_PtrSize(vBundles) )
2115 printf(
"Warning: The instance %s of network %s will be connected without using formal names.\n", pNtkBox->
pName,
Abc_ObjName(pBox) );
2122 if ( iBundle != Abc_NtkPiNum(pNtkBox) + Abc_NtkPoNum(pNtkBox) )
2124 sprintf( pMan->sError,
"The number of actual IOs (%d) is different from the number of formal IOs (%d) when instantiating network %s in box %s.",
2125 Vec_PtrSize(vBundles), Abc_NtkPiNum(pNtkBox) + Abc_NtkPoNum(pNtkBox), pNtkBox->
pName,
Abc_ObjName(pBox) );
2129 Vec_PtrFree( vBundles );
2138 pBundle = (
Ver_Bundle_t *)Vec_PtrEntry( vBundles, iBundle++ );
2142 pTermNew = Abc_NtkCreateBi( pNtk );
2152 pBundle = (
Ver_Bundle_t *)Vec_PtrEntry( vBundles, iBundle++ );
2156 pTermNew = Abc_NtkCreateBo( pNtk );
2167 Vec_PtrFree( vBundles );
2177 pNameFormal =
Abc_ObjName( Abc_ObjFanout0(pTerm) );
2183 assert( pBundle != NULL );
2185 if ( k == Vec_PtrSize(vBundles) )
2188 Length =
strlen(pNameFormal);
2189 if ( pNameFormal[Length-1] ==
']' )
2192 for ( Length--; Length >= 0; Length-- )
2193 if ( pNameFormal[Length] ==
'[' )
2201 if ( j == Vec_PtrSize(vBundles) )
2205 if ( pBundle == NULL )
2207 sprintf( pMan->sError,
"Cannot find an actual net for the formal net %s when instantiating network %s in box %s.",
2216 pTermNew = Abc_NtkCreateBi( pNtk );
2228 pNameFormal =
Abc_ObjName( Abc_ObjFanin0(pTerm) );
2234 assert( pBundle != NULL );
2236 if ( k == Vec_PtrSize(vBundles) )
2239 Length =
strlen(pNameFormal);
2240 if ( pNameFormal[Length-1] ==
']' )
2243 for ( Length--; Length >= 0; Length-- )
2244 if ( pNameFormal[Length] ==
'[' )
2252 if ( j == Vec_PtrSize(vBundles) )
2256 if ( pBundle == NULL )
2261 pTermNew = Abc_NtkCreateBo( pNtk );
2262 sprintf( Buffer,
"_temp_net%d", Abc_ObjId(pTermNew) );
2274 sprintf( pMan->sError,
"It looks like formal output %s is driving a constant net (%s) when instantiating network %s in box %s.",
2279 Vec_PtrFree( vBundles );
2284 pTermNew = Abc_NtkCreateBo( pNtk );
2295 Vec_PtrFree( vBundles );
2316 int i, k, RetValue = 1;
2323 if ( Abc_ObjIsLatch(pBox) )
2326 if ( pBox->
pData == NULL )
2335 if ( !Ver_ParseConnectBox( pMan, pBox ) )
2341 Abc_ObjBlackboxToWhitebox( pBox );
2368 vUndefs = Vec_PtrAlloc( 16 );
2374 if ( pNtkBox == NULL )
2376 if ( Ver_NtkIsDefined(pNtkBox) )
2378 if ( pNtkBox->
pData == NULL )
2381 Vec_PtrPush( vUndefs, pNtkBox );
2382 pNtkBox->
pData = Vec_PtrAlloc( 16 );
2412 if ( !Ver_NtkIsDefined(pNtk) )
2421 printf(
"Warning: The design contains %d undefined object types interpreted as blackboxes:\n", nBoxes );
2423 if ( !Ver_NtkIsDefined(pNtk) )
2424 printf(
"%s (%d) ", Abc_NtkName(pNtk), pNtk->
fHiePath );
2458 if ( Abc_ObjFaninNum(pNet) == 0 )
2494 if ( Abc_ObjFaninNum(pNet) > 0 )
2523 if ( pBundle == NULL )
2549 Abc_Obj_t * pBox, * pTerm, * pTermNew, * pNetAct, * pNetFormal;
2563 pTerm = Abc_NtkCreateBo( pNtk );
2564 assert( Abc_NtkBoxNum(pNtk) <= 1 );
2565 pBox = Abc_NtkBoxNum(pNtk)? Abc_NtkBox(pNtk,0) : Abc_NtkCreateBlackbox(pNtk);
2585 if ( Abc_ObjFaninNum(pNetAct) > 0 )
2587 sprintf( pMan->sError,
"Missing specification of the I/Os of undefined box \"%s\".", Abc_NtkName(pNtk) );
2594 pTermNew = Abc_NtkCreateBo( pNetAct->
pNtk );
2623 Abc_Obj_t * pBox, * pBox2, * pTerm, * pTermNew, * pNetFormal, * pNetAct;
2624 int i, k, j, m, CountCur, CountTotal = -1;
2634 CountCur += (pBundle != NULL);
2635 if ( CountTotal == -1 )
2636 CountTotal = CountCur;
2637 else if ( CountTotal != CountCur )
2639 sprintf( pMan->sError,
"The number of formal inputs (%d) is different from the expected one (%d) when instantiating network %s in box %s.",
2650 if ( pBundle == NULL )
2662 pTerm = Abc_NtkCreateBi( pNtk );
2663 assert( Abc_NtkBoxNum(pNtk) <= 1 );
2664 pBox2 = Abc_NtkBoxNum(pNtk)? Abc_NtkBox(pNtk,0) : Abc_NtkCreateBlackbox(pNtk);
2677 if ( pBundle == NULL )
2682 pTermNew = Abc_NtkCreateBi( pNetAct->
pNtk );
2715 int i, k, nMaxSize = 0;
2742 char * pNameGeneric;
2744 int i, k, Count1 = 0;
2748 sprintf( Buffer,
"%s.log", pNameGeneric );
2750 pFile = fopen( Buffer,
"w" );
2758 if ( Abc_ObjIsLatch(pBox) )
2761 if ( pNtkBox == NULL )
2766 fprintf( pFile,
"The hierarhical design %s contains %d modules:\n", pMan->pFileName, Vec_PtrSize(pMan->pDesign->vModules) );
2769 fprintf( pFile,
"%-50s : ", Abc_NtkName(pNtk) );
2770 if ( !Ver_NtkIsDefined(pNtk) )
2771 fprintf( pFile,
"undefbox" );
2772 else if ( Abc_NtkHasBlackbox(pNtk) )
2773 fprintf( pFile,
"blackbox" );
2775 fprintf( pFile,
"logicbox" );
2776 fprintf( pFile,
" instantiated %6d times ", pNtk->
fHieVisited );
2778 fprintf( pFile,
" pi = %4d", Abc_NtkPiNum(pNtk) );
2779 fprintf( pFile,
" po = %4d", Abc_NtkPoNum(pNtk) );
2780 fprintf( pFile,
" nd = %8d", Abc_NtkNodeNum(pNtk) );
2781 fprintf( pFile,
" lat = %6d", Abc_NtkLatchNum(pNtk) );
2782 fprintf( pFile,
" box = %6d", Abc_NtkBoxNum(pNtk)-Abc_NtkLatchNum(pNtk) );
2783 fprintf( pFile,
"\n" );
2784 Count1 += (Abc_NtkPoNum(pNtk) == 1);
2788 fprintf( pFile,
"The number of modules with one output = %d (%.2f %%).\n", Count1, 100.0 * Count1/Vec_PtrSize(pMan->pDesign->vModules) );
2791 if ( Vec_PtrSize(pMan->pDesign->vModules) > 1 )
2795 int j, nActNets, Counter = 0;
2801 if ( Abc_ObjIsLatch(pBox) )
2805 if ( pNtkBox == NULL )
2807 if ( !Ver_NtkIsDefined(pNtkBox) )
2814 if ( nActNets != Abc_NtkPiNum(pNtkBox) + Abc_NtkPoNum(pNtkBox) )
2819 fprintf( pFile,
"The outputs of all box instances are connected.\n" );
2822 fprintf( pFile,
"\n" );
2823 fprintf( pFile,
"The outputs of %d box instances are not connected:\n", Counter );
2829 if ( Abc_ObjIsLatch(pBox) )
2833 if ( pNtkBox == NULL )
2835 if ( !Ver_NtkIsDefined(pNtkBox) )
2842 if ( nActNets != Abc_NtkPiNum(pNtkBox) + Abc_NtkPoNum(pNtkBox) )
2843 fprintf( pFile,
"In module \"%s\" instance \"%s\" of box \"%s\" has different numbers of actual/formal nets (%d/%d).\n",
2844 Abc_NtkName(pNtk),
Abc_ObjName(pBox), Abc_NtkName(pNtkBox), nActNets, Abc_NtkPiNum(pNtkBox) + Abc_NtkPoNum(pNtkBox) );
2850 printf(
"Hierarchy statistics can be found in log file \"%s\".\n", Buffer );
2872int Ver_ParseAttachBoxes(
Ver_Man_t * pMan )
2878 int i, RetValue, Counter, nMaxBoxSize;
2881 if ( fPrintLog && pMan->pDesign->vModules && Vec_PtrSize(pMan->pDesign->vModules) > 1 )
2894 assert( Vec_PtrSize( vUndefs ) > 0 );
2906 if ( pBundle == NULL )
2926 Vec_PtrFree( vUndefs );
2951 pTerm = Abc_NtkCreatePi( pNtk );
2976 pTerm = Abc_NtkCreatePo( pNtk );
2996 pTerm = Abc_NtkCreateBi( pNtk );
2999 pLatch = Abc_NtkCreateLatch( pNtk );
3002 pTerm = Abc_NtkCreateBo( pNtk );
3008 Abc_LatchSetInitDc( pLatch );
3027 pNet = Abc_NtkCreateNet( pNtk );
struct Abc_Obj_t_ Abc_Obj_t
ABC_DLL Abc_Obj_t * Abc_NtkFindOrCreateNet(Abc_Ntk_t *pNtk, char *pName)
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
#define Abc_NtkForEachPo(pNtk, pPo, i)
ABC_DLL int Abc_NtkCheckRead(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
ABC_DLL void Abc_DesFree(Abc_Des_t *p, Abc_Ntk_t *pNtk)
#define Abc_NtkForEachBlackbox(pNtk, pObj, i)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
ABC_DLL void Abc_NtkFinalizeRead(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Des_t * Abc_DesCreate(char *pName)
DECLARATIONS ///.
struct Abc_Des_t_ Abc_Des_t
BASIC TYPES ///.
ABC_DLL Abc_Ntk_t * Abc_DesFindModelByName(Abc_Des_t *p, char *pName)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
#define Abc_NtkForEachPi(pNtk, pPi, i)
ABC_DLL int Abc_DesAddModel(Abc_Des_t *p, Abc_Ntk_t *pNtk)
#define Abc_NtkForEachBox(pNtk, pObj, i)
ABC_DLL Abc_Obj_t * Abc_NtkFindNet(Abc_Ntk_t *pNtk, char *pName)
#define ABC_ALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL void * Abc_FrameReadLibGen()
Hop_Obj_t * Hop_CreateOr(Hop_Man_t *p, int nVars)
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Hop_Obj_t * Hop_CreateAnd(Hop_Man_t *p, int nVars)
Hop_Obj_t * Hop_CreateExor(Hop_Man_t *p, int nVars)
void Hop_ManStop(Hop_Man_t *p)
struct Hop_Obj_t_ Hop_Obj_t
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
Mio_Gate_t * Mio_LibraryReadConst0(Mio_Library_t *pLib)
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
struct Mio_LibraryStruct_t_ Mio_Library_t
Mio_Gate_t * Mio_GateReadTwin(Mio_Gate_t *pGate)
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
char * Mio_PinReadName(Mio_Pin_t *pPin)
char * Mio_GateReadName(Mio_Gate_t *pGate)
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
Mio_Gate_t * Mio_LibraryReadConst1(Mio_Library_t *pLib)
struct Mio_PinStruct_t_ Mio_Pin_t
char * Mio_GateReadOutName(Mio_Gate_t *pGate)
struct Mio_GateStruct_t_ Mio_Gate_t
Mio_Gate_t * Mio_LibraryReadBuf(Mio_Library_t *pLib)
int st__strhash(const char *string, int modulus)
int st__lookup(st__table *table, const char *key, char **value)
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
int st__insert(st__table *table, const char *key, char *value)
void st__free_table(st__table *table)
#define st__is_member(table, key)
#define st__foreach_item(table, gen, key, value)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
int Ver_ParseInsertsSuffix(Ver_Man_t *pMan, char *pWord, int nMsb, int nLsb)
Vec_Ptr_t * Ver_ParseCollectUndefBoxes(Ver_Man_t *pMan)
int Ver_ParseMaxBoxSize(Vec_Ptr_t *vUndefs)
struct Ver_Bundle_t_ Ver_Bundle_t
int Ver_ParseConstant(Ver_Man_t *pMan, char *pWord)
int Ver_ParseLookupSuffix(Ver_Man_t *pMan, char *pWord, int *pnMsb, int *pnLsb)
int Ver_ParseFormalNetsAreDriven(Abc_Ntk_t *pNtk, char *pNameFormal)
int Ver_ParseDriveInputs(Ver_Man_t *pMan, Vec_Ptr_t *vUndefs)
Ver_SignalType_t
DECLARATIONS ///.
int Ver_ParseCheckNondrivenNets(Vec_Ptr_t *vUndefs)
int Ver_ParseConnectDefBoxes(Ver_Man_t *pMan)
Abc_Obj_t * Ver_ParseFindNet(Abc_Ntk_t *pNtk, char *pName)
Abc_Des_t * Ver_ParseFile(char *pFileName, Abc_Des_t *pGateLib, int fCheck, int fUseMemMan)
MACRO DEFINITIONS ///.
void Ver_ParsePrintErrorMessage(Ver_Man_t *p)
int Ver_ParseSignalPrefix(Ver_Man_t *pMan, char **ppWord, int *pnMsb, int *pnLsb)
void Ver_ParseReportUndefBoxes(Ver_Man_t *pMan)
int Ver_ParseDriveFormal(Ver_Man_t *pMan, Abc_Ntk_t *pNtk, Ver_Bundle_t *pBundle0)
int Ver_ParseConvertNetwork(Ver_Man_t *pMan, Abc_Ntk_t *pNtk, int fMapped)
void Ver_ParseFreeBundle(Ver_Bundle_t *pBundle)
int Ver_FindGateInput(Mio_Gate_t *pGate, char *pName)
void Ver_ParsePrintLog(Ver_Man_t *pMan)
Abc_Ntk_t * Ver_ParseFindOrCreateNetwork(Ver_Man_t *pMan, char *pName)
Ver_Bundle_t * Ver_ParseGetNondrivenBundle(Abc_Ntk_t *pNtk, int Counter)
int Ver_ParseSignalSuffix(Ver_Man_t *pMan, char *pWord, int *pnMsb, int *pnLsb)
void Ver_StreamMove(Ver_Stream_t *p)
int Ver_StreamGetCurPosition(Ver_Stream_t *p)
int Ver_ParseSkipComments(Ver_Man_t *p)
DECLARATIONS ///.
struct Ver_Stream_t_ Ver_Stream_t
char * Ver_StreamGetWord(Ver_Stream_t *p, char *pCharsToStop)
char Ver_StreamPopChar(Ver_Stream_t *p)
typedefABC_NAMESPACE_HEADER_START struct Ver_Man_t_ Ver_Man_t
INCLUDES ///.
Ver_Stream_t * Ver_StreamAlloc(char *pFileName)
FUNCTION DEFINITIONS ///.
void Ver_StreamSkipToChars(Ver_Stream_t *p, char *pCharsToStop)
char Ver_StreamScanChar(Ver_Stream_t *p)
void * Ver_FormulaParser(char *pFormula, void *pMan, Vec_Ptr_t *vNames, Vec_Ptr_t *vStackFn, Vec_Int_t *vStackOp, char *pErrorMessage)
FUNCTION DEFINITIONS ///.
void Ver_StreamFree(Ver_Stream_t *p)
char * Ver_ParseGetName(Ver_Man_t *p)
int Ver_StreamGetLineNumber(Ver_Stream_t *p)
void * Ver_FormulaReduction(char *pFormula, void *pMan, Vec_Ptr_t *vNames, char *pErrorMessage)
int Ver_StreamGetFileSize(Ver_Stream_t *p)