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
2ce1ce8b
Commit
2ce1ce8b
authored
Sep 26, 2021
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various changes.
parent
787dbb94
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
158 additions
and
2 deletions
+158
-2
src/aig/gia/giaSimBase.c
+54
-2
src/misc/util/abc_global.h
+1
-0
src/misc/util/utilSort.c
+103
-0
No files found.
src/aig/gia/giaSimBase.c
View file @
2ce1ce8b
...
...
@@ -177,13 +177,17 @@ static inline void Gia_ManSimPatSimAnd3( Gia_Man_t * p, int i, Gia_Obj_t * pObj,
pSimsC1
[
w
]
|=
(
pSims2
[
w
]
|
(
pSims1
[
w
]
^
Diff1
))
&
pSimsC2
[
w
];
}
}
Vec_Wrd_t
*
Gia_ManSimPatSimIn
(
Gia_Man_t
*
pGia
,
Vec_Wrd_t
*
vSims
,
int
fIns
)
Vec_Wrd_t
*
Gia_ManSimPatSimIn
(
Gia_Man_t
*
pGia
,
Vec_Wrd_t
*
vSims
,
int
fIns
,
Vec_Int_t
*
vAnds
)
{
Gia_Obj_t
*
pObj
;
int
i
,
Id
,
nWords
=
Vec_WrdSize
(
vSims
)
/
Gia_ManObjNum
(
pGia
);
Vec_Wrd_t
*
vSimsCi
=
fIns
?
Vec_WrdStart
(
Gia_ManCiNum
(
pGia
)
*
nWords
)
:
NULL
;
Vec_Wrd_t
*
vSimsC
=
Vec_WrdStart
(
Vec_WrdSize
(
vSims
)
);
assert
(
Vec_WrdSize
(
vSims
)
%
Gia_ManObjNum
(
pGia
)
==
0
);
if
(
vAnds
)
Vec_IntForEachEntry
(
vAnds
,
Id
,
i
)
memset
(
Vec_WrdEntryP
(
vSimsC
,
Id
*
nWords
),
0xFF
,
sizeof
(
word
)
*
nWords
);
else
Gia_ManForEachCoDriverId
(
pGia
,
Id
,
i
)
memset
(
Vec_WrdEntryP
(
vSimsC
,
Id
*
nWords
),
0xFF
,
sizeof
(
word
)
*
nWords
);
Gia_ManForEachAndReverse
(
pGia
,
pObj
,
i
)
...
...
@@ -200,7 +204,7 @@ void Gia_ManSimPatSimInTest( Gia_Man_t * pGia )
int
nWords
=
10
;
Vec_Wrd_t
*
vSimsCi
=
Vec_WrdStartRandom
(
Gia_ManCiNum
(
pGia
)
*
nWords
);
Vec_Wrd_t
*
vSims
=
Gia_ManSimPatSimOut
(
pGia
,
vSimsCi
,
0
);
Vec_Wrd_t
*
vSims2
=
Gia_ManSimPatSimIn
(
pGia
,
vSims
,
0
);
Vec_Wrd_t
*
vSims2
=
Gia_ManSimPatSimIn
(
pGia
,
vSims
,
0
,
NULL
);
int
nOnes
=
Abc_TtCountOnesVec
(
Vec_WrdArray
(
vSims2
),
Vec_WrdSize
(
vSims2
)
);
int
nTotal
=
64
*
nWords
*
Gia_ManCandNum
(
pGia
);
printf
(
"Ratio = %6.2f %%
\n
"
,
100
.
0
*
nOnes
/
nTotal
);
...
...
@@ -208,6 +212,54 @@ void Gia_ManSimPatSimInTest( Gia_Man_t * pGia )
Vec_WrdFree
(
vSims2
);
Vec_WrdFree
(
vSimsCi
);
}
static
inline
void
Gia_ManSimPatSimAnd4
(
Gia_Man_t
*
p
,
int
i
,
Gia_Obj_t
*
pObj
,
int
nWords
,
Vec_Wrd_t
*
vSims
,
Vec_Wrd_t
*
vSimsC
)
{
word
pComps
[
2
]
=
{
~
(
word
)
0
,
0
};
word
Diff0
=
pComps
[
Gia_ObjFaninC0
(
pObj
)];
word
Diff1
=
pComps
[
Gia_ObjFaninC1
(
pObj
)];
word
*
pSims0
=
Vec_WrdArray
(
vSims
)
+
nWords
*
Gia_ObjFaninId0
(
pObj
,
i
);
word
*
pSims1
=
Vec_WrdArray
(
vSims
)
+
nWords
*
Gia_ObjFaninId1
(
pObj
,
i
);
word
*
pSimsC0
=
Vec_WrdArray
(
vSimsC
)
+
nWords
*
Gia_ObjFaninId0
(
pObj
,
i
);
word
*
pSimsC1
=
Vec_WrdArray
(
vSimsC
)
+
nWords
*
Gia_ObjFaninId1
(
pObj
,
i
);
word
*
pSimsC2
=
Vec_WrdArray
(
vSimsC
)
+
nWords
*
i
;
int
w
;
if
(
Gia_ObjIsXor
(
pObj
)
)
for
(
w
=
0
;
w
<
nWords
;
w
++
)
pSimsC2
[
w
]
=
pSimsC0
[
w
]
&
pSimsC1
[
w
];
else
for
(
w
=
0
;
w
<
nWords
;
w
++
)
pSimsC2
[
w
]
=
(
pSimsC0
[
w
]
&
pSimsC1
[
w
])
|
((
pSims0
[
w
]
^
Diff0
)
&
pSimsC0
[
w
])
|
((
pSims1
[
w
]
^
Diff1
)
&
pSimsC1
[
w
]);
}
Vec_Wrd_t
*
Gia_ManSimPatSimC
(
Gia_Man_t
*
pGia
,
Vec_Wrd_t
*
vSims
,
Vec_Wrd_t
*
vSimsCiC
)
{
Gia_Obj_t
*
pObj
;
int
i
,
Id
,
nWords
=
Vec_WrdSize
(
vSims
)
/
Gia_ManObjNum
(
pGia
);
Vec_Wrd_t
*
vSimsC
=
Vec_WrdStart
(
Vec_WrdSize
(
vSims
)
);
assert
(
Vec_WrdSize
(
vSims
)
%
Gia_ManObjNum
(
pGia
)
==
0
);
memset
(
Vec_WrdEntryP
(
vSimsC
,
0
),
0xFF
,
sizeof
(
word
)
*
nWords
);
Gia_ManForEachCiId
(
pGia
,
Id
,
i
)
memmove
(
Vec_WrdEntryP
(
vSimsC
,
Id
*
nWords
),
Vec_WrdEntryP
(
vSimsCiC
,
i
*
nWords
),
sizeof
(
word
)
*
nWords
);
Gia_ManForEachAnd
(
pGia
,
pObj
,
i
)
Gia_ManSimPatSimAnd4
(
pGia
,
i
,
pObj
,
nWords
,
vSims
,
vSimsC
);
return
vSimsC
;
}
void
Gia_ManSimPatSimCTest
(
Gia_Man_t
*
pGia
)
{
int
nWords
=
10
;
Vec_Wrd_t
*
vSimsCi
=
Vec_WrdStartRandom
(
Gia_ManCiNum
(
pGia
)
*
nWords
);
Vec_Wrd_t
*
vSims
=
Gia_ManSimPatSimOut
(
pGia
,
vSimsCi
,
0
);
Vec_Wrd_t
*
vSims2
=
Gia_ManSimPatSimIn
(
pGia
,
vSims
,
0
,
NULL
);
Vec_Wrd_t
*
vSimsCi2
=
Gia_ManSimPatSimIn
(
pGia
,
vSims
,
1
,
NULL
);
Vec_Wrd_t
*
vSims3
=
Gia_ManSimPatSimC
(
pGia
,
vSims
,
vSimsCi2
);
int
nOnes2
=
Abc_TtCountOnesVec
(
Vec_WrdArray
(
vSims2
),
Vec_WrdSize
(
vSims2
)
);
int
nOnes3
=
Abc_TtCountOnesVec
(
Vec_WrdArray
(
vSims3
),
Vec_WrdSize
(
vSims3
)
);
int
nTotal
=
64
*
nWords
*
Gia_ManCandNum
(
pGia
);
printf
(
"Ratio = %6.2f %% Ratio = %6.2f %%
\n
"
,
100
.
0
*
nOnes2
/
nTotal
,
100
.
0
*
nOnes3
/
nTotal
);
Vec_WrdFree
(
vSims
);
Vec_WrdFree
(
vSims2
);
Vec_WrdFree
(
vSims3
);
Vec_WrdFree
(
vSimsCi
);
Vec_WrdFree
(
vSimsCi2
);
}
void
Gia_ManSimPatResim
(
Gia_Man_t
*
pGia
,
Vec_Int_t
*
vObjs
,
int
nWords
,
Vec_Wrd_t
*
vSims
)
{
Gia_Obj_t
*
pObj
;
int
i
;
...
...
src/misc/util/abc_global.h
View file @
2ce1ce8b
...
...
@@ -516,6 +516,7 @@ static inline void Abc_ReverseOrder( int * pA, int nA )
extern
void
Abc_MergeSort
(
int
*
pInput
,
int
nSize
);
extern
int
*
Abc_MergeSortCost
(
int
*
pCosts
,
int
nSize
);
extern
void
Abc_MergeSortCost2
(
int
*
pInput
,
int
nSize
,
int
*
pCost
);
extern
void
Abc_MergeSortCost2Reverse
(
int
*
pInput
,
int
nSize
,
int
*
pCost
);
extern
void
Abc_QuickSort1
(
word
*
pData
,
int
nSize
,
int
fDecrease
);
extern
void
Abc_QuickSort2
(
word
*
pData
,
int
nSize
,
int
fDecrease
);
extern
void
Abc_QuickSort3
(
word
*
pData
,
int
nSize
,
int
fDecrease
);
...
...
src/misc/util/utilSort.c
View file @
2ce1ce8b
...
...
@@ -250,6 +250,109 @@ void Abc_MergeSortCost2( int * pInput, int nSize, int * pCost )
SeeAlso []
***********************************************************************/
void
Abc_SortMergeCost2Reverse
(
int
*
p1Beg
,
int
*
p1End
,
int
*
p2Beg
,
int
*
p2End
,
int
*
pOut
,
int
*
pCost
)
{
int
nEntries
=
(
p1End
-
p1Beg
)
+
(
p2End
-
p2Beg
);
int
*
pOutBeg
=
pOut
;
while
(
p1Beg
<
p1End
&&
p2Beg
<
p2End
)
{
if
(
pCost
[
*
p1Beg
]
==
pCost
[
*
p2Beg
]
)
*
pOut
++
=
*
p1Beg
++
,
*
pOut
++
=
*
p2Beg
++
;
else
if
(
pCost
[
*
p1Beg
]
>
pCost
[
*
p2Beg
]
)
*
pOut
++
=
*
p1Beg
++
;
else
// if ( pCost[*p1Beg] < pCost[*p2Beg] )
*
pOut
++
=
*
p2Beg
++
;
}
while
(
p1Beg
<
p1End
)
*
pOut
++
=
*
p1Beg
++
;
while
(
p2Beg
<
p2End
)
*
pOut
++
=
*
p2Beg
++
;
assert
(
pOut
-
pOutBeg
==
nEntries
);
}
/**Function*************************************************************
Synopsis [Recursive sorting.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void
Abc_SortCost2Reverse_rec
(
int
*
pInBeg
,
int
*
pInEnd
,
int
*
pOutBeg
,
int
*
pCost
)
{
int
nSize
=
pInEnd
-
pInBeg
;
assert
(
nSize
>
0
);
if
(
nSize
==
1
)
return
;
if
(
nSize
==
2
)
{
if
(
pCost
[
pInBeg
[
0
]]
<
pCost
[
pInBeg
[
1
]]
)
{
pInBeg
[
0
]
^=
pInBeg
[
1
];
pInBeg
[
1
]
^=
pInBeg
[
0
];
pInBeg
[
0
]
^=
pInBeg
[
1
];
}
}
else
if
(
nSize
<
8
)
{
int
temp
,
i
,
j
,
best_i
;
for
(
i
=
0
;
i
<
nSize
-
1
;
i
++
)
{
best_i
=
i
;
for
(
j
=
i
+
1
;
j
<
nSize
;
j
++
)
if
(
pCost
[
pInBeg
[
j
]]
>
pCost
[
pInBeg
[
best_i
]]
)
best_i
=
j
;
temp
=
pInBeg
[
i
];
pInBeg
[
i
]
=
pInBeg
[
best_i
];
pInBeg
[
best_i
]
=
temp
;
}
}
else
{
Abc_SortCost2Reverse_rec
(
pInBeg
,
pInBeg
+
nSize
/
2
,
pOutBeg
,
pCost
);
Abc_SortCost2Reverse_rec
(
pInBeg
+
nSize
/
2
,
pInEnd
,
pOutBeg
+
nSize
/
2
,
pCost
);
Abc_SortMergeCost2Reverse
(
pInBeg
,
pInBeg
+
nSize
/
2
,
pInBeg
+
nSize
/
2
,
pInEnd
,
pOutBeg
,
pCost
);
memcpy
(
pInBeg
,
pOutBeg
,
sizeof
(
int
)
*
nSize
);
}
}
/**Function*************************************************************
Synopsis [Returns the sorted array of integers.]
Description [This procedure is about 10% faster than qsort().]
SideEffects []
SeeAlso []
***********************************************************************/
void
Abc_MergeSortCost2Reverse
(
int
*
pInput
,
int
nSize
,
int
*
pCost
)
{
int
*
pOutput
;
if
(
nSize
<
2
)
return
;
pOutput
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
nSize
);
Abc_SortCost2Reverse_rec
(
pInput
,
pInput
+
nSize
,
pOutput
,
pCost
);
free
(
pOutput
);
}
/**Function*************************************************************
Synopsis [Merging two lists of entries.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void
Abc_MergeSortCostMerge
(
int
*
p1Beg
,
int
*
p1End
,
int
*
p2Beg
,
int
*
p2End
,
int
*
pOut
)
{
int
nEntries
=
(
p1End
-
p1Beg
)
+
(
p2End
-
p2Beg
);
...
...
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