Skip to content

Commit

Permalink
Adding reversing of simulation bits in &sim_read.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanminko committed Feb 6, 2024
1 parent d7ef3cc commit e9a0bf6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/base/abci/abc.c
Original file line number Diff line number Diff line change
Expand Up @@ -34403,11 +34403,11 @@ int Abc_CommandAbc9Iwls21Test( Abc_Frame_t * pAbc, int argc, char ** argv )
***********************************************************************/
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 )
{
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
26 changes: 26 additions & 0 deletions src/misc/vec/vecWrd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e9a0bf6

Please sign in to comment.