ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioWriteEdgelist.c File Reference
#include "ioAbc.h"
#include "base/main/main.h"
#include "map/mio/mio.h"
#include "bool/kit/kit.h"
#include "map/if/if.h"
Include dependency graph for ioWriteEdgelist.c:

Go to the source code of this file.

Functions

void Io_WriteEdgelist (Abc_Ntk_t *pNtk, char *FileName, int fWriteLatches, int fBb2Wb, int fSeq, int fName)
 FUNCTION DEFINITIONS ///.
 
void Io_NtkEdgelistWrite_int (FILE *pFile, Abc_Ntk_t *pNtk, int fWriteLatches, int fBb2Wb, int fSeq, int fName)
 
void Io_NtkEdgelistWriteConvertedBox (FILE *pFile, Abc_Ntk_t *pNtk, int fSeq)
 
char * Io_NtkWriteEdgelistDeriveSop (Mem_Flex_t *pMem, word uTruth, int nVars, Vec_Int_t *vCover)
 
void Io_NtkEdgelistWriteSubcktFanins (FILE *pFile, Abc_Obj_t *pNode)
 
int Io_NtkEdgelistWriteNodeGate (FILE *pFile, Abc_Obj_t *pNode, int Length, int fName)
 
int Io_NtkEdgelistWriteNodeSubckt (FILE *pFile, Abc_Obj_t *pNode, int Length)
 
void Io_NtkEdgelistWriteNodeInt (FILE *pFile, Abc_Obj_t *pNode, Vec_Int_t *vCover)
 
void Io_NtkEdgelistWriteNodeIntStruct (FILE *pFile, Abc_Obj_t *pNode, Vec_Int_t *vCover, char *pStr)
 
void Io_NtkEdgelistWriteModelIntStruct (FILE *pFile, Abc_Obj_t *pNode, Vec_Int_t *vCover, char *pStr)
 

Function Documentation

◆ Io_NtkEdgelistWrite_int()

void Io_NtkEdgelistWrite_int ( FILE * pFile,
Abc_Ntk_t * pNtk,
int fWriteLatches,
int fBb2Wb,
int fSeq,
int fName )

Function*************************************************************

