Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
75ed8581
Commit
75ed8581
authored
Sep 28, 2018
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding switch to 'write_pla' to write random onset minterms of the first PO function.
parent
3e33c91c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
148 additions
and
4 deletions
+148
-4
src/base/io/io.c
+26
-3
src/base/io/ioWritePla.c
+122
-1
No files found.
src/base/io/io.c
View file @
75ed8581
...
@@ -2678,14 +2678,24 @@ usage:
...
@@ -2678,14 +2678,24 @@ usage:
***********************************************************************/
***********************************************************************/
int
IoCommandWritePla
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
int
IoCommandWritePla
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
{
extern
int
Io_WriteMoPlaM
(
Abc_Ntk_t
*
pNtk
,
char
*
pFileName
,
int
nMints
);
char
*
pFileName
;
char
*
pFileName
;
int
c
,
fUseMoPla
=
0
;
int
c
,
fUseMoPla
=
0
,
nMints
=
0
;
Extra_UtilGetoptReset
();
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"mh"
)
)
!=
EOF
)
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"
M
mh"
)
)
!=
EOF
)
{
{
switch
(
c
)
switch
(
c
)
{
{
case
'M'
:
if
(
globalUtilOptind
>=
argc
)
{
Abc_Print
(
-
1
,
"Command line switch
\"
-M
\"
should be followed by an integer.
\n
"
);
goto
usage
;
}
nMints
=
atoi
(
argv
[
globalUtilOptind
]);
globalUtilOptind
++
;
break
;
case
'm'
:
case
'm'
:
fUseMoPla
^=
1
;
fUseMoPla
^=
1
;
break
;
break
;
...
@@ -2705,12 +2715,25 @@ int IoCommandWritePla( Abc_Frame_t * pAbc, int argc, char **argv )
...
@@ -2705,12 +2715,25 @@ int IoCommandWritePla( Abc_Frame_t * pAbc, int argc, char **argv )
// get the output file name
// get the output file name
pFileName
=
argv
[
globalUtilOptind
];
pFileName
=
argv
[
globalUtilOptind
];
// call the corresponding file writer
// call the corresponding file writer
if
(
nMints
)
{
if
(
Abc_NtkIsBddLogic
(
pAbc
->
pNtkCur
)
)
Io_WriteMoPlaM
(
pAbc
->
pNtkCur
,
pFileName
,
nMints
);
else
{
Abc_Ntk_t
*
pStrash
=
Abc_NtkStrash
(
pAbc
->
pNtkCur
,
0
,
0
,
0
);
Io_WriteMoPlaM
(
pStrash
,
pFileName
,
nMints
);
Abc_NtkDelete
(
pStrash
);
}
}
else
Io_Write
(
pAbc
->
pNtkCur
,
pFileName
,
fUseMoPla
?
IO_FILE_MOPLA
:
IO_FILE_PLA
);
Io_Write
(
pAbc
->
pNtkCur
,
pFileName
,
fUseMoPla
?
IO_FILE_MOPLA
:
IO_FILE_PLA
);
return
0
;
return
0
;
usage
:
usage
:
fprintf
(
pAbc
->
Err
,
"usage: write_pla [-mh] <file>
\n
"
);
fprintf
(
pAbc
->
Err
,
"usage: write_pla [-
M <num>] [-
mh] <file>
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
writes the collapsed network into a PLA file
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
writes the collapsed network into a PLA file
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
-M <num> : the number of on-set minterms to write [default = %d]
\n
"
,
nMints
);
fprintf
(
pAbc
->
Err
,
"
\t
-m : toggle writing multi-output PLA [default = %s]
\n
"
,
fUseMoPla
?
"yes"
:
"no"
);
fprintf
(
pAbc
->
Err
,
"
\t
-m : toggle writing multi-output PLA [default = %s]
\n
"
,
fUseMoPla
?
"yes"
:
"no"
);
fprintf
(
pAbc
->
Err
,
"
\t
-h : print the help massage
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
-h : print the help massage
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
file : the name of the file to write
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
file : the name of the file to write
\n
"
);
...
...
src/base/io/ioWritePla.c
View file @
75ed8581
...
@@ -383,7 +383,7 @@ int Io_WriteMoPlaOneIntMinterms( FILE * pFile, Abc_Ntk_t * pNtk, DdManager * dd,
...
@@ -383,7 +383,7 @@ int Io_WriteMoPlaOneIntMinterms( FILE * pFile, Abc_Ntk_t * pNtk, DdManager * dd,
***********************************************************************/
***********************************************************************/
int
Io_WriteMoPlaOne
(
FILE
*
pFile
,
Abc_Ntk_t
*
pNtk
)
int
Io_WriteMoPlaOne
(
FILE
*
pFile
,
Abc_Ntk_t
*
pNtk
)
{
{
int
fVerbose
=
1
;
int
fVerbose
=
0
;
DdManager
*
dd
;
DdManager
*
dd
;
DdNode
*
bFunc
;
DdNode
*
bFunc
;
Vec_Ptr_t
*
vFuncsGlob
;
Vec_Ptr_t
*
vFuncsGlob
;
...
@@ -445,9 +445,130 @@ int Io_WriteMoPla( Abc_Ntk_t * pNtk, char * pFileName )
...
@@ -445,9 +445,130 @@ int Io_WriteMoPla( Abc_Ntk_t * pNtk, char * pFileName )
return
1
;
return
1
;
}
}
/**Function*************************************************************
Synopsis [Writes the network in PLA format.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Io_WriteMoPlaOneIntMintermsM
(
FILE
*
pFile
,
Abc_Ntk_t
*
pNtk
,
DdManager
*
dd
,
DdNode
*
bFunc
,
int
nMints
)
{
Abc_Obj_t
*
pNode
;
int
*
pArray
=
ABC_CALLOC
(
int
,
dd
->
size
);
DdNode
**
pbMints
=
Cudd_bddPickArbitraryMinterms
(
dd
,
bFunc
,
dd
->
vars
,
dd
->
size
,
nMints
);
int
i
,
k
,
nInputs
=
Abc_NtkCiNum
(
pNtk
);
assert
(
dd
->
size
==
Abc_NtkCiNum
(
pNtk
)
);
// write the header
fprintf
(
pFile
,
".i %d
\n
"
,
nInputs
);
fprintf
(
pFile
,
".o %d
\n
"
,
1
);
fprintf
(
pFile
,
".ilb"
);
Abc_NtkForEachCi
(
pNtk
,
pNode
,
i
)
fprintf
(
pFile
,
" %s"
,
Abc_ObjName
(
pNode
)
);
fprintf
(
pFile
,
"
\n
"
);
fprintf
(
pFile
,
".ob"
);
fprintf
(
pFile
,
" %s"
,
Abc_ObjName
(
Abc_NtkCo
(
pNtk
,
0
))
);
fprintf
(
pFile
,
"
\n
"
);
fprintf
(
pFile
,
".p %d
\n
"
,
nMints
);
// iterate through minterms
for
(
k
=
0
;
k
<
nMints
;
k
++
)
{
Cudd_BddToCubeArray
(
dd
,
pbMints
[
k
],
pArray
);
for
(
i
=
0
;
i
<
Abc_NtkCiNum
(
pNtk
);
i
++
)
if
(
pArray
[
i
]
==
0
)
fprintf
(
pFile
,
"%c"
,
'0'
);
else
if
(
pArray
[
i
]
==
1
)
fprintf
(
pFile
,
"%c"
,
'1'
);
else
if
(
pArray
[
i
]
==
2
)
fprintf
(
pFile
,
"%c"
,
'-'
);
fprintf
(
pFile
,
" "
);
fprintf
(
pFile
,
"%c"
,
'1'
);
fprintf
(
pFile
,
"
\n
"
);
}
fprintf
(
pFile
,
".e
\n
"
);
//for ( k = 0; k < nMints; k++ )
// Cudd_RecursiveDeref( dd, pbMints[k] );
ABC_FREE
(
pbMints
);
ABC_FREE
(
pArray
);
return
1
;
}
int
Io_WriteMoPlaOneM
(
FILE
*
pFile
,
Abc_Ntk_t
*
pNtk
,
int
nMints
)
{
int
fVerbose
=
0
;
DdManager
*
dd
;
DdNode
*
bFunc
;
Vec_Ptr_t
*
vFuncsGlob
;
Abc_Obj_t
*
pObj
;
int
i
;
if
(
Abc_NtkIsStrash
(
pNtk
)
)
{
assert
(
Abc_NtkIsStrash
(
pNtk
)
);
dd
=
(
DdManager
*
)
Abc_NtkBuildGlobalBdds
(
pNtk
,
10000000
,
1
,
1
,
0
,
fVerbose
);
if
(
dd
==
NULL
)
return
0
;
if
(
fVerbose
)
printf
(
"Shared BDD size = %6d nodes.
\n
"
,
Cudd_ReadKeys
(
dd
)
-
Cudd_ReadDead
(
dd
)
);
// complement the global functions
vFuncsGlob
=
Vec_PtrAlloc
(
Abc_NtkCoNum
(
pNtk
)
);
Abc_NtkForEachCo
(
pNtk
,
pObj
,
i
)
Vec_PtrPush
(
vFuncsGlob
,
Abc_ObjGlobalBdd
(
pObj
)
);
// consider minterms
Io_WriteMoPlaOneIntMintermsM
(
pFile
,
pNtk
,
dd
,
(
DdNode
*
)
Vec_PtrEntry
(
vFuncsGlob
,
0
),
nMints
);
Abc_NtkFreeGlobalBdds
(
pNtk
,
0
);
// cleanup
Vec_PtrForEachEntry
(
DdNode
*
,
vFuncsGlob
,
bFunc
,
i
)
Cudd_RecursiveDeref
(
dd
,
bFunc
);
Vec_PtrFree
(
vFuncsGlob
);
//Extra_StopManager( dd );
Cudd_Quit
(
dd
);
}
else
if
(
Abc_NtkIsBddLogic
(
pNtk
)
)
{
DdNode
*
bFunc
=
(
DdNode
*
)
Abc_ObjFanin0
(
Abc_NtkCo
(
pNtk
,
0
))
->
pData
;
dd
=
(
DdManager
*
)
pNtk
->
pManFunc
;
if
(
dd
->
size
==
Abc_NtkCiNum
(
pNtk
)
)
Io_WriteMoPlaOneIntMintermsM
(
pFile
,
pNtk
,
dd
,
bFunc
,
nMints
);
else
{
printf
(
"Cannot write minterms because the size of the manager for local BDDs is not equal to
\n
"
);
printf
(
"the number of primary inputs. (It is likely that the current network is not collapsed.)
\n
"
);
}
}
return
1
;
}
int
Io_WriteMoPlaM
(
Abc_Ntk_t
*
pNtk
,
char
*
pFileName
,
int
nMints
)
{
FILE
*
pFile
;
assert
(
Abc_NtkIsStrash
(
pNtk
)
||
Abc_NtkIsBddLogic
(
pNtk
)
);
pFile
=
fopen
(
pFileName
,
"w"
);
if
(
pFile
==
NULL
)
{
fprintf
(
stdout
,
"Io_WriteMoPlaM(): Cannot open the output file.
\n
"
);
return
0
;
}
fprintf
(
pFile
,
"# Benchmark
\"
%s
\"
written by ABC on %s
\n
"
,
pNtk
->
pName
,
Extra_TimeStamp
()
);
Io_WriteMoPlaOneM
(
pFile
,
pNtk
,
nMints
);
fclose
(
pFile
);
return
1
;
}
#else
#else
int
Io_WriteMoPla
(
Abc_Ntk_t
*
pNtk
,
char
*
pFileName
)
{
return
1
;
}
int
Io_WriteMoPla
(
Abc_Ntk_t
*
pNtk
,
char
*
pFileName
)
{
return
1
;
}
int
Io_WriteMoPlaM
(
Abc_Ntk_t
*
pNtk
,
char
*
pFileName
,
int
nMints
)
{
return
1
;
}
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment