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
e86e4b66
Commit
e86e4b66
authored
May 18, 2013
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added switch -I <file_name> to &sim to perform simulation with the user's simulation pattern.
parent
2a71e3e7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
122 additions
and
2 deletions
+122
-2
src/aig/gia/giaSim.c
+95
-0
src/base/abci/abc.c
+27
-2
No files found.
src/aig/gia/giaSim.c
View file @
e86e4b66
...
...
@@ -663,6 +663,101 @@ int Gia_ManSimSimulate( Gia_Man_t * pAig, Gia_ParSim_t * pPars )
return
RetValue
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t
*
Gia_ManSimReadFile
(
char
*
pFileIn
)
{
int
c
;
Vec_Int_t
*
vPat
;
FILE
*
pFile
=
fopen
(
pFileIn
,
"rb"
);
if
(
pFile
==
NULL
)
{
printf
(
"Cannot open input file.
\n
"
);
return
NULL
;
}
vPat
=
Vec_IntAlloc
(
1000
);
while
(
(
c
=
fgetc
(
pFile
))
!=
EOF
)
if
(
c
==
'0'
||
c
==
'1'
)
Vec_IntPush
(
vPat
,
c
-
'0'
);
fclose
(
pFile
);
return
vPat
;
}
int
Gia_ManSimWriteFile
(
char
*
pFileOut
,
Vec_Int_t
*
vPat
,
int
nOuts
)
{
int
c
,
i
;
FILE
*
pFile
=
fopen
(
pFileOut
,
"wb"
);
if
(
pFile
==
NULL
)
{
printf
(
"Cannot open output file.
\n
"
);
return
0
;
}
assert
(
Vec_IntSize
(
vPat
)
%
nOuts
==
0
);
Vec_IntForEachEntry
(
vPat
,
c
,
i
)
{
fputc
(
'0'
+
c
,
pFile
);
if
(
i
%
nOuts
==
nOuts
-
1
)
fputc
(
'\n'
,
pFile
);
}
fclose
(
pFile
);
return
1
;
}
Vec_Int_t
*
Gia_ManSimSimulateOne
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vPat
)
{
Vec_Int_t
*
vPatOut
;
Gia_Obj_t
*
pObj
,
*
pObjRo
;
int
i
,
k
,
f
;
assert
(
Vec_IntSize
(
vPat
)
%
Gia_ManPiNum
(
p
)
==
0
);
Gia_ManConst0
(
p
)
->
fMark1
=
0
;
Gia_ManForEachRo
(
p
,
pObj
,
i
)
pObj
->
fMark1
=
0
;
vPatOut
=
Vec_IntAlloc
(
1000
);
for
(
k
=
f
=
0
;
f
<
Vec_IntSize
(
vPat
)
/
Gia_ManPiNum
(
p
);
f
++
)
{
Gia_ManForEachPi
(
p
,
pObj
,
i
)
pObj
->
fMark1
=
Vec_IntEntry
(
vPat
,
k
++
);
Gia_ManForEachAnd
(
p
,
pObj
,
i
)
pObj
->
fMark1
=
(
Gia_ObjFanin0
(
pObj
)
->
fMark1
^
Gia_ObjFaninC0
(
pObj
))
&
(
Gia_ObjFanin1
(
pObj
)
->
fMark1
^
Gia_ObjFaninC1
(
pObj
));
Gia_ManForEachCo
(
p
,
pObj
,
i
)
pObj
->
fMark1
=
(
Gia_ObjFanin0
(
pObj
)
->
fMark1
^
Gia_ObjFaninC0
(
pObj
));
Gia_ManForEachPo
(
p
,
pObj
,
i
)
Vec_IntPush
(
vPatOut
,
pObj
->
fMark1
);
Gia_ManForEachRiRo
(
p
,
pObj
,
pObjRo
,
i
)
pObjRo
->
fMark1
=
pObj
->
fMark1
;
}
assert
(
k
==
Vec_IntSize
(
vPat
)
);
Gia_ManForEachObj
(
p
,
pObj
,
i
)
pObj
->
fMark1
=
0
;
return
vPatOut
;
}
void
Gia_ManSimSimulatePattern
(
Gia_Man_t
*
p
,
char
*
pFileIn
,
char
*
pFileOut
)
{
Vec_Int_t
*
vPat
,
*
vPatOut
;
vPat
=
Gia_ManSimReadFile
(
pFileIn
);
if
(
vPat
==
NULL
)
return
;
if
(
Vec_IntSize
(
vPat
)
%
Gia_ManPiNum
(
p
)
)
{
printf
(
"The number of 0s and 1s in the input file (%d) does not evenly divide by the number of primary inputs (%d).
\n
"
,
Vec_IntSize
(
vPat
),
Gia_ManPiNum
(
p
)
);
Vec_IntFree
(
vPat
);
return
;
}
vPatOut
=
Gia_ManSimSimulateOne
(
p
,
vPat
);
if
(
Gia_ManSimWriteFile
(
pFileOut
,
vPatOut
,
Gia_ManPoNum
(
p
)
)
)
printf
(
"Output patterns are written into file
\"
%s
\"
.
\n
"
,
pFileOut
);
Vec_IntFree
(
vPat
);
Vec_IntFree
(
vPatOut
);
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...
...
src/base/abci/abc.c
View file @
e86e4b66
...
...
@@ -25155,10 +25155,11 @@ usage:
int
Abc_CommandAbc9Sim
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
Gia_ParSim_t
Pars
,
*
pPars
=
&
Pars
;
char
*
pFileName
=
NULL
;
int
c
;
Gia_ManSimSetDefaultParams
(
pPars
);
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"FWNTmvh"
)
)
!=
EOF
)
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"FWNT
I
mvh"
)
)
!=
EOF
)
{
switch
(
c
)
{
...
...
@@ -25206,6 +25207,17 @@ int Abc_CommandAbc9Sim( Abc_Frame_t * pAbc, int argc, char ** argv )
if
(
pPars
->
TimeLimit
<
0
)
goto
usage
;
break
;
case
'I'
:
if
(
globalUtilOptind
>=
argc
)
{
Abc_Print
(
-
1
,
"Command line switch
\"
-I
\"
should be followed by an integer.
\n
"
);
goto
usage
;
}
pFileName
=
argv
[
globalUtilOptind
];
globalUtilOptind
++
;
if
(
pFileName
==
NULL
)
goto
usage
;
break
;
case
'm'
:
pPars
->
fCheckMiter
^=
1
;
break
;
...
...
@@ -25228,6 +25240,18 @@ int Abc_CommandAbc9Sim( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print
(
-
1
,
"The network is combinational.
\n
"
);
return
0
;
}
if
(
pFileName
!=
NULL
)
{
extern
void
Gia_ManSimSimulatePattern
(
Gia_Man_t
*
p
,
char
*
pFileIn
,
char
*
pFileOut
);
char
pFileNameOut
[
1000
];
char
*
pNameGeneric
=
Extra_FileNameGeneric
(
pFileName
);
assert
(
strlen
(
pNameGeneric
)
<
900
);
sprintf
(
pFileNameOut
,
"%s_out.%s"
,
pNameGeneric
,
Extra_FileNameExtension
(
pFileName
)
);
ABC_FREE
(
pNameGeneric
);
Gia_ManSimSimulatePattern
(
pAbc
->
pGia
,
pFileName
,
pFileNameOut
);
return
1
;
}
pAbc
->
nFrames
=
-
1
;
if
(
Gia_ManSimSimulate
(
pAbc
->
pGia
,
pPars
)
)
pAbc
->
Status
=
0
;
...
...
@@ -25239,7 +25263,7 @@ int Abc_CommandAbc9Sim( Abc_Frame_t * pAbc, int argc, char ** argv )
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: &sim [-FWNT num] [-mvh]
\n
"
);
Abc_Print
(
-
2
,
"usage: &sim [-FWNT num] [-mvh]
-I <file>
\n
"
);
Abc_Print
(
-
2
,
"
\t
performs random simulation of the sequential miter
\n
"
);
Abc_Print
(
-
2
,
"
\t
(if candidate equivalences are defined, performs refinement)
\n
"
);
Abc_Print
(
-
2
,
"
\t
-F num : the number of frames to simulate [default = %d]
\n
"
,
pPars
->
nIters
);
...
...
@@ -25249,6 +25273,7 @@ usage:
Abc_Print
(
-
2
,
"
\t
-m : toggle miter vs. any circuit [default = %s]
\n
"
,
pPars
->
fCheckMiter
?
"miter"
:
"circuit"
);
Abc_Print
(
-
2
,
"
\t
-v : toggle printing verbose information [default = %s]
\n
"
,
pPars
->
fVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-h : print the command usage
\n
"
);
Abc_Print
(
-
2
,
"
\t
-I file: (optional) file with input patterns (one line per frame, as many as PIs)
\n
"
);
return
1
;
}
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