Synopsis [Write the network into a Edgelist file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 101 of file ioWriteEdgelist.c.

102{
103 Abc_Ntk_t * pExdc;
104 assert( Abc_NtkIsNetlist(pNtk) );
105 // write the model name
106 // fprintf( pFile, ".model %s\n", Abc_NtkName(pNtk) );
107 // write the network
108 Io_NtkEdgelistWriteOne( pFile, pNtk, fWriteLatches, fBb2Wb, fSeq , fName);
109 // write EXDC network if it exists
110 pExdc = Abc_NtkExdc( pNtk );
111 if ( pExdc )
112 {
113 fprintf( pFile, "\n" );
114 fprintf( pFile, ".exdc\n" );
115 Io_NtkEdgelistWriteOne( pFile, pExdc, fWriteLatches, fBb2Wb, fSeq , fName);
116 }
117 // finalize the file
118 //fprintf( pFile, ".end\n" );
119}
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
#define assert(ex)
Definition util_old.h:213

◆ Io_NtkEdgelistWriteConvertedBox()

void Io_NtkEdgelistWriteConvertedBox ( FILE * pFile,
Abc_Ntk_t * pNtk,
int fSeq )

Function*************************************************************

Synopsis [Write one network.]

Description []

SideEffects []

SeeAlso []

Definition at line 142 of file ioWriteEdgelist.c.

143{
144 Abc_Obj_t * pObj;
145 int i, v;
146 if ( fSeq )
147 {
148 fprintf( pFile, ".attrib white box seq\n" );
149 }
150 else
151 {
152 fprintf( pFile, ".attrib white box comb\n" );
153 fprintf( pFile, ".delay 1\n" );
154 }
155 Abc_NtkForEachPo( pNtk, pObj, i )
156 {
157 // write the .names line
158 //fprintf( pFile, ".names" );
159 Io_NtkEdgelistWritePis( pFile, pNtk, 1 );
160 if ( fSeq )
161 fprintf( pFile, " %s_in\n", Abc_ObjName(Abc_ObjFanin0(pObj)) );
162 else
163 fprintf( pFile, " %s\n", Abc_ObjName(Abc_ObjFanin0(pObj)) );
164 for ( v = 0; v < Abc_NtkPiNum(pNtk); v++ )
165 fprintf( pFile, "1" );
166 fprintf( pFile, " 1\n" );
167 if ( fSeq )
168 fprintf( pFile, " %s_in %s 1\n", Abc_ObjName(Abc_ObjFanin0(pObj)), Abc_ObjName(Abc_ObjFanin0(pObj)) );
169 //fprintf( pFile, ".latch %s_in %s 1\n", Abc_ObjName(Abc_ObjFanin0(pObj)), Abc_ObjName(Abc_ObjFanin0(pObj)) );
170 }
171}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
Here is the call graph for this function:

◆ Io_NtkEdgelistWriteModelIntStruct()

void Io_NtkEdgelistWriteModelIntStruct ( FILE * pFile,
Abc_Obj_t * pNode,
Vec_Int_t * vCover,
char * pStr )

Function*************************************************************

Synopsis [Write the node into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 1080 of file ioWriteEdgelist.c.

1081{
1082 Abc_Obj_t * pNet;
1083 int nLeaves = Abc_ObjFaninNum(pNode);
1084 int i, nLutLeaf, nLutLeaf2, nLutRoot, Length;
1085
1086 // write the header
1087 /*
1088 fprintf( pFile, "\n" );
1089 fprintf( pFile, ".model m%d\n", Abc_ObjName(pNode) );
1090 fprintf( pFile, ".inputs" );
1091 for ( i = 0; i < Abc_ObjFaninNum(pNode); i++ )
1092 fprintf( pFile, " %c", 'a' + i );
1093 fprintf( pFile, "\n" );
1094 fprintf( pFile, ".outputs o\n" );
1095 */
1096 // quit if parameters are wrong
1097 Length = strlen(pStr);
1098 if ( Length != 2 && Length != 3 )
1099 {
1100 printf( "Wrong LUT struct (%s)\n", pStr );
1101 return;
1102 }
1103 for ( i = 0; i < Length; i++ )
1104 if ( pStr[i] - '0' < 3 || pStr[i] - '0' > 6 )
1105 {
1106 printf( "The LUT size (%d) should belong to {3,4,5,6}.\n", pStr[i] - '0' );
1107 return;
1108 }
1109
1110 nLutLeaf = pStr[0] - '0';
1111 nLutLeaf2 = ( Length == 3 ) ? pStr[1] - '0' : 0;
1112 nLutRoot = pStr[Length-1] - '0';
1113 if ( nLeaves > nLutLeaf - 1 + (nLutLeaf2 ? nLutLeaf2 - 1 : 0) + nLutRoot )
1114 {
1115 printf( "The node size (%d) is too large for the LUT structure %s.\n", nLeaves, pStr );
1116 return;
1117 }
1118
1119 // consider easy case
1120 if ( nLeaves <= Abc_MaxInt( nLutLeaf2, Abc_MaxInt(nLutLeaf, nLutRoot) ) )
1121 {
1122 // write the .names line
1123 // //fprintf( pFile, ".names" );
1124 Abc_ObjForEachFanin( pNode, pNet, i )
1125 fprintf( pFile, "%c", 'a' + i );
1126 // get the output name
1127 fprintf( pFile, " %s", "o" );
1128 // write the cubes
1129 fprintf( pFile, " %s\n", (char*)Abc_ObjData(pNode) );
1130 //fprintf( pFile, ".end\n" );
1131 return;
1132 }
1133 else
1134 {
1135 extern int If_CluMinimumBase( word * t, int * pSupp, int nVarsAll, int * pnVars );
1136
1137 static word TruthStore[16][1<<10] = {{0}}, * pTruths[16];
1138 word pCube[1<<10], pRes[1<<10], Func0, Func1, Func2;
1139 char pLut0[32], pLut1[32], pLut2[32] = {0}, * pSop;
1140// int nVarsMin[3], pVars[3][20];
1141
1142 if ( TruthStore[0][0] == 0 )
1143 {
1144 static word Truth6[6] = {
1145 ABC_CONST(0xAAAAAAAAAAAAAAAA),
1146 ABC_CONST(0xCCCCCCCCCCCCCCCC),
1147 ABC_CONST(0xF0F0F0F0F0F0F0F0),
1148 ABC_CONST(0xFF00FF00FF00FF00),
1149 ABC_CONST(0xFFFF0000FFFF0000),
1150 ABC_CONST(0xFFFFFFFF00000000)
1151 };
1152 int nVarsMax = 16;
1153 int nWordsMax = (1 << 10);
1154 int i, k;
1155 assert( nVarsMax <= 16 );
1156 for ( i = 0; i < nVarsMax; i++ )
1157 pTruths[i] = TruthStore[i];
1158 for ( i = 0; i < 6; i++ )
1159 for ( k = 0; k < nWordsMax; k++ )
1160 pTruths[i][k] = Truth6[i];
1161 for ( i = 6; i < nVarsMax; i++ )
1162 for ( k = 0; k < nWordsMax; k++ )
1163 pTruths[i][k] = ((k >> (i-6)) & 1) ? ~(word)0 : 0;
1164 }
1165
1166 // collect variables
1167// Abc_ObjForEachFanin( pNode, pNet, i )
1168// pVars[0][i] = pVars[1][i] = pVars[2][i] = i;
1169
1170 // derive truth table
1171 Abc_SopToTruthBig( (char*)Abc_ObjData(pNode), nLeaves, pTruths, pCube, pRes );
1172 if ( Kit_TruthIsConst0((unsigned *)pRes, nLeaves) || Kit_TruthIsConst1((unsigned *)pRes, nLeaves) )
1173 {
1174 fprintf( pFile, ".names %s\n %d\n", "o", Kit_TruthIsConst1((unsigned *)pRes, nLeaves) );
1175 fprintf( pFile, ".end\n" );
1176 return;
1177 }
1178
1179// Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1180// Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1181
1182 // perform decomposition
1183 if ( Length == 2 )
1184 {
1185 if ( !If_CluCheckExt( NULL, pRes, nLeaves, nLutLeaf, nLutRoot, pLut0, pLut1, &Func0, &Func1 ) )
1186 {
1187 Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1188 Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1189 printf( "Node \"%s\" is not decomposable. Writing BLIF has failed.\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1190 return;
1191 }
1192 }
1193 else
1194 {
1195 if ( !If_CluCheckExt3( NULL, pRes, nLeaves, nLutLeaf, nLutLeaf2, nLutRoot, pLut0, pLut1, pLut2, &Func0, &Func1, &Func2 ) )
1196 {
1197 Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1198 Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1199 printf( "Node \"%s\" is not decomposable. Writing BLIF has failed.\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1200 return;
1201 }
1202 }
1203
1204 // write leaf node
1205 // //fprintf( pFile, ".names" );
1206 for ( i = 0; i < pLut1[0]; i++ )
1207 fprintf( pFile, " %c", 'a' + pLut1[2+i] );
1208 fprintf( pFile, " lut1\n" );
1209 // write SOP
1210 pSop = Io_NtkWriteEdgelistDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc, Func1, pLut1[0], vCover );
1211 fprintf( pFile, "%s", pSop );
1212
1213 if ( Length == 3 && pLut2[0] > 0 )
1214 {
1215 // write leaf node
1216 // //fprintf( pFile, ".names" );
1217 for ( i = 0; i < pLut2[0]; i++ )
1218 if ( pLut2[2+i] == nLeaves )
1219 fprintf( pFile, " lut1" );
1220 else
1221 fprintf( pFile, " %c", 'a' + pLut2[2+i] );
1222 fprintf( pFile, " lut2\n" );
1223 // write SOP
1224 pSop = Io_NtkWriteEdgelistDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc, Func2, pLut2[0], vCover );
1225 fprintf( pFile, "%s", pSop );
1226 }
1227
1228 // write root node
1229 //fprintf( pFile, ".names" );
1230 for ( i = 0; i < pLut0[0]; i++ )
1231 if ( pLut0[2+i] == nLeaves )
1232 fprintf( pFile, " lut1" );
1233 else if ( pLut0[2+i] == nLeaves+1 )
1234 fprintf( pFile, " lut2" );
1235 else
1236 fprintf( pFile, " %c", 'a' + pLut0[2+i] );
1237 fprintf( pFile, " %s\n", "o" );
1238 // write SOP
1239 pSop = Io_NtkWriteEdgelistDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc, Func0, pLut0[0], vCover );
1240 fprintf( pFile, "%s", pSop );
1241 fprintf( pFile, ".end\n" );
1242 }
1243}
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL void Abc_SopToTruthBig(char *pSop, int nInputs, word **pVars, word *pCube, word *pRes)
Definition abcSop.c:1425
#define ABC_CONST(number)
PARAMETERS ///.
Definition abc_global.h:240
void Extra_PrintHex(FILE *pFile, unsigned *pTruth, int nVars)
int If_CluMinimumBase(word *t, int *pSupp, int nVarsAll, int *pnVars)
Definition ifDec16.c:1532
int If_CluCheckExt3(void *p, word *pTruth, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot, char *pLut0, char *pLut1, char *pLut2, word *pFunc0, word *pFunc1, word *pFunc2)
Definition ifDec16.c:2079
int If_CluCheckExt(void *p, word *pTruth, int nVars, int nLutLeaf, int nLutRoot, char *pLut0, char *pLut1, word *pFunc0, word *pFunc1)
Definition ifDec16.c:2066
char * Io_NtkWriteEdgelistDeriveSop(Mem_Flex_t *pMem, word uTruth, int nVars, Vec_Int_t *vCover)
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition kitDsd.c:491
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
int strlen()
Here is the call graph for this function:

◆ Io_NtkEdgelistWriteNodeGate()

int Io_NtkEdgelistWriteNodeGate ( FILE * pFile,
Abc_Obj_t * pNode,
int Length,
int fName )

Function*************************************************************

Synopsis [Writes the primary input list.]

Description []

SideEffects []

SeeAlso []

Definition at line 654 of file ioWriteEdgelist.c.

655{
656 static int fReport = 0;
657 Mio_Gate_t * pGate = (Mio_Gate_t *)pNode->pData;
658 Mio_Pin_t * pGatePin;
659 Abc_Obj_t * pNode2;
660 int i;
661 for ( pGatePin = Mio_GateReadPins(pGate), i = 0; pGatePin; pGatePin = Mio_PinReadNext(pGatePin), i++ ){
662 if (fName)
663 fprintf( pFile, "%s ", Abc_ObjName( Abc_ObjFanin(pNode,i) ) );
664 else
665 fprintf( pFile, "%d ", Abc_ObjId( Abc_ObjFanin(pNode,i) ) );
666 }
667 //fprintf( pFile, "%s=%s ", Mio_PinReadName(pGatePin), Abc_ObjName( Abc_ObjFanin(pNode,i) ) );
668 assert ( i == Abc_ObjFaninNum(pNode) );
669 if (fName)
670 fprintf( pFile, "%s", Abc_ObjName( Abc_ObjFanout0(pNode) ) );
671 else
672 fprintf( pFile, "%d", Abc_ObjId( Abc_ObjFanout0(pNode) ) );
673
674 //fprintf( pFile, "%s=%s", Mio_GateReadOutName(pGate), Abc_ObjName( Abc_ObjFanout0(pNode) ) );
675 if ( Mio_GateReadTwin(pGate) == NULL ){
676 //print gate type
677 fprintf( pFile, " %s", Mio_GateReadName(pGate) );
678 fprintf( pFile, " %lu", Mio_GateReadTruth(pGate) );
679 //Vec_Int_t * Expr = Mio_GateReadExpr(pGate);
680 //Vec_IntPrint(Expr);
681 return 0;
682 }
683 pNode2 = Abc_NtkFetchTwinNode( pNode );
684 if ( pNode2 == NULL )
685 {
686 if ( !fReport )
687 fReport = 1, printf( "Warning: Missing second output of gate(s) \"%s\".\n", Mio_GateReadName(pGate) );
688 return 0;
689 }
690 fprintf( pFile, " %s", Abc_ObjName( Abc_ObjFanout0(pNode2) ) );
691 //print gate type
692 fprintf( pFile, " %s", Mio_GateReadName(pGate));
693 fprintf( pFile, " %lu", Mio_GateReadTruth(pGate) );
694 return 1;
695}
ABC_DLL Abc_Obj_t * Abc_NtkFetchTwinNode(Abc_Obj_t *pNode)
Definition abcMap.c:804
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
Definition mioApi.c:173
Mio_Gate_t * Mio_GateReadTwin(Mio_Gate_t *pGate)
Definition mioApi.c:176
word Mio_GateReadTruth(Mio_Gate_t *pGate)
Definition mioApi.c:181
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition mioApi.c:169
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
Definition mioApi.c:217
struct Mio_PinStruct_t_ Mio_Pin_t
Definition mio.h:44
struct Mio_GateStruct_t_ Mio_Gate_t
Definition mio.h:43
void * pData
Definition abc.h:145
Here is the call graph for this function:

◆ Io_NtkEdgelistWriteNodeInt()

void Io_NtkEdgelistWriteNodeInt ( FILE * pFile,
Abc_Obj_t * pNode,
Vec_Int_t * vCover )

Function*************************************************************

Synopsis [Write the node into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 772 of file ioWriteEdgelist.c.

773{
774 Abc_Obj_t * pNet;
775 int i, nVars = Abc_ObjFaninNum(pNode);
776 if ( nVars > 7 )
777 {
778 printf( "Node \"%s\" has more than 7 inputs. Writing Edgelist has failed.\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
779 return;
780 }
781
782 fprintf( pFile, "\n" );
783 if ( nVars <= 4 )
784 {
785 Abc_ObjForEachFanin( pNode, pNet, i )
786 fprintf( pFile, " %s", Abc_ObjName(pNet) );
787 // get the output name
788 fprintf( pFile, " %s ", Abc_ObjName(Abc_ObjFanout0(pNode)) );
789 // write the cubes
790 fprintf( pFile, "%s\n", (char*)Abc_ObjData(pNode) );
791 }
792 else
793 {
794 extern int If_Dec6PickBestMux( word t, word Cofs[2] );
795 extern int If_Dec7PickBestMux( word t[2], word c0r[2], word c1r[2] );
796 extern word If_Dec6MinimumBase( word uTruth, int * pSupp, int nVarsAll, int * pnVars );
797 extern void If_Dec7MinimumBase( word uTruth[2], int * pSupp, int nVarsAll, int * pnVars );
798 extern word If_Dec6Perform( word t, int fDerive );
799 extern word If_Dec7Perform( word t[2], int fDerive );
800
801 char * pSop;
802 word z, uTruth6 = 0, uTruth7[2], Cofs6[2], Cofs7[2][2];
803 int c, iVar, nVarsMin[2], pVars[2][10];
804
805 // collect variables
806 Abc_ObjForEachFanin( pNode, pNet, i )
807 pVars[0][i] = pVars[1][i] = i;
808
809 // derive truth table
810 if ( nVars == 7 )
811 {
812 Abc_SopToTruth7( (char*)Abc_ObjData(pNode), nVars, uTruth7 );
813 iVar = If_Dec7PickBestMux( uTruth7, Cofs7[0], Cofs7[1] );
814 }
815 else
816 {
817 uTruth6 = Abc_SopToTruth( (char*)Abc_ObjData(pNode), nVars );
818 iVar = If_Dec6PickBestMux( uTruth6, Cofs6 );
819 }
820
821 // perform MUX decomposition
822 if ( iVar >= 0 )
823 {
824 if ( nVars == 7 )
825 {
826 If_Dec7MinimumBase( Cofs7[0], pVars[0], nVars, &nVarsMin[0] );
827 If_Dec7MinimumBase( Cofs7[1], pVars[1], nVars, &nVarsMin[1] );
828 }
829 else
830 {
831 Cofs6[0] = If_Dec6MinimumBase( Cofs6[0], pVars[0], nVars, &nVarsMin[0] );
832 Cofs6[1] = If_Dec6MinimumBase( Cofs6[1], pVars[1], nVars, &nVarsMin[1] );
833 }
834 assert( nVarsMin[0] < 5 );
835 assert( nVarsMin[1] < 5 );
836 // write MUX
837 //fprintf( pFile, ".names" );
838 fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin(pNode,iVar)) );
839 fprintf( pFile, " %s_cascade0", Abc_ObjName(Abc_ObjFanout0(pNode)) );
840 fprintf( pFile, " %s_cascade1", Abc_ObjName(Abc_ObjFanout0(pNode)) );
841 fprintf( pFile, " %s\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
842 fprintf( pFile, "1-1 1\n01- 1\n" );
843 // write cofactors
844 for ( c = 0; c < 2; c++ )
845 {
846 pSop = Io_NtkWriteEdgelistDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc,
847 (word)(nVars == 7 ? Cofs7[c][0] : Cofs6[c]), nVarsMin[c], vCover );
848 //fprintf( pFile, ".names" );
849 for ( i = 0; i < nVarsMin[c]; i++ )
850 fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin(pNode,pVars[c][i])) );
851 fprintf( pFile, " %s_cascade%d\n", Abc_ObjName(Abc_ObjFanout0(pNode)), c );
852 fprintf( pFile, "%s", pSop );
853 }
854 return;
855 }
856 assert( nVars == 6 || nVars == 7 );
857
858 // try cascade decomposition
859 if ( nVars == 7 )
860 {
861 z = If_Dec7Perform( uTruth7, 1 );
862 //If_Dec7Verify( uTruth7, z );
863 }
864 else
865 {
866 z = If_Dec6Perform( uTruth6, 1 );
867 //If_Dec6Verify( uTruth6, z );
868 }
869 if ( z == 0 )
870 {
871 printf( "Node \"%s\" is not decomposable. Writing Edgelist has failed.\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
872 return;
873 }
874
875 // derive nodes
876 for ( c = 1; c >= 0; c-- )
877 {
878 // collect fanins
879 uTruth7[c] = ((c ? z >> 32 : z) & 0xffff);
880 uTruth7[c] |= (uTruth7[c] << 16);
881 uTruth7[c] |= (uTruth7[c] << 32);
882 for ( i = 0; i < 4; i++ )
883 pVars[c][i] = (z >> (c*32+16+4*i)) & 7;
884
885 // minimize truth table
886 Cofs6[c] = If_Dec6MinimumBase( uTruth7[c], pVars[c], 4, &nVarsMin[c] );
887
888 // write the nodes
889 //fprintf( pFile, ".names" );
890 for ( i = 0; i < nVarsMin[c]; i++ )
891 if ( pVars[c][i] == 7 )
892 fprintf( pFile, " %s_cascade", Abc_ObjName(Abc_ObjFanout0(pNode)) );
893 else
894 fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin(pNode,pVars[c][i])) );
895 fprintf( pFile, " %s%s\n", Abc_ObjName(Abc_ObjFanout0(pNode)), c? "" : "_cascade" );
896
897 // write SOP
898 pSop = Io_NtkWriteEdgelistDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc,
899 (word)Cofs6[c], nVarsMin[c], vCover );
900 fprintf( pFile, "%s", pSop );
901 }
902 }
903}
ABC_DLL void Abc_SopToTruth7(char *pSop, int nInputs, word r[2])
Definition abcSop.c:1365
ABC_DLL word Abc_SopToTruth(char *pSop, int nInputs)
Definition abcSop.c:1314
int If_Dec7PickBestMux(word t[2], word c0r[2], word c1r[2])
Definition ifDec07.c:643
int If_Dec6PickBestMux(word t, word Cofs[2])
Definition ifDec07.c:626
word If_Dec6Perform(word t, int fDerive)
Definition ifDec07.c:409
word If_Dec7Perform(word t0[2], int fDerive)
Definition ifDec07.c:449
word If_Dec6MinimumBase(word uTruth, int *pSupp, int nVarsAll, int *pnVars)
Definition ifDec07.c:501
void If_Dec7MinimumBase(word uTruth[2], int *pSupp, int nVarsAll, int *pnVars)
Definition ifDec07.c:533
Here is the call graph for this function:

◆ Io_NtkEdgelistWriteNodeIntStruct()

void Io_NtkEdgelistWriteNodeIntStruct ( FILE * pFile,
Abc_Obj_t * pNode,
Vec_Int_t * vCover,
char * pStr )

Function*************************************************************

Synopsis [Write the node into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 916 of file ioWriteEdgelist.c.

917{
918 Abc_Obj_t * pNet;
919 int nLeaves = Abc_ObjFaninNum(pNode);
920 int i, nLutLeaf, nLutLeaf2, nLutRoot, Length;
921
922 // quit if parameters are wrong
923 Length = strlen(pStr);
924 if ( Length != 2 && Length != 3 )
925 {
926 printf( "Wrong LUT struct (%s)\n", pStr );
927 return;
928 }
929 for ( i = 0; i < Length; i++ )
930 if ( pStr[i] - '0' < 3 || pStr[i] - '0' > 6 )
931 {
932 printf( "The LUT size (%d) should belong to {3,4,5,6}.\n", pStr[i] - '0' );
933 return;
934 }
935
936 nLutLeaf = pStr[0] - '0';
937 nLutLeaf2 = ( Length == 3 ) ? pStr[1] - '0' : 0;
938 nLutRoot = pStr[Length-1] - '0';
939 if ( nLeaves > nLutLeaf - 1 + (nLutLeaf2 ? nLutLeaf2 - 1 : 0) + nLutRoot )
940 {
941 printf( "The node size (%d) is too large for the LUT structure %s.\n", nLeaves, pStr );
942 return;
943 }
944
945 // consider easy case
946 fprintf( pFile, "\n" );
947 if ( nLeaves <= Abc_MaxInt( nLutLeaf2, Abc_MaxInt(nLutLeaf, nLutRoot) ) )
948 {
949 // write the .names line
951 Abc_ObjForEachFanin( pNode, pNet, i )
952 fprintf( pFile, " %s", Abc_ObjName(pNet) );
953 // get the output name
954 fprintf( pFile, " %s ", Abc_ObjName(Abc_ObjFanout0(pNode)) );
955 // write the cubes
956 fprintf( pFile, "%s\n", (char*)Abc_ObjData(pNode) );
957 return;
958 }
959 else
960 {
961 extern int If_CluMinimumBase( word * t, int * pSupp, int nVarsAll, int * pnVars );
962
963 static word TruthStore[16][1<<10] = {{0}}, * pTruths[16];
964 word pCube[1<<10], pRes[1<<10], Func0, Func1, Func2;
965 char pLut0[32], pLut1[32], pLut2[32] = {0}, * pSop;
966// int nVarsMin[3], pVars[3][20];
967
968 if ( TruthStore[0][0] == 0 )
969 {
970 static word Truth6[6] = {
971 ABC_CONST(0xAAAAAAAAAAAAAAAA),
972 ABC_CONST(0xCCCCCCCCCCCCCCCC),
973 ABC_CONST(0xF0F0F0F0F0F0F0F0),
974 ABC_CONST(0xFF00FF00FF00FF00),
975 ABC_CONST(0xFFFF0000FFFF0000),
976 ABC_CONST(0xFFFFFFFF00000000)
977 };
978 int nVarsMax = 16;
979 int nWordsMax = (1 << 10);
980 int i, k;
981 assert( nVarsMax <= 16 );
982 for ( i = 0; i < nVarsMax; i++ )
983 pTruths[i] = TruthStore[i];
984 for ( i = 0; i < 6; i++ )
985 for ( k = 0; k < nWordsMax; k++ )
986 pTruths[i][k] = Truth6[i];
987 for ( i = 6; i < nVarsMax; i++ )
988 for ( k = 0; k < nWordsMax; k++ )
989 pTruths[i][k] = ((k >> (i-6)) & 1) ? ~(word)0 : 0;
990 }
991
992 // collect variables
993// Abc_ObjForEachFanin( pNode, pNet, i )
994// pVars[0][i] = pVars[1][i] = pVars[2][i] = i;
995
996 // derive truth table
997 Abc_SopToTruthBig( (char*)Abc_ObjData(pNode), nLeaves, pTruths, pCube, pRes );
998 if ( Kit_TruthIsConst0((unsigned *)pRes, nLeaves) || Kit_TruthIsConst1((unsigned *)pRes, nLeaves) )
999 {
1000 fprintf( pFile, "%s\n const%d\n", Abc_ObjName(Abc_ObjFanout0(pNode)), Kit_TruthIsConst1((unsigned *)pRes, nLeaves) );
1001 return;
1002 }
1003
1004// Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1005// Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1006
1007 // perform decomposition
1008 if ( Length == 2 )
1009 {
1010 if ( !If_CluCheckExt( NULL, pRes, nLeaves, nLutLeaf, nLutRoot, pLut0, pLut1, &Func0, &Func1 ) )
1011 {
1012 Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1013 Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1014 printf( "Node \"%s\" is not decomposable. Writing BLIF has failed.\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1015 return;
1016 }
1017 }
1018 else
1019 {
1020 if ( !If_CluCheckExt3( NULL, pRes, nLeaves, nLutLeaf, nLutLeaf2, nLutRoot, pLut0, pLut1, pLut2, &Func0, &Func1, &Func2 ) )
1021 {
1022 Extra_PrintHex( stdout, (unsigned *)pRes, nLeaves ); printf( " " );
1023 Kit_DsdPrintFromTruth( (unsigned*)pRes, nLeaves ); printf( "\n" );
1024 printf( "Node \"%s\" is not decomposable. Writing BLIF has failed.\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1025 return;
1026 }
1027 }
1028
1029 // write leaf node
1030 // //fprintf( pFile, ".names" );
1031 for ( i = 0; i < pLut1[0]; i++ )
1032 fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin(pNode,pLut1[2+i])) );
1033 fprintf( pFile, " %s_lut1\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1034 // write SOP
1035 pSop = Io_NtkWriteEdgelistDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc, Func1, pLut1[0], vCover );
1036 fprintf( pFile, "%s", pSop );
1037
1038 if ( Length == 3 && pLut2[0] > 0 )
1039 {
1040 // write leaf node
1041 // //fprintf( pFile, ".names" );
1042 for ( i = 0; i < pLut2[0]; i++ )
1043 if ( pLut2[2+i] == nLeaves )
1044 fprintf( pFile, " %s_lut1", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1045 else
1046 fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin(pNode,pLut2[2+i])) );
1047 fprintf( pFile, " %s_lut2\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1048 // write SOP
1049 pSop = Io_NtkWriteEdgelistDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc, Func2, pLut2[0], vCover );
1050 fprintf( pFile, "%s", pSop );
1051 }
1052
1053 // write root node
1054 // //fprintf( pFile, ".names" );
1055 for ( i = 0; i < pLut0[0]; i++ )
1056 if ( pLut0[2+i] == nLeaves )
1057 fprintf( pFile, " %s_lut1", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1058 else if ( pLut0[2+i] == nLeaves+1 )
1059 fprintf( pFile, " %s_lut2", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1060 else
1061 fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin(pNode,pLut0[2+i])) );
1062 fprintf( pFile, " %s\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1063 // write SOP
1064 pSop = Io_NtkWriteEdgelistDeriveSop( (Mem_Flex_t *)Abc_ObjNtk(pNode)->pManFunc, Func0, pLut0[0], vCover );
1065 fprintf( pFile, "%s", pSop );
1066 }
1067}
Here is the call graph for this function:

◆ Io_NtkEdgelistWriteNodeSubckt()

int Io_NtkEdgelistWriteNodeSubckt ( FILE * pFile,
Abc_Obj_t * pNode,
int Length )

Function*************************************************************

Synopsis [Write the node into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 751 of file ioWriteEdgelist.c.

752{
753 int RetValue = 0;
754 fprintf( pFile, ".subckt" );
755 Io_NtkEdgelistWriteSubcktFanins( pFile, pNode );
756 fprintf( pFile, "\n" );
757 return RetValue;
758}
void Io_NtkEdgelistWriteSubcktFanins(FILE *pFile, Abc_Obj_t *pNode)
Here is the call graph for this function:

◆ Io_NtkEdgelistWriteSubcktFanins()

void Io_NtkEdgelistWriteSubcktFanins ( FILE * pFile,
Abc_Obj_t * pNode )

Function*************************************************************

Synopsis [Writes the primary input list.]

Description []

SideEffects []

SeeAlso []

Definition at line 591 of file ioWriteEdgelist.c.

592{
593 Abc_Obj_t * pNet;
594 int LineLength;
595 int AddedLength;
596 int NameCounter;
597 char * pName;
598 int i;
599
600 LineLength = 6;
601 NameCounter = 0;
602
603 // get the output name
604 pName = Abc_ObjName(Abc_ObjFanout0(pNode));
605 // get the line length after the output name is written
606 AddedLength = strlen(pName) + 1;
607 fprintf( pFile, " m%d", Abc_ObjId(pNode) );
608
609 // get the input names
610 Abc_ObjForEachFanin( pNode, pNet, i )
611 {
612 // get the fanin name
613 pName = Abc_ObjName(pNet);
614 // get the line length after the fanin name is written
615 AddedLength = strlen(pName) + 3;
616 if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
617 { // write the line extender
618 fprintf( pFile, " \\\n" );
619 // reset the line length
620 LineLength = 0;
621 NameCounter = 0;
622 }
623 fprintf( pFile, " %c=%s", 'a'+i, pName );
624 LineLength += AddedLength;
625 NameCounter++;
626 }
627
628 // get the output name
629 pName = Abc_ObjName(Abc_ObjFanout0(pNode));
630 // get the line length after the output name is written
631 AddedLength = strlen(pName) + 3;
632 if ( NameCounter && LineLength + AddedLength > 75 )
633 { // write the line extender
634 fprintf( pFile, " \\\n" );
635 // reset the line length
636 LineLength = 0;
637 NameCounter = 0;
638 }
639 fprintf( pFile, " %c=%s", 'o', pName );
640}
#define IO_WRITE_LINE_LENGTH
MACRO DEFINITIONS ///.
Definition ioAbc.h:75
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_NtkWriteEdgelistDeriveSop()

char * Io_NtkWriteEdgelistDeriveSop ( Mem_Flex_t * pMem,
word uTruth,
int nVars,
Vec_Int_t * vCover )

Function*************************************************************

Synopsis [Transforms truth table into an SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 184 of file ioWriteEdgelist.c.

185{
186 char * pSop;
187 int RetValue = Kit_TruthIsop( (unsigned *)&uTruth, nVars, vCover, 1 );
188 assert( RetValue == 0 || RetValue == 1 );
189 // check the case of constant cover
190 if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover,0) == 0) )
191 {
192 char * pStr0 = " 0\n", * pStr1 = " 1\n";
193 assert( RetValue == 0 );
194 return Vec_IntSize(vCover) == 0 ? pStr0 : pStr1;
195 }
196 // derive the AIG for that tree
197 pSop = Abc_SopCreateFromIsop( pMem, nVars, vCover );
198 if ( RetValue )
199 Abc_SopComplement( pSop );
200 return pSop;
201}
ABC_DLL void Abc_SopComplement(char *pSop)
Definition abcSop.c:648
ABC_DLL char * Abc_SopCreateFromIsop(Mem_Flex_t *pMan, int nVars, Vec_Int_t *vCover)
Definition abcSop.c:424
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
Definition kitIsop.c:134
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Io_WriteEdgelist()

