ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcLog.c File Reference
#include "base/abc/abc.h"
#include "aig/gia/gia.h"
Include dependency graph for abcLog.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Abc_NtkWriteLogFile (char *pFileName, Abc_Cex_t *pCex, int Status, int nFrames, char *pCommand)
 DECLARATIONS ///.
 
int Abc_NtkReadLogFile (char *pFileName, Abc_Cex_t **ppCex, int *pnFrames)
 

Function Documentation

◆ Abc_NtkReadLogFile()

int Abc_NtkReadLogFile ( char * pFileName,
Abc_Cex_t ** ppCex,
int * pnFrames )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 132 of file abcLog.c.

133{
134 FILE * pFile;
135 Abc_Cex_t * pCex;
136 Vec_Int_t * vNums;
137 char Buffer[1000], * pToken, * RetValue;
138 int c, nRegs = -1, nFrames = -1, iPo = -1, Status = -1, nFrames2 = -1;
139 pFile = fopen( pFileName, "r" );
140 if ( pFile == NULL )
141 {
142 printf( "Cannot open log file for reading \"%s\".\n" , pFileName );
143 return -1;
144 }
145 RetValue = fgets( Buffer, 1000, pFile );
146 if ( !strncmp( Buffer, "snl_UNSAT", strlen("snl_UNSAT") ) )
147 {
148 Status = 1;
149 nFrames = atoi( Buffer + strlen("snl_UNSAT") );
150 }
151 else if ( !strncmp( Buffer, "snl_SAT", strlen("snl_SAT") ) )
152 {
153 Status = 0;
154// nFrames = atoi( Buffer + strlen("snl_SAT") );
155 pToken = strtok( Buffer + strlen("snl_SAT"), " \t\n" );
156 nFrames = atoi( pToken );
157 pToken = strtok( NULL, " \t\n" );
158 pToken = strtok( NULL, " \t\n" );
159 if ( pToken != NULL )
160 {
161 iPo = atoi( pToken );
162 pToken = strtok( NULL, " \t\n" );
163 if ( pToken )
164 nFrames2 = atoi( pToken );
165 }
166// else
167// printf( "Warning! The current status is SAT but the current CEX is not given.\n" );
168 }
169 else if ( !strncmp( Buffer, "snl_UNK", strlen("snl_UNK") ) )
170 {
171 Status = -1;
172 nFrames = atoi( Buffer + strlen("snl_UNK") );
173 }
174 else
175 {
176 printf( "Unrecognized status.\n" );
177 }
178 // found regs till the new line
179 vNums = Vec_IntAlloc( 100 );
180 while ( (c = fgetc(pFile)) != EOF )
181 {
182 if ( c == '\n' )
183 break;
184 if ( c == '0' || c == '1' )
185 Vec_IntPush( vNums, c - '0' );
186 }
187 nRegs = Vec_IntSize(vNums);
188 // skip till the new line
189 while ( (c = fgetc(pFile)) != EOF )
190 {
191 if ( c == '0' || c == '1' )
192 Vec_IntPush( vNums, c - '0' );
193 }
194 fclose( pFile );
195 if ( Vec_IntSize(vNums) )
196 {
197 int iFrameCex = (nFrames2 == -1) ? nFrames : nFrames2;
198 if ( nRegs < 0 )
199 {
200 printf( "Cannot read register number.\n" );
201 Vec_IntFree( vNums );
202 return -1;
203 }
204 if ( Vec_IntSize(vNums)-nRegs == 0 )
205 {
206 printf( "Cannot read counter example.\n" );
207 Vec_IntFree( vNums );
208 return -1;
209 }
210 if ( (Vec_IntSize(vNums)-nRegs) % (iFrameCex + 1) != 0 )
211 {
212 printf( "Incorrect number of bits.\n" );
213 Vec_IntFree( vNums );
214 return -1;
215 }
216 pCex = Abc_CexAlloc( nRegs, (Vec_IntSize(vNums)-nRegs)/(iFrameCex + 1), iFrameCex + 1 );
217 pCex->iPo = iPo;
218 pCex->iFrame = iFrameCex;
219 assert( Vec_IntSize(vNums) == pCex->nBits );
220 for ( c = 0; c < pCex->nBits; c++ )
221 if ( Vec_IntEntry(vNums, c) )
222 Abc_InfoSetBit( pCex->pData, c );
223 Vec_IntFree( vNums );
224 if ( ppCex )
225 *ppCex = pCex;
226 else
227 ABC_FREE( pCex );
228 }
229 else
230 {
231 // corner case of seq circuit with no PIs
232 int iFrameCex = (nFrames2 == -1) ? nFrames : nFrames2;
233 pCex = Abc_CexAlloc( 0, 0, iFrameCex + 1 );
234 pCex->iFrame = iFrameCex;
235 pCex->iPo = iPo;
236 if ( ppCex )
237 *ppCex = pCex;
238 Vec_IntFree( vNums );
239 }
240 if ( pnFrames )
241 *pnFrames = nFrames;
242 return Status;
243}
#define ABC_FREE(obj)
Definition abc_global.h:267
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
Definition utilCex.c:51
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition utilCex.h:39
#define assert(ex)
Definition util_old.h:213
int strncmp()
int strlen()
char * strtok()
Here is the call graph for this function:

