Adding reversing of simulation bits in &sim_read.

This commit is contained in:
Alan Mishchenko 2024-02-05 20:32:11 -08:00
parent d7ef3cc030
commit e9a0bf6bf9
2 changed files with 34 additions and 4 deletions

View File

@ -34403,11 +34403,11 @@ usage:
***********************************************************************/
int Abc_CommandAbc9ReadSim( Abc_Frame_t * pAbc, int argc, char ** argv )
{
int c, fOutputs = 0, nWords = 4, fTruth = 0, fVerbose = 0;
int c, fOutputs = 0, nWords = 4, fTruth = 0, fReverse = 0, fVerbose = 0;
char ** pArgvNew;
int nArgcNew;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Wtovh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "Wtrovh" ) ) != EOF )
{
switch ( c )
{
@ -34425,6 +34425,9 @@ int Abc_CommandAbc9ReadSim( Abc_Frame_t * pAbc, int argc, char ** argv )
case 't':
fTruth ^= 1;
break;
case 'r':
fReverse ^= 1;
break;
case 'o':
fOutputs ^= 1;
break;
@ -34455,7 +34458,7 @@ int Abc_CommandAbc9ReadSim( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
}
Vec_WrdFreeP( &pAbc->pGia->vSimsPi );
pAbc->pGia->vSimsPi = Vec_WrdStartTruthTables( Gia_ManCiNum(pAbc->pGia) );
pAbc->pGia->vSimsPi = fReverse ? Vec_WrdStartTruthTablesRev( Gia_ManCiNum(pAbc->pGia) ) : Vec_WrdStartTruthTables( Gia_ManCiNum(pAbc->pGia) );
Vec_WrdFreeP( &pAbc->pGia->vSimsPo );
pAbc->pGia->vSimsPo = Gia_ManSimPatSimOut( pAbc->pGia, pAbc->pGia->vSimsPi, 1 );
return 0;
@ -34498,10 +34501,11 @@ int Abc_CommandAbc9ReadSim( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
Abc_Print( -2, "usage: &sim_read [-W num] [-tovh] <file>\n" );
Abc_Print( -2, "usage: &sim_read [-W num] [-trovh] <file>\n" );
Abc_Print( -2, "\t reads simulation patterns from file\n" );
Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", nWords );
Abc_Print( -2, "\t-t : toggle creating exhaustive simulation info [default = %s]\n", fTruth? "yes": "no" );
Abc_Print( -2, "\t-r : toggle reversing MSB and LSB input variables [default = %s]\n", fReverse? "yes": "no" );
Abc_Print( -2, "\t-o : toggle reading output information [default = %s]\n", fOutputs? "yes": "no" );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");

View File

@ -195,6 +195,32 @@ static inline Vec_Wrd_t * Vec_WrdStartTruthTables( int nVars )
}
return p;
}
static inline Vec_Wrd_t * Vec_WrdStartTruthTablesRev( int nVars )
{
Vec_Wrd_t * p;
unsigned Masks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
int i, k, nWords;
nWords = nVars <= 6 ? 1 : (1 << (nVars - 6));
p = Vec_WrdStart( nWords * nVars );
for ( i = 0; i < nVars; i++ )
{
unsigned * pTruth = (unsigned *)(p->pArray + nWords * (nVars-1-i));
if ( i < 5 )
{
for ( k = 0; k < 2*nWords; k++ )
pTruth[k] = Masks[i];
}
else
{
for ( k = 0; k < 2*nWords; k++ )
if ( k & (1 << (i-5)) )
pTruth[k] = ~(unsigned)0;
else
pTruth[k] = 0;
}
}
return p;
}
static inline int Vec_WrdShiftOne( Vec_Wrd_t * p, int nWords )
{
int i, nObjs = p->nSize/nWords;