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
68d360c2
Commit
68d360c2
authored
Oct 28, 2012
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move truth table code into a separte file.
parent
f5a8cf99
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
335 additions
and
303 deletions
+335
-303
abclib.dsp
+4
-0
src/base/abci/abcRec3.c
+1
-42
src/map/if/if.h
+1
-1
src/map/if/ifTruth.c
+6
-260
src/misc/util/utilTruth.h
+323
-0
No files found.
abclib.dsp
View file @
68d360c2
...
...
@@ -2709,6 +2709,10 @@ SOURCE=.\src\misc\util\utilSignal.h
SOURCE=.\src\misc\util\utilSort.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\util\utilTruth.h
# End Source File
# End Group
# Begin Group "nm"
...
...
src/base/abci/abcRec3.c
View file @
68d360c2
...
...
@@ -24,6 +24,7 @@
#include "aig/gia/giaAig.h"
#include "misc/vec/vecMem.h"
#include "bool/lucky/lucky.h"
#include "misc/util/utilTruth.h"
ABC_NAMESPACE_IMPL_START
...
...
@@ -407,48 +408,6 @@ void Lms_GiaProfilesPrint( Gia_Man_t * p )
/**Function*************************************************************
Synopsis [Stretch truthtable to have more input variables.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
void
Abc_TtStretch5
(
unsigned
*
pInOut
,
int
nVarS
,
int
nVarB
)
{
int
w
,
i
,
step
,
nWords
;
if
(
nVarS
==
nVarB
)
return
;
assert
(
nVarS
<
nVarB
);
step
=
Abc_TruthWordNum
(
nVarS
);
nWords
=
Abc_TruthWordNum
(
nVarB
);
if
(
step
==
nWords
)
return
;
assert
(
step
<
nWords
);
for
(
w
=
0
;
w
<
nWords
;
w
+=
step
)
for
(
i
=
0
;
i
<
step
;
i
++
)
pInOut
[
w
+
i
]
=
pInOut
[
i
];
}
static
void
Abc_TtStretch6
(
word
*
pInOut
,
int
nVarS
,
int
nVarB
)
{
int
w
,
i
,
step
,
nWords
;
if
(
nVarS
==
nVarB
)
return
;
assert
(
nVarS
<
nVarB
);
step
=
Abc_Truth6WordNum
(
nVarS
);
nWords
=
Abc_Truth6WordNum
(
nVarB
);
if
(
step
==
nWords
)
return
;
assert
(
step
<
nWords
);
for
(
w
=
0
;
w
<
nWords
;
w
+=
step
)
for
(
i
=
0
;
i
<
step
;
i
++
)
pInOut
[
w
+
i
]
=
pInOut
[
i
];
}
/**Function*************************************************************
Synopsis [Compute support sizes for each CO.]
Description []
...
...
src/map/if/if.h
View file @
68d360c2
...
...
@@ -535,7 +535,7 @@ extern void If_ObjPrint( If_Obj_t * pObj );
/*=== abcRec3.c ============================================================*/
extern
int
If_CutDelayRecCost
(
If_Man_t
*
p
,
If_Cut_t
*
pCut
,
If_Obj_t
*
pObj
);
extern
int
If_CutDelayRecCost2
(
If_Man_t
*
p
,
If_Cut_t
*
pCut
,
If_Obj_t
*
pObj
);
extern
int
If_CutDelayRecCost
2
(
If_Man_t
*
p
,
If_Cut_t
*
pCut
,
If_Obj_t
*
pObj
);
extern
int
If_CutDelayRecCost
3
(
If_Man_t
*
p
,
If_Cut_t
*
pCut
,
If_Obj_t
*
pObj
);
extern
ABC_DLL
int
Abc_NtkRecIsRunning
();
extern
ABC_DLL
int
Abc_NtkRecIsRunning2
();
extern
ABC_DLL
int
Abc_NtkRecIsRunning3
();
...
...
src/map/if/ifTruth.c
View file @
68d360c2
...
...
@@ -19,6 +19,7 @@
***********************************************************************/
#include "if.h"
#include "misc/util/utilTruth.h"
ABC_NAMESPACE_IMPL_START
...
...
@@ -450,261 +451,6 @@ int If_CutTruthMinimize( If_Man_t * p, If_Cut_t * pCut )
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
int
Abc_TtWordNum
(
int
nVars
)
{
return
nVars
<=
6
?
1
:
1
<<
(
nVars
-
6
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
void
Abc_TtCopy
(
word
*
pOut
,
word
*
pIn
,
int
nWords
,
int
fCompl
)
{
int
w
;
if
(
fCompl
)
for
(
w
=
0
;
w
<
nWords
;
w
++
)
pOut
[
w
]
=
~
pIn
[
w
];
else
for
(
w
=
0
;
w
<
nWords
;
w
++
)
pOut
[
w
]
=
pIn
[
w
];
}
static
inline
void
Abc_TtAnd
(
word
*
pOut
,
word
*
pIn1
,
word
*
pIn2
,
int
nWords
,
int
fCompl
)
{
int
w
;
if
(
fCompl
)
for
(
w
=
0
;
w
<
nWords
;
w
++
)
pOut
[
w
]
=
~
(
pIn1
[
w
]
&
pIn2
[
w
]);
else
for
(
w
=
0
;
w
<
nWords
;
w
++
)
pOut
[
w
]
=
pIn1
[
w
]
&
pIn2
[
w
];
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
int
Abc_TtSuppIsMinBase
(
int
Supp
)
{
return
(
Supp
&
(
Supp
+
1
))
==
0
;
}
static
inline
int
Abc_Tt6HasVar
(
word
t
,
int
iVar
)
{
static
word
Truth6
[
6
]
=
{
0xAAAAAAAAAAAAAAAA
,
0xCCCCCCCCCCCCCCCC
,
0xF0F0F0F0F0F0F0F0
,
0xFF00FF00FF00FF00
,
0xFFFF0000FFFF0000
,
0xFFFFFFFF00000000
};
return
(
t
&
~
Truth6
[
iVar
])
!=
((
t
&
Truth6
[
iVar
])
>>
(
1
<<
iVar
));
}
static
inline
int
Abc_TtHasVar
(
word
*
t
,
int
nVars
,
int
iVar
)
{
static
word
Truth6
[
6
]
=
{
0xAAAAAAAAAAAAAAAA
,
0xCCCCCCCCCCCCCCCC
,
0xF0F0F0F0F0F0F0F0
,
0xFF00FF00FF00FF00
,
0xFFFF0000FFFF0000
,
0xFFFFFFFF00000000
};
int
nWords
=
Abc_TtWordNum
(
nVars
);
assert
(
iVar
<
nVars
);
if
(
iVar
<
6
)
{
int
i
,
Shift
=
(
1
<<
iVar
);
for
(
i
=
0
;
i
<
nWords
;
i
++
)
if
(
(
t
[
i
]
&
~
Truth6
[
iVar
])
!=
((
t
[
i
]
&
Truth6
[
iVar
])
>>
Shift
)
)
return
1
;
return
0
;
}
else
{
int
i
,
k
,
Step
=
(
1
<<
(
iVar
-
6
));
for
(
k
=
0
;
k
<
nWords
;
k
+=
2
*
Step
)
{
for
(
i
=
0
;
i
<
Step
;
i
++
)
if
(
t
[
i
]
!=
t
[
Step
+
i
]
)
return
1
;
t
+=
2
*
Step
;
}
return
0
;
}
}
static
inline
int
Abc_TtSupport
(
word
*
t
,
int
nVars
)
{
int
v
,
Supp
=
0
;
for
(
v
=
0
;
v
<
nVars
;
v
++
)
if
(
Abc_TtHasVar
(
t
,
nVars
,
v
)
)
Supp
|=
(
1
<<
v
);
return
Supp
;
}
static
inline
int
Abc_TtSupportSize
(
word
*
t
,
int
nVars
)
{
int
v
,
SuppSize
=
0
;
for
(
v
=
0
;
v
<
nVars
;
v
++
)
if
(
Abc_TtHasVar
(
t
,
nVars
,
v
)
)
SuppSize
++
;
return
SuppSize
;
}
static
inline
int
Abc_TtSupportAndSize
(
word
*
t
,
int
nVars
,
int
*
pSuppSize
)
{
int
v
,
Supp
=
0
;
*
pSuppSize
=
0
;
for
(
v
=
0
;
v
<
nVars
;
v
++
)
if
(
Abc_TtHasVar
(
t
,
nVars
,
v
)
)
Supp
|=
(
1
<<
v
),
(
*
pSuppSize
)
++
;
return
Supp
;
}
static
inline
int
Abc_Tt6SupportAndSize
(
word
t
,
int
nVars
,
int
*
pSuppSize
)
{
int
v
,
Supp
=
0
;
*
pSuppSize
=
0
;
assert
(
nVars
<=
6
);
for
(
v
=
0
;
v
<
nVars
;
v
++
)
if
(
Abc_Tt6HasVar
(
t
,
v
)
)
Supp
|=
(
1
<<
v
),
(
*
pSuppSize
)
++
;
return
Supp
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
word
Abc_Tt6SwapVars
(
word
Truth
,
int
iVar
,
int
jVar
)
{
static
word
PPMasks
[
6
][
6
]
=
{
{
0x2222222222222222
,
0x0A0A0A0A0A0A0A0A
,
0x00AA00AA00AA00AA
,
0x0000AAAA0000AAAA
,
0x00000000AAAAAAAA
,
0xAAAAAAAAAAAAAAAA
},
{
0x0000000000000000
,
0x0C0C0C0C0C0C0C0C
,
0x00CC00CC00CC00CC
,
0x0000CCCC0000CCCC
,
0x00000000CCCCCCCC
,
0xCCCCCCCCCCCCCCCC
},
{
0x0000000000000000
,
0x0000000000000000
,
0x00F000F000F000F0
,
0x0000F0F00000F0F0
,
0x00000000F0F0F0F0
,
0xF0F0F0F0F0F0F0F0
},
{
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x0000FF000000FF00
,
0x00000000FF00FF00
,
0xFF00FF00FF00FF00
},
{
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x00000000FFFF0000
,
0xFFFF0000FFFF0000
},
{
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0xFFFFFFFF00000000
}
};
int
shift
;
word
low2High
,
high2Low
;
assert
(
iVar
<=
5
&&
jVar
<=
5
&&
iVar
<
jVar
);
shift
=
(
1
<<
jVar
)
-
(
1
<<
iVar
);
low2High
=
(
Truth
&
PPMasks
[
iVar
][
jVar
-
1
]
)
<<
shift
;
Truth
&=
~
PPMasks
[
iVar
][
jVar
-
1
];
high2Low
=
(
Truth
&
(
PPMasks
[
iVar
][
jVar
-
1
]
<<
shift
))
>>
shift
;
Truth
&=
~
(
PPMasks
[
iVar
][
jVar
-
1
]
<<
shift
);
return
Truth
|
low2High
|
high2Low
;
}
static
inline
void
Abc_TtSwapVars
(
word
*
pTruth
,
int
nVars
,
int
*
V2P
,
int
*
P2V
,
int
iVar
,
int
jVar
)
{
word
low2High
,
high2Low
,
temp
;
int
nWords
=
Abc_TtWordNum
(
nVars
);
int
shift
,
step
,
iStep
,
jStep
;
int
w
=
0
,
i
=
0
,
j
=
0
;
static
word
PPMasks
[
6
][
6
]
=
{
{
0x2222222222222222
,
0x0A0A0A0A0A0A0A0A
,
0x00AA00AA00AA00AA
,
0x0000AAAA0000AAAA
,
0x00000000AAAAAAAA
,
0xAAAAAAAAAAAAAAAA
},
{
0x0000000000000000
,
0x0C0C0C0C0C0C0C0C
,
0x00CC00CC00CC00CC
,
0x0000CCCC0000CCCC
,
0x00000000CCCCCCCC
,
0xCCCCCCCCCCCCCCCC
},
{
0x0000000000000000
,
0x0000000000000000
,
0x00F000F000F000F0
,
0x0000F0F00000F0F0
,
0x00000000F0F0F0F0
,
0xF0F0F0F0F0F0F0F0
},
{
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x0000FF000000FF00
,
0x00000000FF00FF00
,
0xFF00FF00FF00FF00
},
{
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x00000000FFFF0000
,
0xFFFF0000FFFF0000
},
{
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0xFFFFFFFF00000000
}
};
if
(
iVar
==
jVar
)
return
;
if
(
jVar
<
iVar
)
{
int
varTemp
=
jVar
;
jVar
=
iVar
;
iVar
=
varTemp
;
}
if
(
iVar
<=
5
&&
jVar
<=
5
)
{
shift
=
(
1
<<
jVar
)
-
(
1
<<
iVar
);
for
(
w
=
0
;
w
<
nWords
;
w
++
)
{
low2High
=
(
pTruth
[
w
]
&
PPMasks
[
iVar
][
jVar
-
1
]
)
<<
shift
;
pTruth
[
w
]
&=
~
PPMasks
[
iVar
][
jVar
-
1
];
high2Low
=
(
pTruth
[
w
]
&
(
PPMasks
[
iVar
][
jVar
-
1
]
<<
shift
))
>>
shift
;
pTruth
[
w
]
&=
~
(
PPMasks
[
iVar
][
jVar
-
1
]
<<
shift
);
pTruth
[
w
]
=
pTruth
[
w
]
|
low2High
|
high2Low
;
}
}
else
if
(
iVar
<=
5
&&
jVar
>
5
)
{
step
=
Abc_TtWordNum
(
jVar
+
1
)
/
2
;
shift
=
1
<<
iVar
;
for
(
w
=
0
;
w
<
nWords
;
w
+=
2
*
step
)
{
for
(
j
=
0
;
j
<
step
;
j
++
)
{
low2High
=
(
pTruth
[
w
+
j
]
&
PPMasks
[
iVar
][
5
])
>>
shift
;
pTruth
[
w
+
j
]
&=
~
PPMasks
[
iVar
][
5
];
high2Low
=
(
pTruth
[
w
+
step
+
j
]
&
(
PPMasks
[
iVar
][
5
]
>>
shift
))
<<
shift
;
pTruth
[
w
+
step
+
j
]
&=
~
(
PPMasks
[
iVar
][
5
]
>>
shift
);
pTruth
[
w
+
j
]
|=
high2Low
;
pTruth
[
w
+
step
+
j
]
|=
low2High
;
}
}
}
else
{
iStep
=
Abc_TtWordNum
(
iVar
+
1
)
/
2
;
jStep
=
Abc_TtWordNum
(
jVar
+
1
)
/
2
;
for
(
w
=
0
;
w
<
nWords
;
w
+=
2
*
jStep
)
{
for
(
i
=
0
;
i
<
jStep
;
i
+=
2
*
iStep
)
{
for
(
j
=
0
;
j
<
iStep
;
j
++
)
{
temp
=
pTruth
[
w
+
iStep
+
i
+
j
];
pTruth
[
w
+
iStep
+
i
+
j
]
=
pTruth
[
w
+
jStep
+
i
+
j
];
pTruth
[
w
+
jStep
+
i
+
j
]
=
temp
;
}
}
}
}
if
(
V2P
&&
P2V
)
{
V2P
[
P2V
[
iVar
]]
=
jVar
;
V2P
[
P2V
[
jVar
]]
=
iVar
;
P2V
[
iVar
]
^=
P2V
[
jVar
];
P2V
[
jVar
]
^=
P2V
[
iVar
];
P2V
[
iVar
]
^=
P2V
[
jVar
];
}
}
/**Function*************************************************************
Synopsis [Performs truth table computation.]
...
...
@@ -741,7 +487,7 @@ static inline int If_CutTruthMinimize6( If_Man_t * p, If_Cut_t * pCut )
if
(
k
<
i
)
{
pCut
->
pLeaves
[
k
]
=
pCut
->
pLeaves
[
i
];
*
If_CutTruthW
(
pCut
)
=
Abc_Tt6SwapVars
(
*
If_CutTruthW
(
pCut
)
,
k
,
i
);
Abc_TtSwapVars
(
If_CutTruthW
(
pCut
),
pCut
->
nLimit
,
k
,
i
);
}
k
++
;
}
...
...
@@ -760,7 +506,7 @@ static inline word If_TruthStretch6( word Truth, If_Cut_t * pCut, If_Cut_t * pCu
continue
;
assert
(
pCut0
->
pLeaves
[
k
]
==
pCut
->
pLeaves
[
i
]
);
if
(
k
<
i
)
Truth
=
Abc_Tt6SwapVars
(
Truth
,
k
,
i
);
Abc_TtSwapVars
(
&
Truth
,
pCut
->
nLimit
,
k
,
i
);
k
--
;
}
return
Truth
;
...
...
@@ -804,7 +550,7 @@ static inline int If_CutTruthMinimize21( If_Man_t * p, If_Cut_t * pCut )
if
(
k
<
i
)
{
pCut
->
pLeaves
[
k
]
=
pCut
->
pLeaves
[
i
];
Abc_TtSwapVars
(
pTruth
,
nVars
,
NULL
,
NULL
,
k
,
i
);
Abc_TtSwapVars
(
pTruth
,
nVars
,
k
,
i
);
}
k
++
;
}
...
...
@@ -848,7 +594,7 @@ static inline int If_CutTruthMinimize2( If_Man_t * p, If_Cut_t * pCut )
if
(
k
<
i
)
{
pCut
->
pLeaves
[
k
]
=
pCut
->
pLeaves
[
i
];
Abc_TtSwapVars
(
If_CutTruthW
(
pCut
),
pCut
->
nLimit
,
NULL
,
NULL
,
k
,
i
);
Abc_TtSwapVars
(
If_CutTruthW
(
pCut
),
pCut
->
nLimit
,
k
,
i
);
}
k
++
;
}
...
...
@@ -867,7 +613,7 @@ static inline void If_TruthStretch2( word * pTruth, If_Cut_t * pCut, If_Cut_t *
continue
;
assert
(
pCut0
->
pLeaves
[
k
]
==
pCut
->
pLeaves
[
i
]
);
if
(
k
<
i
)
Abc_TtSwapVars
(
pTruth
,
pCut
->
nLimit
,
NULL
,
NULL
,
k
,
i
);
Abc_TtSwapVars
(
pTruth
,
pCut
->
nLimit
,
k
,
i
);
k
--
;
}
}
...
...
src/misc/util/utilTruth.h
0 → 100644
View file @
68d360c2
/**CFile****************************************************************
FileName [utilTruth.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Truth table manipulation.]
Synopsis [Truth table manipulation.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - October 28, 2012.]
Revision [$Id: utilTruth.h,v 1.00 2012/10/28 00:00:00 alanmi Exp $]
***********************************************************************/
#ifndef ABC__misc__util__utilTruth_h
#define ABC__misc__util__utilTruth_h
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
static
word
s_Truths6
[
6
]
=
{
0xAAAAAAAAAAAAAAAA
,
0xCCCCCCCCCCCCCCCC
,
0xF0F0F0F0F0F0F0F0
,
0xFF00FF00FF00FF00
,
0xFFFF0000FFFF0000
,
0xFFFFFFFF00000000
};
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
int
Abc_TtWordNum
(
int
nVars
)
{
return
nVars
<=
6
?
1
:
1
<<
(
nVars
-
6
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
void
Abc_TtCopy
(
word
*
pOut
,
word
*
pIn
,
int
nWords
,
int
fCompl
)
{
int
w
;
if
(
fCompl
)
for
(
w
=
0
;
w
<
nWords
;
w
++
)
pOut
[
w
]
=
~
pIn
[
w
];
else
for
(
w
=
0
;
w
<
nWords
;
w
++
)
pOut
[
w
]
=
pIn
[
w
];
}
static
inline
void
Abc_TtAnd
(
word
*
pOut
,
word
*
pIn1
,
word
*
pIn2
,
int
nWords
,
int
fCompl
)
{
int
w
;
if
(
fCompl
)
for
(
w
=
0
;
w
<
nWords
;
w
++
)
pOut
[
w
]
=
~
(
pIn1
[
w
]
&
pIn2
[
w
]);
else
for
(
w
=
0
;
w
<
nWords
;
w
++
)
pOut
[
w
]
=
pIn1
[
w
]
&
pIn2
[
w
];
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
int
Abc_TtSuppIsMinBase
(
int
Supp
)
{
return
(
Supp
&
(
Supp
+
1
))
==
0
;
}
static
inline
int
Abc_Tt6HasVar
(
word
t
,
int
iVar
)
{
return
(
t
&
~
s_Truths6
[
iVar
])
!=
((
t
&
s_Truths6
[
iVar
])
>>
(
1
<<
iVar
));
}
static
inline
int
Abc_TtHasVar
(
word
*
t
,
int
nVars
,
int
iVar
)
{
int
nWords
=
Abc_TtWordNum
(
nVars
);
assert
(
iVar
<
nVars
);
if
(
iVar
<
6
)
{
int
i
,
Shift
=
(
1
<<
iVar
);
for
(
i
=
0
;
i
<
nWords
;
i
++
)
if
(
(
t
[
i
]
&
~
s_Truths6
[
iVar
])
!=
((
t
[
i
]
&
s_Truths6
[
iVar
])
>>
Shift
)
)
return
1
;
return
0
;
}
else
{
int
i
,
k
,
Step
=
(
1
<<
(
iVar
-
6
));
for
(
k
=
0
;
k
<
nWords
;
k
+=
2
*
Step
,
t
+=
2
*
Step
)
for
(
i
=
0
;
i
<
Step
;
i
++
)
if
(
t
[
i
]
!=
t
[
Step
+
i
]
)
return
1
;
return
0
;
}
}
static
inline
int
Abc_TtSupport
(
word
*
t
,
int
nVars
)
{
int
v
,
Supp
=
0
;
for
(
v
=
0
;
v
<
nVars
;
v
++
)
if
(
Abc_TtHasVar
(
t
,
nVars
,
v
)
)
Supp
|=
(
1
<<
v
);
return
Supp
;
}
static
inline
int
Abc_TtSupportSize
(
word
*
t
,
int
nVars
)
{
int
v
,
SuppSize
=
0
;
for
(
v
=
0
;
v
<
nVars
;
v
++
)
if
(
Abc_TtHasVar
(
t
,
nVars
,
v
)
)
SuppSize
++
;
return
SuppSize
;
}
static
inline
int
Abc_TtSupportAndSize
(
word
*
t
,
int
nVars
,
int
*
pSuppSize
)
{
int
v
,
Supp
=
0
;
*
pSuppSize
=
0
;
for
(
v
=
0
;
v
<
nVars
;
v
++
)
if
(
Abc_TtHasVar
(
t
,
nVars
,
v
)
)
Supp
|=
(
1
<<
v
),
(
*
pSuppSize
)
++
;
return
Supp
;
}
static
inline
int
Abc_Tt6SupportAndSize
(
word
t
,
int
nVars
,
int
*
pSuppSize
)
{
int
v
,
Supp
=
0
;
*
pSuppSize
=
0
;
assert
(
nVars
<=
6
);
for
(
v
=
0
;
v
<
nVars
;
v
++
)
if
(
Abc_Tt6HasVar
(
t
,
v
)
)
Supp
|=
(
1
<<
v
),
(
*
pSuppSize
)
++
;
return
Supp
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
void
Abc_TtSwapVars
(
word
*
pTruth
,
int
nVars
,
int
iVar
,
int
jVar
)
{
static
word
PPMasks
[
6
][
6
]
=
{
{
0x2222222222222222
,
0x0A0A0A0A0A0A0A0A
,
0x00AA00AA00AA00AA
,
0x0000AAAA0000AAAA
,
0x00000000AAAAAAAA
,
0xAAAAAAAAAAAAAAAA
},
{
0x0000000000000000
,
0x0C0C0C0C0C0C0C0C
,
0x00CC00CC00CC00CC
,
0x0000CCCC0000CCCC
,
0x00000000CCCCCCCC
,
0xCCCCCCCCCCCCCCCC
},
{
0x0000000000000000
,
0x0000000000000000
,
0x00F000F000F000F0
,
0x0000F0F00000F0F0
,
0x00000000F0F0F0F0
,
0xF0F0F0F0F0F0F0F0
},
{
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x0000FF000000FF00
,
0x00000000FF00FF00
,
0xFF00FF00FF00FF00
},
{
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x00000000FFFF0000
,
0xFFFF0000FFFF0000
},
{
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0x0000000000000000
,
0xFFFFFFFF00000000
}
};
if
(
nVars
<=
6
)
{
int
shift
;
word
low2High
,
high2Low
;
assert
(
iVar
<=
5
&&
jVar
<=
5
&&
iVar
<
jVar
);
shift
=
(
1
<<
jVar
)
-
(
1
<<
iVar
);
low2High
=
(
pTruth
[
0
]
&
PPMasks
[
iVar
][
jVar
-
1
]
)
<<
shift
;
pTruth
[
0
]
&=
~
PPMasks
[
iVar
][
jVar
-
1
];
high2Low
=
(
pTruth
[
0
]
&
(
PPMasks
[
iVar
][
jVar
-
1
]
<<
shift
))
>>
shift
;
pTruth
[
0
]
&=
~
(
PPMasks
[
iVar
][
jVar
-
1
]
<<
shift
);
pTruth
[
0
]
|=
low2High
|
high2Low
;
}
else
{
word
low2High
,
high2Low
,
temp
;
int
nWords
=
Abc_TtWordNum
(
nVars
);
int
shift
,
step
,
iStep
,
jStep
;
int
w
=
0
,
i
=
0
,
j
=
0
;
if
(
iVar
==
jVar
)
return
;
if
(
jVar
<
iVar
)
ABC_SWAP
(
int
,
iVar
,
jVar
);
if
(
iVar
<=
5
&&
jVar
<=
5
)
{
shift
=
(
1
<<
jVar
)
-
(
1
<<
iVar
);
for
(
w
=
0
;
w
<
nWords
;
w
++
)
{
low2High
=
(
pTruth
[
w
]
&
PPMasks
[
iVar
][
jVar
-
1
]
)
<<
shift
;
pTruth
[
w
]
&=
~
PPMasks
[
iVar
][
jVar
-
1
];
high2Low
=
(
pTruth
[
w
]
&
(
PPMasks
[
iVar
][
jVar
-
1
]
<<
shift
))
>>
shift
;
pTruth
[
w
]
&=
~
(
PPMasks
[
iVar
][
jVar
-
1
]
<<
shift
);
pTruth
[
w
]
|=
low2High
|
high2Low
;
}
}
else
if
(
iVar
<=
5
&&
jVar
>
5
)
{
step
=
Abc_TtWordNum
(
jVar
+
1
)
/
2
;
shift
=
1
<<
iVar
;
for
(
w
=
0
;
w
<
nWords
;
w
+=
2
*
step
)
{
for
(
j
=
0
;
j
<
step
;
j
++
)
{
low2High
=
(
pTruth
[
w
+
j
]
&
PPMasks
[
iVar
][
5
])
>>
shift
;
pTruth
[
w
+
j
]
&=
~
PPMasks
[
iVar
][
5
];
high2Low
=
(
pTruth
[
w
+
step
+
j
]
&
(
PPMasks
[
iVar
][
5
]
>>
shift
))
<<
shift
;
pTruth
[
w
+
step
+
j
]
&=
~
(
PPMasks
[
iVar
][
5
]
>>
shift
);
pTruth
[
w
+
j
]
|=
high2Low
;
pTruth
[
w
+
step
+
j
]
|=
low2High
;
}
}
}
else
{
iStep
=
Abc_TtWordNum
(
iVar
+
1
)
/
2
;
jStep
=
Abc_TtWordNum
(
jVar
+
1
)
/
2
;
for
(
w
=
0
;
w
<
nWords
;
w
+=
2
*
jStep
)
{
for
(
i
=
0
;
i
<
jStep
;
i
+=
2
*
iStep
)
{
for
(
j
=
0
;
j
<
iStep
;
j
++
)
{
temp
=
pTruth
[
w
+
iStep
+
i
+
j
];
pTruth
[
w
+
iStep
+
i
+
j
]
=
pTruth
[
w
+
jStep
+
i
+
j
];
pTruth
[
w
+
jStep
+
i
+
j
]
=
temp
;
}
}
}
}
}
}
/**Function*************************************************************
Synopsis [Stretch truthtable to have more input variables.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
void
Abc_TtStretch5
(
unsigned
*
pInOut
,
int
nVarS
,
int
nVarB
)
{
int
w
,
i
,
step
,
nWords
;
if
(
nVarS
==
nVarB
)
return
;
assert
(
nVarS
<
nVarB
);
step
=
Abc_TruthWordNum
(
nVarS
);
nWords
=
Abc_TruthWordNum
(
nVarB
);
if
(
step
==
nWords
)
return
;
assert
(
step
<
nWords
);
for
(
w
=
0
;
w
<
nWords
;
w
+=
step
)
for
(
i
=
0
;
i
<
step
;
i
++
)
pInOut
[
w
+
i
]
=
pInOut
[
i
];
}
static
void
Abc_TtStretch6
(
word
*
pInOut
,
int
nVarS
,
int
nVarB
)
{
int
w
,
i
,
step
,
nWords
;
if
(
nVarS
==
nVarB
)
return
;
assert
(
nVarS
<
nVarB
);
step
=
Abc_Truth6WordNum
(
nVarS
);
nWords
=
Abc_Truth6WordNum
(
nVarB
);
if
(
step
==
nWords
)
return
;
assert
(
step
<
nWords
);
for
(
w
=
0
;
w
<
nWords
;
w
+=
step
)
for
(
i
=
0
;
i
<
step
;
i
++
)
pInOut
[
w
+
i
]
=
pInOut
[
i
];
}
/*=== utilTruth.c ===========================================================*/
ABC_NAMESPACE_HEADER_END
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
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