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
d0af09a2
Commit
d0af09a2
authored
Sep 26, 2015
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New command &rexwalk.
parent
62e5ff90
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
268 additions
and
0 deletions
+268
-0
src/aig/gia/giaRex.c
+197
-0
src/base/abci/abc.c
+71
-0
No files found.
src/aig/gia/giaRex.c
View file @
d0af09a2
...
@@ -338,6 +338,203 @@ Gia_Man_t * Gia_ManRex2Gia( char * pStrInit, int fOrder, int fVerbose )
...
@@ -338,6 +338,203 @@ Gia_Man_t * Gia_ManRex2Gia( char * pStrInit, int fOrder, int fVerbose )
return
pNew
;
return
pNew
;
}
}
/**Function*************************************************************
Synopsis [Transposing 64-bit matrix.]
Description [Borrowed from "Hacker's Delight", by Henry Warren.]
SideEffects []
SeeAlso []
***********************************************************************/
void
Gia_ManAutomTranspose64
(
word
A
[
64
]
)
{
int
j
,
k
;
word
t
,
m
=
0x00000000FFFFFFFF
;
for
(
j
=
32
;
j
!=
0
;
j
=
j
>>
1
,
m
=
m
^
(
m
<<
j
)
)
{
for
(
k
=
0
;
k
<
64
;
k
=
(
k
+
j
+
1
)
&
~
j
)
{
t
=
(
A
[
k
]
^
(
A
[
k
+
j
]
>>
j
))
&
m
;
A
[
k
]
=
A
[
k
]
^
t
;
A
[
k
+
j
]
=
A
[
k
+
j
]
^
(
t
<<
j
);
}
}
}
/**Function*************************************************************
Synopsis [Simulate AIG with the given sequence.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
word
Gia_ManAutomSim0
(
Gia_Man_t
*
p
,
Gia_Obj_t
*
pObj
,
Vec_Wrd_t
*
vTemp
)
{
return
Gia_ObjFaninC0
(
pObj
)
?
~
Vec_WrdEntry
(
vTemp
,
Gia_ObjFaninId0p
(
p
,
pObj
))
:
Vec_WrdEntry
(
vTemp
,
Gia_ObjFaninId0p
(
p
,
pObj
));
}
static
inline
word
Gia_ManAutomSim1
(
Gia_Man_t
*
p
,
Gia_Obj_t
*
pObj
,
Vec_Wrd_t
*
vTemp
)
{
return
Gia_ObjFaninC1
(
pObj
)
?
~
Vec_WrdEntry
(
vTemp
,
Gia_ObjFaninId1p
(
p
,
pObj
))
:
Vec_WrdEntry
(
vTemp
,
Gia_ObjFaninId1p
(
p
,
pObj
));
}
word
Gia_ManAutomStep
(
Gia_Man_t
*
p
,
word
Cur
,
word
*
pNext
,
Vec_Wrd_t
*
vTemp
)
{
Gia_Obj_t
*
pObj
;
int
i
;
assert
(
Gia_ManPoNum
(
p
)
==
1
);
assert
(
Vec_WrdSize
(
vTemp
)
>=
Gia_ManObjNum
(
p
)
);
Vec_WrdWriteEntry
(
vTemp
,
0
,
0
);
Gia_ManForEachPi
(
p
,
pObj
,
i
)
Vec_WrdWriteEntry
(
vTemp
,
Gia_ObjId
(
p
,
pObj
),
((
word
)
1
)
<<
(
63
-
i
)
);
Gia_ManForEachRo
(
p
,
pObj
,
i
)
Vec_WrdWriteEntry
(
vTemp
,
Gia_ObjId
(
p
,
pObj
),
((
Cur
>>
(
63
-
i
))
&
1
)
?
~
((
word
)
0
)
:
0
);
Gia_ManForEachAnd
(
p
,
pObj
,
i
)
Vec_WrdWriteEntry
(
vTemp
,
i
,
Gia_ManAutomSim0
(
p
,
pObj
,
vTemp
)
&
Gia_ManAutomSim1
(
p
,
pObj
,
vTemp
)
);
Gia_ManForEachRi
(
p
,
pObj
,
i
)
pNext
[
i
]
=
Gia_ManAutomSim0
(
p
,
pObj
,
vTemp
);
for
(
;
i
<
64
;
i
++
)
pNext
[
i
]
=
0
;
// transpose
// for ( i = 0; i < 64; i++ )
// Extra_PrintBinary( stdout, (unsigned *)&pNext[i], 64 ), Abc_Print( 1, "\n" );
// printf( "\n" );
Gia_ManAutomTranspose64
(
pNext
);
// for ( i = 0; i < 64; i++ )
// Extra_PrintBinary( stdout, (unsigned *)&pNext[i], 64 ), Abc_Print( 1, "\n" );
// printf( "\n" );
// return output values
return
Gia_ManAutomSim0
(
p
,
Gia_ManPo
(
p
,
0
),
vTemp
);
}
void
Gia_ManAutomWalkOne
(
Gia_Man_t
*
p
,
int
nSteps
,
Vec_Wrd_t
*
vStates
,
Vec_Int_t
*
vCounts
,
Vec_Wrd_t
*
vTemp
,
word
Init
)
{
word
iState
=
0
,
Output
,
pNext
[
64
];
int
i
,
k
,
kMin
,
Index
,
IndexMin
;
int
Count
,
CountMin
;
for
(
i
=
0
;
i
<
nSteps
;
i
++
)
{
Output
=
Gia_ManAutomStep
(
p
,
iState
,
pNext
,
vTemp
);
// check visited states
kMin
=
-
1
;
IndexMin
=
-
1
;
CountMin
=
ABC_INFINITY
;
for
(
k
=
0
;
k
<
Gia_ManPiNum
(
p
);
k
++
)
{
if
(
pNext
[
k
]
==
Init
)
continue
;
Index
=
Vec_WrdFind
(
vStates
,
pNext
[
k
]
);
Count
=
Index
==
-
1
?
0
:
Vec_IntEntry
(
vCounts
,
Index
);
if
(
CountMin
>
Count
||
(
CountMin
!=
ABC_INFINITY
&&
Count
&&
((
float
)
CountMin
/
Count
)
>
(
float
)
rand
()
/
RAND_MAX
)
)
{
CountMin
=
Count
;
IndexMin
=
Index
;
kMin
=
k
;
}
if
(
CountMin
==
0
)
break
;
}
// choose the best state
if
(
CountMin
==
ABC_INFINITY
)
{
for
(
k
=
0
;
k
<
Gia_ManPiNum
(
p
);
k
++
)
if
(
(
Output
>>
(
63
-
k
))
&
1
)
{
printf
(
"%c"
,
'a'
+
k
);
printf
(
"!"
);
}
break
;
}
assert
(
CountMin
<
ABC_INFINITY
);
if
(
IndexMin
==
-
1
)
{
assert
(
CountMin
==
0
);
IndexMin
=
Vec_IntSize
(
vCounts
);
Vec_IntPush
(
vCounts
,
0
);
Vec_WrdPush
(
vStates
,
pNext
[
kMin
]
);
}
Vec_IntAddToEntry
(
vCounts
,
IndexMin
,
1
);
iState
=
pNext
[
kMin
];
//Extra_PrintBinary( stdout, (unsigned *)&iState, 64 ); printf( "\n" );
// print the transition
printf
(
"%c"
,
'a'
+
kMin
);
if
(
(
Output
>>
(
63
-
kMin
))
&
1
)
printf
(
"!"
);
}
printf
(
"
\n
"
);
}
// find flop variables pointed to by negative edges
word
Gia_ManAutomInit
(
Gia_Man_t
*
p
)
{
Gia_Obj_t
*
pObj
;
int
i
,
Index
;
word
Init
=
0
;
Gia_ManForEachAnd
(
p
,
pObj
,
i
)
{
if
(
Gia_ObjFaninC0
(
pObj
)
&&
Gia_ObjIsCi
(
Gia_ObjFanin0
(
pObj
))
)
{
Index
=
Gia_ObjCioId
(
Gia_ObjFanin0
(
pObj
))
-
Gia_ManPiNum
(
p
);
if
(
Index
>=
0
)
Init
|=
((
word
)
1
<<
(
63
-
Index
));
}
if
(
Gia_ObjFaninC1
(
pObj
)
&&
Gia_ObjIsCi
(
Gia_ObjFanin1
(
pObj
))
)
{
Index
=
Gia_ObjCioId
(
Gia_ObjFanin1
(
pObj
))
-
Gia_ManPiNum
(
p
);
if
(
Index
>=
0
)
Init
|=
((
word
)
1
<<
(
63
-
Index
));
}
}
return
Init
;
}
void
Gia_ManAutomWalk
(
Gia_Man_t
*
p
,
int
nSteps
,
int
nWalks
,
int
fVerbose
)
{
Vec_Wrd_t
*
vTemp
,
*
vStates
;
Vec_Int_t
*
vCounts
;
int
i
;
word
Init
;
if
(
Gia_ManPoNum
(
p
)
!=
1
)
{
printf
(
"AIG should have one primary output.
\n
"
);
return
;
}
if
(
Gia_ManPiNum
(
p
)
>
64
)
{
printf
(
"Cannot simulate an automaton with more than 64 inputs.
\n
"
);
return
;
}
if
(
Gia_ManRegNum
(
p
)
>
64
)
{
printf
(
"Cannot simulate an automaton with more than 63 states.
\n
"
);
return
;
}
vTemp
=
Vec_WrdStart
(
Gia_ManObjNum
(
p
)
);
vStates
=
Vec_WrdAlloc
(
1000
);
vCounts
=
Vec_IntAlloc
(
1000
);
Vec_WrdPush
(
vStates
,
0
);
Vec_IntPush
(
vCounts
,
1
);
Init
=
Gia_ManAutomInit
(
p
);
for
(
i
=
0
;
i
<
nWalks
;
i
++
)
Gia_ManAutomWalkOne
(
p
,
nSteps
,
vStates
,
vCounts
,
vTemp
,
Init
);
if
(
fVerbose
)
{
word
State
;
Vec_WrdForEachEntry
(
vStates
,
State
,
i
)
{
State
^=
Init
;
printf
(
"%3d : "
,
i
);
Extra_PrintBinary
(
stdout
,
(
unsigned
*
)
&
State
,
64
);
printf
(
" %d "
,
Vec_IntEntry
(
vCounts
,
i
)
);
printf
(
"
\n
"
);
}
printf
(
"
\n
"
);
}
Vec_WrdFree
(
vTemp
);
Vec_WrdFree
(
vStates
);
Vec_IntFree
(
vCounts
);
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
...
...
src/base/abci/abc.c
View file @
d0af09a2
...
@@ -346,6 +346,7 @@ static int Abc_CommandAbc9PSig ( Abc_Frame_t * pAbc, int argc, cha
...
@@ -346,6 +346,7 @@ static int Abc_CommandAbc9PSig ( Abc_Frame_t * pAbc, int argc, cha
static
int
Abc_CommandAbc9Status
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Status
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9MuxProfile
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9MuxProfile
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Rex2Gia
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Rex2Gia
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9RexWalk
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Show
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Show
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9SetRegNum
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9SetRegNum
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Strash
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Strash
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
...
@@ -964,6 +965,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
...
@@ -964,6 +965,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&status"
,
Abc_CommandAbc9Status
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&status"
,
Abc_CommandAbc9Status
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&profile"
,
Abc_CommandAbc9MuxProfile
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&profile"
,
Abc_CommandAbc9MuxProfile
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&rex2gia"
,
Abc_CommandAbc9Rex2Gia
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&rex2gia"
,
Abc_CommandAbc9Rex2Gia
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&rexwalk"
,
Abc_CommandAbc9RexWalk
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&show"
,
Abc_CommandAbc9Show
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&show"
,
Abc_CommandAbc9Show
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&setregnum"
,
Abc_CommandAbc9SetRegNum
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&setregnum"
,
Abc_CommandAbc9SetRegNum
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&st"
,
Abc_CommandAbc9Strash
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&st"
,
Abc_CommandAbc9Strash
,
0
);
...
@@ -27009,6 +27011,75 @@ usage:
...
@@ -27009,6 +27011,75 @@ usage:
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
int
Abc_CommandAbc9RexWalk
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
void
Gia_ManAutomWalk
(
Gia_Man_t
*
p
,
int
nSteps
,
int
nWalks
,
int
fVerbose
);
int
c
,
nSteps
=
50
,
nWalks
=
5
,
fVerbose
=
0
;
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"SRvh"
)
)
!=
EOF
)
{
switch
(
c
)
{
case
'S'
:
if
(
globalUtilOptind
>=
argc
)
{
Abc_Print
(
-
1
,
"Command line switch
\"
-S
\"
should be followed by an integer.
\n
"
);
goto
usage
;
}
nSteps
=
atoi
(
argv
[
globalUtilOptind
]);
globalUtilOptind
++
;
if
(
nSteps
<
0
)
goto
usage
;
break
;
case
'R'
:
if
(
globalUtilOptind
>=
argc
)
{
Abc_Print
(
-
1
,
"Command line switch
\"
-R
\"
should be followed by an integer.
\n
"
);
goto
usage
;
}
nWalks
=
atoi
(
argv
[
globalUtilOptind
]);
globalUtilOptind
++
;
if
(
nWalks
<
0
)
goto
usage
;
break
;
case
'v'
:
fVerbose
^=
1
;
break
;
case
'h'
:
goto
usage
;
default:
goto
usage
;
}
}
if
(
pAbc
->
pGia
==
NULL
)
{
Abc_Print
(
-
1
,
"Abc_CommandAbc9Show(): There is no AIG.
\n
"
);
return
1
;
}
Gia_ManAutomWalk
(
pAbc
->
pGia
,
nSteps
,
nWalks
,
fVerbose
);
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: &rexwalk [-SR] [-vh]
\n
"
);
Abc_Print
(
-
2
,
"
\t
performs simulation of an AIG representing a regular expression
\n
"
);
Abc_Print
(
-
2
,
"
\t
-S num : the number of steps to take [default = %d]
\n
"
,
nSteps
);
Abc_Print
(
-
2
,
"
\t
-R num : the number of walks to make [default = %d]
\n
"
,
nWalks
);
Abc_Print
(
-
2
,
"
\t
-v : toggle verbose output [default = %s]
\n
"
,
fVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-h : print the command usage
\n
"
);
return
1
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Abc_CommandAbc9Show
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
int
Abc_CommandAbc9Show
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
{
Aig_Man_t
*
pMan
;
Aig_Man_t
*
pMan
;
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