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
22d9b1d3
Commit
22d9b1d3
authored
Jul 16, 2020
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experiment with structural similarity.
parent
ba063a1b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
220 additions
and
0 deletions
+220
-0
src/aig/gia/gia.h
+3
-0
src/aig/gia/giaDfs.c
+28
-0
src/aig/gia/giaIso3.c
+92
-0
src/aig/gia/giaUtil.c
+22
-0
src/base/abci/abc.c
+60
-0
src/base/acb/acbFunc.c
+15
-0
No files found.
src/aig/gia/gia.h
View file @
22d9b1d3
...
...
@@ -570,6 +570,7 @@ static inline int Gia_ObjPhaseRealLit( Gia_Man_t * p, int iLit ) {
static
inline
int
Gia_ObjLevelId
(
Gia_Man_t
*
p
,
int
Id
)
{
return
Vec_IntGetEntry
(
p
->
vLevels
,
Id
);
}
static
inline
int
Gia_ObjLevel
(
Gia_Man_t
*
p
,
Gia_Obj_t
*
pObj
)
{
return
Gia_ObjLevelId
(
p
,
Gia_ObjId
(
p
,
pObj
)
);
}
static
inline
void
Gia_ObjUpdateLevelId
(
Gia_Man_t
*
p
,
int
Id
,
int
l
)
{
Vec_IntSetEntry
(
p
->
vLevels
,
Id
,
Abc_MaxInt
(
Vec_IntEntry
(
p
->
vLevels
,
Id
),
l
));
}
static
inline
void
Gia_ObjSetLevelId
(
Gia_Man_t
*
p
,
int
Id
,
int
l
)
{
Vec_IntSetEntry
(
p
->
vLevels
,
Id
,
l
);
}
static
inline
void
Gia_ObjSetLevel
(
Gia_Man_t
*
p
,
Gia_Obj_t
*
pObj
,
int
l
)
{
Gia_ObjSetLevelId
(
p
,
Gia_ObjId
(
p
,
pObj
),
l
);
}
static
inline
void
Gia_ObjSetCoLevel
(
Gia_Man_t
*
p
,
Gia_Obj_t
*
pObj
)
{
assert
(
Gia_ObjIsCo
(
pObj
)
);
Gia_ObjSetLevel
(
p
,
pObj
,
Gia_ObjLevel
(
p
,
Gia_ObjFanin0
(
pObj
))
);
}
...
...
@@ -1264,6 +1265,7 @@ extern Vec_Int_t * Gia_ManCollectNodesCis( Gia_Man_t * p, int * pNodes,
extern
int
Gia_ManSuppSize
(
Gia_Man_t
*
p
,
int
*
pNodes
,
int
nNodes
);
extern
int
Gia_ManConeSize
(
Gia_Man_t
*
p
,
int
*
pNodes
,
int
nNodes
);
extern
Vec_Vec_t
*
Gia_ManLevelize
(
Gia_Man_t
*
p
);
extern
Vec_Wec_t
*
Gia_ManLevelizeR
(
Gia_Man_t
*
p
);
extern
Vec_Int_t
*
Gia_ManOrderReverse
(
Gia_Man_t
*
p
);
extern
void
Gia_ManCollectTfi
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vRoots
,
Vec_Int_t
*
vNodes
);
extern
void
Gia_ManCollectTfo
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vRoots
,
Vec_Int_t
*
vNodes
);
...
...
@@ -1670,6 +1672,7 @@ extern void Gia_ManSetPhase1( Gia_Man_t * p );
extern
void
Gia_ManCleanPhase
(
Gia_Man_t
*
p
);
extern
int
Gia_ManCheckCoPhase
(
Gia_Man_t
*
p
);
extern
int
Gia_ManLevelNum
(
Gia_Man_t
*
p
);
extern
int
Gia_ManLevelRNum
(
Gia_Man_t
*
p
);
extern
Vec_Int_t
*
Gia_ManGetCiLevels
(
Gia_Man_t
*
p
);
extern
int
Gia_ManSetLevels
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vCiLevels
);
extern
Vec_Int_t
*
Gia_ManReverseLevel
(
Gia_Man_t
*
p
);
...
...
src/aig/gia/giaDfs.c
View file @
22d9b1d3
...
...
@@ -418,6 +418,34 @@ Vec_Vec_t * Gia_ManLevelize( Gia_Man_t * p )
/**Function*************************************************************
Synopsis [Levelizes the nodes.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Wec_t
*
Gia_ManLevelizeR
(
Gia_Man_t
*
p
)
{
Gia_Obj_t
*
pObj
;
Vec_Wec_t
*
vLevels
;
int
nLevels
,
Level
,
i
;
nLevels
=
Gia_ManLevelRNum
(
p
);
vLevels
=
Vec_WecStart
(
nLevels
+
1
);
Gia_ManForEachObj
(
p
,
pObj
,
i
)
{
if
(
i
==
0
||
(
!
Gia_ObjIsCo
(
pObj
)
&&
!
Gia_ObjLevel
(
p
,
pObj
))
)
continue
;
Level
=
Gia_ObjLevel
(
p
,
pObj
);
assert
(
Level
<=
nLevels
);
Vec_WecPush
(
vLevels
,
Level
,
i
);
}
return
vLevels
;
}
/**Function*************************************************************
Synopsis [Computes reverse topological order.]
Description [Assumes that levels are already assigned.
...
...
src/aig/gia/giaIso3.c
View file @
22d9b1d3
...
...
@@ -158,6 +158,98 @@ void Gia_Iso3Test( Gia_Man_t * p )
Vec_IntFreeP
(
&
vSign
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Wec_t
*
Gia_Iso4Gia
(
Gia_Man_t
*
p
)
{
Vec_Wec_t
*
vLevs
=
Gia_ManLevelizeR
(
p
);
Vec_Int_t
*
vLevel
;
int
l
;
Abc_Random
(
1
);
Vec_WecForEachLevel
(
vLevs
,
vLevel
,
l
)
{
Gia_Obj_t
*
pObj
;
int
i
;
int
RandC
[
2
]
=
{
Abc_Random
(
0
),
Abc_Random
(
0
)
};
if
(
l
==
0
)
{
Gia_ManForEachObjVec
(
vLevel
,
p
,
pObj
,
i
)
{
Gia_Obj_t
*
pfanin
=
Gia_ObjFanin0
(
pObj
);
assert
(
Gia_ObjIsCo
(
pObj
)
);
pObj
->
Value
=
Abc_Random
(
0
);
Gia_ObjFanin0
(
pObj
)
->
Value
+=
pObj
->
Value
+
RandC
[
Gia_ObjFaninC0
(
pObj
)];
}
}
else
{
Gia_ManForEachObjVec
(
vLevel
,
p
,
pObj
,
i
)
if
(
Gia_ObjIsAnd
(
pObj
)
)
{
Gia_ObjFanin0
(
pObj
)
->
Value
+=
pObj
->
Value
+
RandC
[
Gia_ObjFaninC0
(
pObj
)];
Gia_ObjFanin1
(
pObj
)
->
Value
+=
pObj
->
Value
+
RandC
[
Gia_ObjFaninC1
(
pObj
)];
}
}
}
return
vLevs
;
}
void
Gia_Iso4Test
(
Gia_Man_t
*
p
)
{
Vec_Wec_t
*
vLevs
=
Gia_Iso4Gia
(
p
);
Vec_Int_t
*
vLevel
;
int
l
;
Vec_WecForEachLevel
(
vLevs
,
vLevel
,
l
)
{
Gia_Obj_t
*
pObj
;
int
i
;
printf
(
"Level %d
\n
"
,
l
);
Gia_ManForEachObjVec
(
vLevel
,
p
,
pObj
,
i
)
printf
(
"Obj = %5d. Value = %08x.
\n
"
,
Gia_ObjId
(
p
,
pObj
),
pObj
->
Value
);
}
Vec_WecFree
(
vLevs
);
}
Vec_Int_t
*
Gia_IsoCollectData
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vObjs
)
{
Gia_Obj_t
*
pObj
;
int
i
;
Vec_Int_t
*
vData
=
Vec_IntAlloc
(
Vec_IntSize
(
vObjs
)
);
Gia_ManForEachObjVec
(
vObjs
,
p
,
pObj
,
i
)
Vec_IntPush
(
vData
,
pObj
->
Value
);
return
vData
;
}
void
Gia_IsoCompareVecs
(
Gia_Man_t
*
pGia0
,
Vec_Wec_t
*
vLevs0
,
Gia_Man_t
*
pGia1
,
Vec_Wec_t
*
vLevs1
)
{
int
i
,
Common
,
nLevels
=
Abc_MinInt
(
Vec_WecSize
(
vLevs0
),
Vec_WecSize
(
vLevs1
)
);
Gia_ManPrintStats
(
pGia0
,
NULL
);
Gia_ManPrintStats
(
pGia1
,
NULL
);
printf
(
"Printing %d shared levels:
\n
"
,
nLevels
);
for
(
i
=
0
;
i
<
nLevels
;
i
++
)
{
Vec_Int_t
*
vLev0
=
Vec_WecEntry
(
vLevs0
,
i
);
Vec_Int_t
*
vLev1
=
Vec_WecEntry
(
vLevs1
,
i
);
Vec_Int_t
*
vData0
=
Gia_IsoCollectData
(
pGia0
,
vLev0
);
Vec_Int_t
*
vData1
=
Gia_IsoCollectData
(
pGia1
,
vLev1
);
Vec_IntSort
(
vData0
,
0
);
Vec_IntSort
(
vData1
,
0
);
Common
=
Vec_IntTwoCountCommon
(
vData0
,
vData1
);
printf
(
"Level = %3d. One = %6d. Two = %6d. Common = %6d.
\n
"
,
i
,
Vec_IntSize
(
vData0
)
-
Common
,
Vec_IntSize
(
vData1
)
-
Common
,
Common
);
Vec_IntFree
(
vData0
);
Vec_IntFree
(
vData1
);
}
}
void
Gia_Iso4TestTwo
(
Gia_Man_t
*
pGia0
,
Gia_Man_t
*
pGia1
)
{
Vec_Wec_t
*
vLevs0
=
Gia_Iso4Gia
(
pGia0
);
Vec_Wec_t
*
vLevs1
=
Gia_Iso4Gia
(
pGia1
);
Gia_IsoCompareVecs
(
pGia0
,
vLevs0
,
pGia1
,
vLevs1
);
Vec_WecFree
(
vLevs0
);
Vec_WecFree
(
vLevs1
);
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...
...
src/aig/gia/giaUtil.c
View file @
22d9b1d3
...
...
@@ -522,6 +522,28 @@ int Gia_ManLevelNum( Gia_Man_t * p )
}
return
p
->
nLevels
;
}
int
Gia_ManLevelRNum
(
Gia_Man_t
*
p
)
{
Gia_Obj_t
*
pObj
;
int
i
;
Gia_ManCleanLevels
(
p
,
Gia_ManObjNum
(
p
)
);
p
->
nLevels
=
0
;
Gia_ManForEachObjReverse
(
p
,
pObj
,
i
)
{
if
(
!
p
->
fGiaSimple
&&
Gia_ObjIsBuf
(
pObj
)
)
Gia_ObjUpdateLevelId
(
p
,
Gia_ObjFaninId0
(
pObj
,
i
),
Gia_ObjLevel
(
p
,
pObj
)
);
else
if
(
Gia_ObjIsAnd
(
pObj
)
)
{
Gia_ObjUpdateLevelId
(
p
,
Gia_ObjFaninId0
(
pObj
,
i
),
1
+
Gia_ObjLevel
(
p
,
pObj
)
);
Gia_ObjUpdateLevelId
(
p
,
Gia_ObjFaninId1
(
pObj
,
i
),
1
+
Gia_ObjLevel
(
p
,
pObj
)
);
}
else
if
(
Gia_ObjIsCo
(
pObj
)
)
Gia_ObjUpdateLevelId
(
p
,
Gia_ObjFaninId0
(
pObj
,
i
),
1
);
else
p
->
nLevels
=
Abc_MaxInt
(
p
->
nLevels
,
Gia_ObjLevel
(
p
,
pObj
)
);
}
return
p
->
nLevels
;
}
float
Gia_ManLevelAve
(
Gia_Man_t
*
p
)
{
Gia_Obj_t
*
pObj
;
...
...
src/base/abci/abc.c
View file @
22d9b1d3
...
...
@@ -505,6 +505,7 @@ static int Abc_CommandAbc9Mesh ( Abc_Frame_t * pAbc, int argc, cha
static
int
Abc_CommandAbc9Iso
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9IsoNpn
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9IsoSt
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Compare
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9CexInfo
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Cycle
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAbc9Cone
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
...
...
@@ -1226,6 +1227,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&iso"
,
Abc_CommandAbc9Iso
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&isonpn"
,
Abc_CommandAbc9IsoNpn
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&isost"
,
Abc_CommandAbc9IsoSt
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&compare"
,
Abc_CommandAbc9Compare
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&cexinfo"
,
Abc_CommandAbc9CexInfo
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&cycle"
,
Abc_CommandAbc9Cycle
,
0
);
Cmd_CommandAdd
(
pAbc
,
"ABC9"
,
"&cone"
,
Abc_CommandAbc9Cone
,
0
);
...
...
@@ -42291,6 +42293,64 @@ usage:
SeeAlso []
***********************************************************************/
int
Abc_CommandAbc9Compare
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
void
Gia_Iso4TestTwo
(
Gia_Man_t
*
pGia0
,
Gia_Man_t
*
pGia1
);
Gia_Man_t
*
pGia0
,
*
pGia1
;
char
**
pArgvNew
;
int
nArgcNew
;
int
c
,
fVerbose
=
0
;
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"vh"
)
)
!=
EOF
)
{
switch
(
c
)
{
case
'v'
:
fVerbose
^=
1
;
break
;
case
'h'
:
goto
usage
;
default:
goto
usage
;
}
}
pArgvNew
=
argv
+
globalUtilOptind
;
nArgcNew
=
argc
-
globalUtilOptind
;
if
(
nArgcNew
!=
2
)
{
Abc_Print
(
-
1
,
"Abc_CommandAbc9Compare(): This command expects two AIG file names on the command line.
\n
"
);
return
1
;
}
pGia0
=
Gia_AigerRead
(
pArgvNew
[
0
],
0
,
0
,
0
);
pGia1
=
Gia_AigerRead
(
pArgvNew
[
1
],
0
,
0
,
0
);
if
(
pGia0
==
NULL
||
pGia1
==
NULL
)
{
Abc_Print
(
-
1
,
"Abc_CommandAbc9Compare(): Reading input files did not work.
\n
"
);
return
1
;
}
Gia_Iso4TestTwo
(
pGia0
,
pGia1
);
Gia_ManStop
(
pGia0
);
Gia_ManStop
(
pGia1
);
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: &compare <file1> <file2> [-vh]
\n
"
);
Abc_Print
(
-
2
,
"
\t
compared two AIGs for structural similarity
\n
"
);
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
"
);
return
1
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Abc_CommandAbc9CexInfo
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
void
Bmc_CexTest
(
Gia_Man_t
*
p
,
Abc_Cex_t
*
pCex
,
int
fVerbose
);
src/base/acb/acbFunc.c
View file @
22d9b1d3
...
...
@@ -825,6 +825,21 @@ void Vec_IntPermute( Vec_Int_t * p )
}
}
void
Vec_IntPermute2
(
Vec_Int_t
*
p
)
{
int
i
,
nSize
=
Vec_IntSize
(
p
);
int
*
pArray
=
Vec_IntArray
(
p
);
srand
(
time
(
NULL
)
);
for
(
i
=
0
;
i
<
nSize
-
1
;
i
++
)
{
if
(
rand
()
%
3
==
0
)
{
printf
(
"Permuting %d and %d
\n
"
,
i
,
i
+
1
);
ABC_SWAP
(
int
,
pArray
[
i
],
pArray
[
i
+
1
]
);
}
}
}
void
Acb_PrintPatterns
(
Vec_Wrd_t
*
vPats
,
int
nPats
,
Vec_Int_t
*
vWeights
)
{
int
i
,
k
,
Entry
,
nDivs
=
Vec_IntSize
(
vWeights
);
...
...
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