◆ Abc_NtkWriteLogFile()

ABC_NAMESPACE_IMPL_START void Abc_NtkWriteLogFile ( char * pFileName,
Abc_Cex_t * pCex,
int Status,
int nFrames,
char * pCommand )

DECLARATIONS ///.

CFile****************************************************************

FileName [abcLog.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Log file printing.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
abcLog.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 68 of file abcLog.c.

69{
70 FILE * pFile;
71 int i;
72 pFile = fopen( pFileName, "w" );
73 if ( pFile == NULL )
74 {
75 printf( "Cannot open log file for writing \"%s\".\n" , pFileName );
76 return;
77 }
78 // write <result>
79 if ( Status == 1 )
80 fprintf( pFile, "snl_UNSAT" );
81 else if ( Status == 0 )
82 fprintf( pFile, "snl_SAT" );
83 else if ( Status == -1 )
84 fprintf( pFile, "snl_UNK" );
85 else
86 printf( "Abc_NtkWriteLogFile(): Cannot recognize solving status.\n" );
87 fprintf( pFile, " " );
88 // write <bug_free_depth>
89 fprintf( pFile, "%d", nFrames );
90 fprintf( pFile, " " );
91 // write <engine_name>
92 fprintf( pFile, "%s", pCommand ? pCommand : "unknown" );
93 if ( pCex && Status == 0 )
94 fprintf( pFile, " %d", pCex->iPo );
95 // write <cyc>
96 if ( pCex && pCex->iFrame != nFrames )
97 fprintf( pFile, " %d", pCex->iFrame );
98 fprintf( pFile, "\n" );
99 // write <INIT_STATE>
100 if ( pCex == NULL )
101 fprintf( pFile, "NULL" );
102 else
103 {
104 for ( i = 0; i < pCex->nRegs; i++ )
105 fprintf( pFile, "%d", Abc_InfoHasBit(pCex->pData,i) );
106 }
107 fprintf( pFile, "\n" );
108 // write <TRACE>
109 if ( pCex == NULL )
110 fprintf( pFile, "NULL" );
111 else
112 {
113 assert( pCex->nBits - pCex->nRegs == pCex->nPis * (pCex->iFrame + 1) );
114 for ( i = pCex->nRegs; i < pCex->nBits; i++ )
115 fprintf( pFile, "%d", Abc_InfoHasBit(pCex->pData,i) );
116 }
117 fprintf( pFile, "\n" );
118 fclose( pFile );
119}