void Io_WriteEdgelist ( Abc_Ntk_t * pNtk,
char * FileName,
int fWriteLatches,
int fBb2Wb,
int fSeq,
int fName )

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Write the network into a Edgelist file with the given name.]

Description []

SideEffects []

SeeAlso []

Definition at line 59 of file ioWriteEdgelist.c.

60{
61 FILE * pFile; int i;
62 // start writing the file
63 pFile = fopen( FileName, "w" );
64 if ( pFile == NULL )
65 {
66 fprintf( stdout, "Io_WriteEdgelist(): Cannot open the output file.\n" );
67 return;
68 }
69 fprintf( stdout, "WriteEdgelist (Verilog-to-PyG @ https://github.com/ycunxi/Verilog-to-PyG) starts writing to %s.\n", FileName );
70 fprintf( pFile, "# Benchmark Edgelist Dumping (beta) \"%s\" written by ABC on %s (more at https://github.com/ycunxi/Verilog-to-PyG)\n", pNtk->pName, Extra_TimeStamp() );
71 // write the master network
72 Io_NtkEdgelistWrite( pFile, pNtk, fWriteLatches, fBb2Wb, fSeq , fName);
73 // make sure there is no logic hierarchy
74// assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
75 // write the hierarchy if present
76 if ( Abc_NtkBlackboxNum(pNtk) > 0 || Abc_NtkWhiteboxNum(pNtk) > 0 )
77 {
78 Abc_Ntk_t * pNtkTemp;
79 Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pNtkTemp, i )
80 {
81 if ( pNtkTemp == pNtk )
82 continue;
83 fprintf( pFile, "\n\n" );
84 Io_NtkEdgelistWrite( pFile, pNtkTemp, fWriteLatches, fBb2Wb, fSeq, fName);
85 }
86 }
87 fclose( pFile );
88}
char * Extra_TimeStamp()
Vec_Ptr_t * vModules
Definition abc.h:225
char * pName
Definition abc.h:158
Abc_Des_t * pDesign
Definition abc.h:180
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function: