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
ff1fb175
Commit
ff1fb175
authored
Jan 31, 2015
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preprocessing for multi-output PLA tables.
parent
c58dd062
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
143 additions
and
0 deletions
+143
-0
src/base/io/ioReadPla.c
+124
-0
src/misc/util/abc_global.h
+1
-0
src/misc/util/utilTruth.h
+18
-0
No files found.
src/base/io/ioReadPla.c
View file @
ff1fb175
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
***********************************************************************/
***********************************************************************/
#include "ioAbc.h"
#include "ioAbc.h"
#include "misc/util/utilTruth.h"
ABC_NAMESPACE_IMPL_START
ABC_NAMESPACE_IMPL_START
...
@@ -33,6 +34,128 @@ static Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros );
...
@@ -33,6 +34,128 @@ static Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros );
/// FUNCTION DEFINITIONS ///
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
static
inline
Io_CubesEqual
(
word
*
c1
,
word
*
c2
,
int
nWords
)
{
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
word
**
Io_ReadPlaCubeSetup
(
Vec_Str_t
*
vSop
)
{
char
*
pSop
=
Vec_StrArray
(
vSop
),
*
pCube
,
Lit
;
int
nCubes
=
Abc_SopGetCubeNum
(
pSop
);
int
nVars
=
Abc_SopGetVarNum
(
pSop
);
int
nWords
=
Abc_Bit6WordNum
(
2
*
nVars
),
c
,
v
;
word
**
pCs
=
ABC_ALLOC
(
word
*
,
nCubes
);
pCs
[
0
]
=
ABC_CALLOC
(
word
,
nCubes
*
nWords
);
for
(
c
=
1
;
c
<
nCubes
;
c
++
)
pCs
[
c
]
=
pCs
[
c
-
1
]
+
nWords
;
c
=
0
;
Abc_SopForEachCube
(
pSop
,
nVars
,
pCube
)
{
Abc_CubeForEachVar
(
pCube
,
Lit
,
v
)
if
(
Lit
==
'0'
)
Abc_TtSetBit
(
pCs
[
c
],
Abc_Var2Lit
(
v
,
0
)
);
else
if
(
Lit
==
'1'
)
Abc_TtSetBit
(
pCs
[
c
],
Abc_Var2Lit
(
v
,
1
)
);
c
++
;
}
assert
(
c
==
nCubes
);
return
pCs
;
}
void
Io_ReadPlaCubeSetdown
(
Vec_Str_t
*
vSop
,
word
**
pCs
,
int
nCubes
,
int
nVars
)
{
char
Symbs
[
3
]
=
{
'-'
,
'0'
,
'1'
};
int
c
,
v
,
Lit
;
Vec_StrClear
(
vSop
);
for
(
c
=
0
;
c
<
nCubes
;
c
++
)
{
for
(
v
=
0
;
v
<
nVars
&&
((
Lit
=
Abc_TtGetQua
(
pCs
[
c
],
v
)),
1
);
v
++
)
{
assert
(
Lit
<
3
);
Vec_StrPush
(
vSop
,
Symbs
[
Lit
]
);
}
Vec_StrPrintStr
(
vSop
,
" 1
\n
"
);
}
Vec_StrPush
(
vSop
,
0
);
}
void
Io_ReadPlaCubePreprocess
(
Vec_Str_t
*
vSop
,
int
iCover
,
int
fVerbose
)
{
word
**
pCs
=
Io_ReadPlaCubeSetup
(
vSop
);
int
nCubes
=
Abc_SopGetCubeNum
(
Vec_StrArray
(
vSop
)
);
int
nVars
=
Abc_SopGetVarNum
(
Vec_StrArray
(
vSop
)
);
int
nWords
=
Abc_Bit6WordNum
(
2
*
nVars
),
c
,
c1
,
c2
;
Vec_Bit_t
*
vMarks
=
Vec_BitStart
(
nCubes
);
if
(
fVerbose
)
printf
(
"Cover %5d : V =%5d C =%5d P =%9d "
,
iCover
,
nVars
,
nCubes
,
nCubes
*
nCubes
/
2
);
// check identical
for
(
c1
=
0
;
c1
<
nCubes
;
c1
++
)
if
(
!
Vec_BitEntry
(
vMarks
,
c1
)
)
for
(
c2
=
c1
+
1
;
c2
<
nCubes
;
c2
++
)
if
(
!
Vec_BitEntry
(
vMarks
,
c2
)
)
if
(
Abc_TtEqual
(
pCs
[
c1
],
pCs
[
c2
],
nWords
)
)
Vec_BitWriteEntry
(
vMarks
,
c2
,
1
);
// remove identical
for
(
c1
=
c
=
0
;
c1
<
nCubes
;
c1
++
)
if
(
!
Vec_BitEntry
(
vMarks
,
c1
)
)
{
if
(
nCubes
==
c1
)
c
++
;
else
Abc_TtCopy
(
pCs
[
c
++
],
pCs
[
c1
],
nWords
,
0
);
}
if
(
fVerbose
)
printf
(
" Equal =%5d"
,
nCubes
-
c
);
// check contained
nCubes
=
c
;
Vec_BitFill
(
vMarks
,
nCubes
,
0
);
for
(
c1
=
0
;
c1
<
nCubes
;
c1
++
)
if
(
!
Vec_BitEntry
(
vMarks
,
c1
)
)
for
(
c2
=
c1
+
1
;
c2
<
nCubes
;
c2
++
)
if
(
!
Vec_BitEntry
(
vMarks
,
c2
)
)
{
if
(
Abc_TtImply
(
pCs
[
c1
],
pCs
[
c2
],
nWords
)
)
Vec_BitWriteEntry
(
vMarks
,
c2
,
1
);
else
if
(
Abc_TtImply
(
pCs
[
c2
],
pCs
[
c1
],
nWords
)
)
{
Vec_BitWriteEntry
(
vMarks
,
c1
,
1
);
break
;
}
}
// remove contained
for
(
c1
=
c
=
0
;
c1
<
nCubes
;
c1
++
)
if
(
!
Vec_BitEntry
(
vMarks
,
c1
)
)
{
if
(
nCubes
==
c1
)
c
++
;
else
Abc_TtCopy
(
pCs
[
c
++
],
pCs
[
c1
],
nWords
,
0
);
}
if
(
fVerbose
)
printf
(
" Contain =%5d"
,
nCubes
-
c
);
nCubes
=
c
;
// check distance-1
// translate
Io_ReadPlaCubeSetdown
(
vSop
,
pCs
,
nCubes
,
nVars
);
// finalize
if
(
fVerbose
)
printf
(
"
\n
"
);
Vec_BitFree
(
vMarks
);
ABC_FREE
(
pCs
[
0
]
);
ABC_FREE
(
pCs
);
}
/**Function*************************************************************
/**Function*************************************************************
Synopsis [Reads the network from a PLA file.]
Synopsis [Reads the network from a PLA file.]
...
@@ -270,6 +393,7 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
...
@@ -270,6 +393,7 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
continue
;
continue
;
}
}
Vec_StrPush
(
ppSops
[
i
],
0
);
Vec_StrPush
(
ppSops
[
i
],
0
);
Io_ReadPlaCubePreprocess
(
ppSops
[
i
],
i
,
0
);
pNode
->
pData
=
Abc_SopRegister
(
(
Mem_Flex_t
*
)
pNtk
->
pManFunc
,
ppSops
[
i
]
->
pArray
);
pNode
->
pData
=
Abc_SopRegister
(
(
Mem_Flex_t
*
)
pNtk
->
pManFunc
,
ppSops
[
i
]
->
pArray
);
Vec_StrFree
(
ppSops
[
i
]
);
Vec_StrFree
(
ppSops
[
i
]
);
}
}
...
...
src/misc/util/abc_global.h
View file @
ff1fb175
...
@@ -254,6 +254,7 @@ static inline int Abc_Base10Log( unsigned n ) { int r; if ( n <
...
@@ -254,6 +254,7 @@ static inline int Abc_Base10Log( unsigned n ) { int r; if ( n <
static
inline
int
Abc_Base16Log
(
unsigned
n
)
{
int
r
;
if
(
n
<
2
)
return
n
;
for
(
r
=
0
,
n
--
;
n
;
n
/=
16
,
r
++
)
{};
return
r
;
}
static
inline
int
Abc_Base16Log
(
unsigned
n
)
{
int
r
;
if
(
n
<
2
)
return
n
;
for
(
r
=
0
,
n
--
;
n
;
n
/=
16
,
r
++
)
{};
return
r
;
}
static
inline
char
*
Abc_UtilStrsav
(
char
*
s
)
{
return
s
?
strcpy
(
ABC_ALLOC
(
char
,
strlen
(
s
)
+
1
),
s
)
:
NULL
;
}
static
inline
char
*
Abc_UtilStrsav
(
char
*
s
)
{
return
s
?
strcpy
(
ABC_ALLOC
(
char
,
strlen
(
s
)
+
1
),
s
)
:
NULL
;
}
static
inline
int
Abc_BitWordNum
(
int
nBits
)
{
return
(
nBits
>>
5
)
+
((
nBits
&
31
)
>
0
);
}
static
inline
int
Abc_BitWordNum
(
int
nBits
)
{
return
(
nBits
>>
5
)
+
((
nBits
&
31
)
>
0
);
}
static
inline
int
Abc_Bit6WordNum
(
int
nBits
)
{
return
(
nBits
>>
6
)
+
((
nBits
&
63
)
>
0
);
}
static
inline
int
Abc_TruthWordNum
(
int
nVars
)
{
return
nVars
<=
5
?
1
:
(
1
<<
(
nVars
-
5
));
}
static
inline
int
Abc_TruthWordNum
(
int
nVars
)
{
return
nVars
<=
5
?
1
:
(
1
<<
(
nVars
-
5
));
}
static
inline
int
Abc_Truth6WordNum
(
int
nVars
)
{
return
nVars
<=
6
?
1
:
(
1
<<
(
nVars
-
6
));
}
static
inline
int
Abc_Truth6WordNum
(
int
nVars
)
{
return
nVars
<=
6
?
1
:
(
1
<<
(
nVars
-
6
));
}
static
inline
int
Abc_InfoHasBit
(
unsigned
*
p
,
int
i
)
{
return
(
p
[(
i
)
>>
5
]
&
(
1
<<
((
i
)
&
31
)))
>
0
;
}
static
inline
int
Abc_InfoHasBit
(
unsigned
*
p
,
int
i
)
{
return
(
p
[(
i
)
>>
5
]
&
(
1
<<
((
i
)
&
31
)))
>
0
;
}
...
...
src/misc/util/utilTruth.h
View file @
ff1fb175
...
@@ -150,11 +150,21 @@ static inline int Abc_TtGetBit( word * p, int i ) { return (int)(p[i
...
@@ -150,11 +150,21 @@ static inline int Abc_TtGetBit( word * p, int i ) { return (int)(p[i
static
inline
void
Abc_TtSetBit
(
word
*
p
,
int
i
)
{
p
[
i
>>
6
]
|=
(((
word
)
1
)
<<
(
i
&
63
));
}
static
inline
void
Abc_TtSetBit
(
word
*
p
,
int
i
)
{
p
[
i
>>
6
]
|=
(((
word
)
1
)
<<
(
i
&
63
));
}
static
inline
void
Abc_TtXorBit
(
word
*
p
,
int
i
)
{
p
[
i
>>
6
]
^=
(((
word
)
1
)
<<
(
i
&
63
));
}
static
inline
void
Abc_TtXorBit
(
word
*
p
,
int
i
)
{
p
[
i
>>
6
]
^=
(((
word
)
1
)
<<
(
i
&
63
));
}
// read/write k-th digit d of a quaternary number:
static
inline
int
Abc_TtGetQua
(
word
*
p
,
int
k
)
{
return
(
int
)(
p
[
k
>>
5
]
>>
((
k
<<
1
)
&
63
))
&
3
;
}
static
inline
void
Abc_TtSetQua
(
word
*
p
,
int
k
,
int
d
)
{
p
[
k
>>
5
]
|=
(((
word
)
d
)
<<
((
k
<<
1
)
&
63
));
}
static
inline
void
Abc_TtXorQua
(
word
*
p
,
int
k
,
int
d
)
{
p
[
k
>>
5
]
^=
(((
word
)
d
)
<<
((
k
<<
1
)
&
63
));
}
// read/write k-th digit d of a hexadecimal number:
// read/write k-th digit d of a hexadecimal number:
static
inline
int
Abc_TtGetHex
(
word
*
p
,
int
k
)
{
return
(
int
)(
p
[
k
>>
4
]
>>
((
k
<<
2
)
&
63
))
&
15
;
}
static
inline
int
Abc_TtGetHex
(
word
*
p
,
int
k
)
{
return
(
int
)(
p
[
k
>>
4
]
>>
((
k
<<
2
)
&
63
))
&
15
;
}
static
inline
void
Abc_TtSetHex
(
word
*
p
,
int
k
,
int
d
)
{
p
[
k
>>
4
]
|=
(((
word
)
d
)
<<
((
k
<<
2
)
&
63
));
}
static
inline
void
Abc_TtSetHex
(
word
*
p
,
int
k
,
int
d
)
{
p
[
k
>>
4
]
|=
(((
word
)
d
)
<<
((
k
<<
2
)
&
63
));
}
static
inline
void
Abc_TtXorHex
(
word
*
p
,
int
k
,
int
d
)
{
p
[
k
>>
4
]
^=
(((
word
)
d
)
<<
((
k
<<
2
)
&
63
));
}
static
inline
void
Abc_TtXorHex
(
word
*
p
,
int
k
,
int
d
)
{
p
[
k
>>
4
]
^=
(((
word
)
d
)
<<
((
k
<<
2
)
&
63
));
}
// read/write k-th digit d of a 256-base number:
static
inline
int
Abc_TtGet256
(
word
*
p
,
int
k
)
{
return
(
int
)(
p
[
k
>>
3
]
>>
((
k
<<
3
)
&
63
))
&
255
;
}
static
inline
void
Abc_TtSet256
(
word
*
p
,
int
k
,
int
d
)
{
p
[
k
>>
3
]
|=
(((
word
)
d
)
<<
((
k
<<
3
)
&
63
));
}
static
inline
void
Abc_TtXor256
(
word
*
p
,
int
k
,
int
d
)
{
p
[
k
>>
3
]
^=
(((
word
)
d
)
<<
((
k
<<
3
)
&
63
));
}
/**Function*************************************************************
/**Function*************************************************************
Synopsis []
Synopsis []
...
@@ -274,6 +284,14 @@ static inline int Abc_TtEqual( word * pIn1, word * pIn2, int nWords )
...
@@ -274,6 +284,14 @@ static inline int Abc_TtEqual( word * pIn1, word * pIn2, int nWords )
return
0
;
return
0
;
return
1
;
return
1
;
}
}
static
inline
int
Abc_TtImply
(
word
*
pIn1
,
word
*
pIn2
,
int
nWords
)
{
int
w
;
for
(
w
=
0
;
w
<
nWords
;
w
++
)
if
(
(
pIn1
[
w
]
&
pIn2
[
w
])
!=
pIn1
[
w
]
)
return
0
;
return
1
;
}
static
inline
int
Abc_TtCompare
(
word
*
pIn1
,
word
*
pIn2
,
int
nWords
)
static
inline
int
Abc_TtCompare
(
word
*
pIn1
,
word
*
pIn2
,
int
nWords
)
{
{
int
w
;
int
w
;
...
...
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