summaryrefslogtreecommitdiffstats
path: root/src/base/pla/plaMan.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2016-01-20 15:01:27 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2016-01-20 15:01:27 -0800
commitdf34a262162df02ec1156bfbca21f9b8884c6e3f (patch)
tree23d54343e1130c59cc5257624da646674b9a8c56 /src/base/pla/plaMan.c
parentf5ee46eb3c2c691e4bafc5b7a7dbe3be16bef5dd (diff)
downloadabc-df34a262162df02ec1156bfbca21f9b8884c6e3f.tar.gz
abc-df34a262162df02ec1156bfbca21f9b8884c6e3f.tar.bz2
abc-df34a262162df02ec1156bfbca21f9b8884c6e3f.zip
Generating sorting network as a PLA file.
Diffstat (limited to 'src/base/pla/plaMan.c')
-rw-r--r--src/base/pla/plaMan.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/base/pla/plaMan.c b/src/base/pla/plaMan.c
index 23ea8368..c396a264 100644
--- a/src/base/pla/plaMan.c
+++ b/src/base/pla/plaMan.c
@@ -32,6 +32,47 @@ ABC_NAMESPACE_IMPL_START
/**Function*************************************************************
+ Synopsis [Generates PLA description of a sorter.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Pla_GenSorter( int nVars )
+{
+ int i, k, Count, nMints = ( 1 << nVars );
+ char Buffer[20];
+ FILE * pFile;
+ sprintf( Buffer, "sorter%02d.pla", nVars );
+ pFile = fopen( Buffer, "wb" );
+ fprintf( pFile, "# This file was generated by ABC on %s.\n", Extra_TimeStamp() );
+ fprintf( pFile, ".i %d\n", nVars );
+ fprintf( pFile, ".o %d\n", nVars );
+ fprintf( pFile, ".p %d\n", nMints-1 );
+ for ( i = 1; i < nMints; i++ )
+ {
+ Count = 0;
+ for ( k = nVars-1; k >= 0; k-- )
+ {
+ Count += ((i >> k) & 1);
+ fprintf( pFile, "%d", (i >> k) & 1 );
+ }
+ fprintf( pFile, " " );
+ for ( k = 0; k < Count; k++ )
+ fprintf( pFile, "1" );
+ for ( ; k < nVars; k++ )
+ fprintf( pFile, "0" );
+ fprintf( pFile, "\n" );
+ }
+ fprintf( pFile, ".end\n" );
+ fclose( pFile );
+}
+
+/**Function*************************************************************
+
Synopsis [Generates prime detector for the given bit-widths.]
Description []