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
11f1a249
Commit
11f1a249
authored
May 01, 2016
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating GIG parser.
parent
a0930910
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
386 additions
and
182 deletions
+386
-182
src/aig/gia/giaGig.c
+384
-180
src/base/io/io.c
+1
-1
src/bool/kit/kitHop.c
+1
-1
No files found.
src/aig/gia/giaGig.c
View file @
11f1a249
...
@@ -29,32 +29,63 @@ ABC_NAMESPACE_IMPL_START
...
@@ -29,32 +29,63 @@ ABC_NAMESPACE_IMPL_START
/// DECLARATIONS ///
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
#define MAX_LINE 1000000
// network types
enum
{
enum
{
GIG_NONE
=
0
,
GLS_NONE
=
-
1
,
// not used
GIG_RESET
=
1
,
GLS_ZERO
=
0
,
// zero
GIG_PI
=
2
,
GLS_ONE
=
1
,
// one
GIG_PO
=
3
,
GLS_PI
=
2
,
// primary input
GIG_SEQ
=
4
,
GLS_PO
=
3
,
// primary output
GIG_LUT
=
5
,
GLS_BAR
=
4
,
// barrier
GIG_DELAY
=
6
,
GLS_SEQ
=
5
,
// sequential
GIG_BOX
=
7
,
GLS_SEL
=
6
,
// fan
GIG_SEL
=
8
,
GLS_LUT4
=
7
,
// LUT4
GIG_BAR
=
9
,
GLS_LUT6
=
8
,
// LUT6
GIG_UNUSED
=
10
GLS_BOX
=
9
,
// sequential box
GLS_DEL
=
10
,
// delay box
GLS_FINAL
};
};
static
char
*
s_
GigNames
[
GIG_UNUSED
]
=
static
char
*
s_
Strs
[
GLS_FINAL
]
=
{
{
"NONE"
,
// GIG_NONE = 0
"0"
,
// GLS_ZERO = 0, // zero
"Reset"
,
// GIG_RESET = 1
"1"
,
// GLS_ONE = 1, // one
"PI"
,
// GIG_PI = 2
"PI"
,
// GLS_PI = 2, // primary input
"PO"
,
// GIG_PO = 3
"PO"
,
// GLS_PO = 3, // primary output
"Seq"
,
// GIG_SEQ = 4
"Bar"
,
// GLS_BAR = 4, // barrier
"Lut4"
,
// GIG_LUT = 5
"Seq"
,
// GLS_SEQ = 5, // sequential
"Delay"
,
// GIG_DELAY = 6
"Sel"
,
// GLS_SEL = 6, // fan
"Box"
,
// GIG_BOX = 7
"Lut4"
,
// GLS_LUT4 = 7, // LUT4
"Sel"
,
// GIG_SEL = 8
"Lut6"
,
// GLS_LUT6 = 8, // LUT6
"Bar"
// GIG_BAR = 9
"Box"
,
// GLS_BOX = 9, // sequential box
"Del"
// GLS_DEL = 10, // delay box
};
typedef
struct
Gls_Man_t_
Gls_Man_t
;
struct
Gls_Man_t_
{
// general
Vec_Str_t
*
vLines
;
// line types
Vec_Str_t
*
vTypes
;
// gate types
Vec_Int_t
*
vIndexes
;
// gate indexes
// specific types
Vec_Int_t
*
vLut4s
;
// 4-LUTs (4-tuples)
Vec_Int_t
*
vLut4TTs
;
// truth tables
Vec_Int_t
*
vLut6s
;
// 6-LUTs (6-tuples)
Vec_Wrd_t
*
vLut6TTs
;
// truth tables
Vec_Int_t
*
vBoxes
;
// boxes (5-tuples)
Vec_Wec_t
*
vDelayIns
;
// delay fanins
Vec_Wec_t
*
vDelayOuts
;
// delay fanouts
Vec_Int_t
*
vDelays
;
// delay values
// ordering
Vec_Int_t
*
vOrderPis
;
Vec_Int_t
*
vOrderPos
;
Vec_Int_t
*
vOrderBoxes
;
Vec_Int_t
*
vOrderDelays
;
Vec_Int_t
*
vOrderLuts
;
Vec_Int_t
*
vOrderSeqs
;
};
};
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
...
@@ -72,22 +103,50 @@ static char * s_GigNames[GIG_UNUSED] =
...
@@ -72,22 +103,50 @@ static char * s_GigNames[GIG_UNUSED] =
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
int
*
Gia_ManGigCount
(
Vec_Int_t
*
vObjs
,
Vec_Int_t
*
vStore
)
Gls_Man_t
*
Gls_ManAlloc
(
Vec_Str_t
*
vLines
,
int
*
pCounts
)
{
{
static
int
nObjs
[
GIG_UNUSED
];
int
i
;
Gls_Man_t
*
p
=
ABC_CALLOC
(
Gls_Man_t
,
1
);
for
(
i
=
0
;
i
<
GIG_UNUSED
;
i
++
)
p
->
vLines
=
vLines
;
nObjs
[
i
]
=
0
;
p
->
vTypes
=
Vec_StrStart
(
Vec_StrSize
(
vLines
)
+
100
);
for
(
i
=
0
;
i
<
Vec_IntSize
(
vObjs
);
i
++
)
p
->
vIndexes
=
Vec_IntStart
(
Vec_StrSize
(
vLines
)
+
100
);
nObjs
[
Vec_IntEntry
(
vStore
,
Vec_IntEntry
(
vObjs
,
i
)
+
1
)]
++
;
p
->
vLut4s
=
Vec_IntAlloc
(
4
*
pCounts
[
GLS_LUT4
]
);
return
nObjs
;
p
->
vLut4TTs
=
Vec_IntAlloc
(
pCounts
[
GLS_LUT4
]
);
p
->
vLut6s
=
Vec_IntAlloc
(
6
*
pCounts
[
GLS_LUT6
]
);
p
->
vLut6TTs
=
Vec_WrdAlloc
(
pCounts
[
GLS_LUT6
]
);
p
->
vBoxes
=
Vec_IntAlloc
(
5
*
pCounts
[
GLS_BOX
]
);
p
->
vDelays
=
Vec_IntAlloc
(
pCounts
[
GLS_DEL
]
);
p
->
vDelayIns
=
Vec_WecAlloc
(
pCounts
[
GLS_DEL
]
);
p
->
vDelayOuts
=
Vec_WecAlloc
(
pCounts
[
GLS_DEL
]
);
// ordering
p
->
vOrderPis
=
Vec_IntAlloc
(
pCounts
[
GLS_PI
]
);
p
->
vOrderPos
=
Vec_IntAlloc
(
pCounts
[
GLS_PO
]
);
p
->
vOrderBoxes
=
Vec_IntAlloc
(
pCounts
[
GLS_BOX
]
);
p
->
vOrderDelays
=
Vec_IntAlloc
(
pCounts
[
GLS_DEL
]
);
p
->
vOrderLuts
=
Vec_IntAlloc
(
pCounts
[
GLS_LUT4
]
+
pCounts
[
GLS_LUT6
]
+
2
*
pCounts
[
GLS_BAR
]
);
p
->
vOrderSeqs
=
Vec_IntAlloc
(
pCounts
[
GLS_SEQ
]
);
return
p
;
}
}
void
G
ia_ManGigPrint
(
int
*
nObjs
)
void
G
ls_ManStop
(
Gls_Man_t
*
p
)
{
{
int
i
;
Vec_StrFree
(
p
->
vLines
);
printf
(
"Statistics: "
);
Vec_StrFree
(
p
->
vTypes
);
for
(
i
=
1
;
i
<
GIG_UNUSED
;
i
++
)
Vec_IntFree
(
p
->
vIndexes
);
printf
(
"%s = %d "
,
s_GigNames
[
i
],
nObjs
[
i
]
);
Vec_IntFree
(
p
->
vLut4s
);
printf
(
"
\n
"
);
Vec_IntFree
(
p
->
vLut4TTs
);
Vec_IntFree
(
p
->
vLut6s
);
Vec_WrdFree
(
p
->
vLut6TTs
);
Vec_IntFree
(
p
->
vBoxes
);
Vec_IntFree
(
p
->
vDelays
);
Vec_WecFree
(
p
->
vDelayIns
);
Vec_WecFree
(
p
->
vDelayOuts
);
// ordering
Vec_IntFree
(
p
->
vOrderPis
);
Vec_IntFree
(
p
->
vOrderPos
);
Vec_IntFree
(
p
->
vOrderBoxes
);
Vec_IntFree
(
p
->
vOrderDelays
);
Vec_IntFree
(
p
->
vOrderLuts
);
Vec_IntFree
(
p
->
vOrderSeqs
);
ABC_FREE
(
p
);
}
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -101,27 +160,209 @@ void Gia_ManGigPrint( int * nObjs )
...
@@ -101,27 +160,209 @@ void Gia_ManGigPrint( int * nObjs )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
void
Gia_ManPrintDelays
(
Vec_Int_t
*
vObjs
,
Vec_Int_t
*
vStore
)
Vec_Str_t
*
Gls_ManCount
(
FILE
*
pFile
,
int
pCounts
[
GLS_FINAL
]
)
{
{
Vec_Int_t
*
vFanCount
=
Vec_IntStart
(
Vec_IntSize
(
vObjs
)
+
100
);
char
*
pLine
,
*
pBuffer
=
ABC_ALLOC
(
char
,
MAX_LINE
);
int
Type
;
int
i
,
*
pEntry
;
//, Counter = 0;
Vec_Str_t
*
vLines
=
Vec_StrAlloc
(
10000
);
for
(
i
=
0
;
i
<
Vec_IntSize
(
vObjs
);
i
++
)
memset
(
pCounts
,
0
,
sizeof
(
int
)
*
GLS_FINAL
);
while
(
fgets
(
pBuffer
,
MAX_LINE
,
pFile
)
!=
NULL
)
{
{
pEntry
=
Vec_IntEntryP
(
vStore
,
Vec_IntEntry
(
vObjs
,
i
)
);
pLine
=
pBuffer
;
if
(
pEntry
[
1
]
!=
GIG_SEL
)
while
(
*
pLine
)
continue
;
if
(
*
pLine
++
==
'='
)
assert
(
pEntry
[
2
]
==
1
);
break
;
Vec_IntAddToEntry
(
vFanCount
,
pEntry
[
3
],
1
);
while
(
*
pLine
==
' '
)
pLine
++
;
if
(
*
pLine
==
'L'
)
{
if
(
pLine
[
3
]
==
'4'
)
Type
=
GLS_LUT4
;
else
if
(
pLine
[
3
]
==
'6'
)
Type
=
GLS_LUT6
;
else
assert
(
0
);
}
else
if
(
*
pLine
==
'P'
)
{
if
(
pLine
[
1
]
==
'I'
)
Type
=
GLS_PI
;
else
if
(
pLine
[
1
]
==
'O'
)
Type
=
GLS_PO
;
else
assert
(
0
);
}
else
if
(
*
pLine
==
'B'
)
{
if
(
pLine
[
1
]
==
'o'
)
Type
=
GLS_BOX
;
else
if
(
pLine
[
1
]
==
'a'
)
Type
=
GLS_BAR
;
else
assert
(
0
);
}
else
if
(
*
pLine
==
'S'
)
{
if
(
pLine
[
2
]
==
'l'
)
Type
=
GLS_SEL
;
else
if
(
pLine
[
2
]
==
'q'
)
Type
=
GLS_SEQ
;
else
assert
(
0
);
}
else
if
(
*
pLine
==
'D'
)
Type
=
GLS_DEL
;
else
assert
(
0
);
Vec_StrPush
(
vLines
,
(
char
)
Type
);
pCounts
[
Type
]
++
;
}
}
for
(
i
=
0
;
i
<
Vec_IntSize
(
vObjs
);
i
++
)
ABC_FREE
(
pBuffer
);
return
vLines
;
}
int
Gls_ManParseOne
(
char
**
ppLine
)
{
int
Entry
;
char
*
pLine
=
*
ppLine
;
while
(
*
pLine
==
' '
)
pLine
++
;
if
(
*
pLine
==
'-'
)
Entry
=
GLS_NONE
;
else
if
(
*
pLine
==
'0'
)
Entry
=
0
;
else
if
(
*
pLine
==
'1'
)
Entry
=
1
;
else
if
(
*
pLine
==
'w'
)
Entry
=
atoi
(
++
pLine
);
else
assert
(
0
);
while
(
*
pLine
==
'-'
||
(
*
pLine
>=
'0'
&&
*
pLine
<=
'9'
)
)
pLine
++
;
while
(
*
pLine
==
' '
)
pLine
++
;
*
ppLine
=
pLine
;
return
Entry
;
}
int
Gls_ManParse
(
FILE
*
pFile
,
Gls_Man_t
*
p
)
{
char
*
pLine
,
*
pBuffer
=
ABC_ALLOC
(
char
,
MAX_LINE
);
int
i
,
k
,
Type
,
iObj
,
Entry
,
iItem
;
word
Truth
;
for
(
i
=
0
;
fgets
(
pBuffer
,
MAX_LINE
,
pFile
)
!=
NULL
;
i
++
)
{
{
pEntry
=
Vec_IntEntryP
(
vStore
,
Vec_IntEntry
(
vObjs
,
i
)
);
pLine
=
pBuffer
;
if
(
pEntry
[
1
]
!=
GIG_DELAY
)
Type
=
Vec_StrEntry
(
p
->
vLines
,
i
);
iObj
=
Gls_ManParseOne
(
&
pLine
);
Vec_StrWriteEntry
(
p
->
vTypes
,
iObj
,
(
char
)
Type
);
if
(
Type
==
GLS_PI
)
{
Vec_IntPush
(
p
->
vOrderPis
,
iObj
);
Vec_IntWriteEntry
(
p
->
vIndexes
,
iObj
,
-
1
);
continue
;
}
while
(
*
pLine
)
if
(
*
pLine
++
==
'('
)
break
;
Entry
=
Gls_ManParseOne
(
&
pLine
);
if
(
Type
==
GLS_PO
||
Type
==
GLS_BAR
||
Type
==
GLS_SEQ
||
Type
==
GLS_SEL
)
{
if
(
Type
==
GLS_PO
)
Vec_IntPush
(
p
->
vOrderPos
,
iObj
);
else
if
(
Type
==
GLS_BAR
)
Vec_IntPush
(
p
->
vOrderLuts
,
iObj
);
else
if
(
Type
==
GLS_SEQ
)
Vec_IntPush
(
p
->
vOrderSeqs
,
iObj
);
else
if
(
Type
==
GLS_SEL
)
{
if
(
(
int
)
Vec_StrEntry
(
p
->
vTypes
,
Entry
)
==
GLS_DEL
)
{
Vec_Int_t
*
vOuts
=
Vec_WecEntry
(
p
->
vDelayOuts
,
Vec_IntEntry
(
p
->
vIndexes
,
Entry
)
);
Vec_IntPush
(
vOuts
,
iObj
);
}
else
if
(
(
int
)
Vec_StrEntry
(
p
->
vTypes
,
Entry
)
==
GLS_BAR
)
Vec_IntPush
(
p
->
vOrderLuts
,
iObj
);
else
assert
(
0
);
}
Vec_IntWriteEntry
(
p
->
vIndexes
,
iObj
,
Entry
);
continue
;
continue
;
printf
(
"(%d,%d,%d) "
,
pEntry
[
2
],
Vec_IntEntry
(
vFanCount
,
pEntry
[
0
]),
pEntry
[
3
+
pEntry
[
2
]]
);
}
if
(
Type
==
GLS_LUT4
)
{
Vec_IntWriteEntry
(
p
->
vIndexes
,
iObj
,
Vec_IntSize
(
p
->
vLut4TTs
)
);
Vec_IntPush
(
p
->
vLut4s
,
Entry
);
for
(
k
=
1
;
;
k
++
)
{
if
(
*
pLine
!=
','
)
break
;
pLine
++
;
Entry
=
Gls_ManParseOne
(
&
pLine
);
Vec_IntPush
(
p
->
vLut4s
,
Entry
);
}
assert
(
*
pLine
==
')'
);
assert
(
k
==
4
);
pLine
++
;
while
(
*
pLine
)
if
(
*
pLine
++
==
'['
)
break
;
Abc_TtReadHex
(
&
Truth
,
pLine
);
Vec_IntPush
(
p
->
vLut4TTs
,
(
unsigned
)
Truth
);
Vec_IntPush
(
p
->
vOrderLuts
,
iObj
);
}
else
if
(
Type
==
GLS_LUT6
)
{
Vec_IntWriteEntry
(
p
->
vIndexes
,
iObj
,
Vec_WrdSize
(
p
->
vLut6TTs
)
);
Vec_IntPush
(
p
->
vLut6s
,
Entry
);
for
(
k
=
1
;
;
k
++
)
{
if
(
*
pLine
!=
','
)
break
;
pLine
++
;
Entry
=
Gls_ManParseOne
(
&
pLine
);
Vec_IntPush
(
p
->
vLut6s
,
Entry
);
}
assert
(
*
pLine
==
')'
);
assert
(
k
==
4
);
pLine
++
;
while
(
*
pLine
)
if
(
*
pLine
++
==
'['
)
break
;
Abc_TtReadHex
(
&
Truth
,
pLine
);
Vec_WrdPush
(
p
->
vLut6TTs
,
Truth
);
Vec_IntPush
(
p
->
vOrderLuts
,
iObj
);
}
else
if
(
Type
==
GLS_BOX
)
{
Vec_IntWriteEntry
(
p
->
vIndexes
,
iObj
,
Vec_IntSize
(
p
->
vBoxes
)
/
5
);
Vec_IntPush
(
p
->
vBoxes
,
Entry
);
for
(
k
=
1
;
;
k
++
)
{
if
(
*
pLine
!=
','
)
break
;
pLine
++
;
Entry
=
Gls_ManParseOne
(
&
pLine
);
Vec_IntPush
(
p
->
vBoxes
,
Entry
);
}
assert
(
*
pLine
==
')'
);
assert
(
k
==
4
||
k
==
5
);
if
(
k
==
4
)
Vec_IntPush
(
p
->
vBoxes
,
GLS_NONE
);
Vec_IntPush
(
p
->
vOrderBoxes
,
iObj
);
}
else
if
(
Type
==
GLS_DEL
)
{
Vec_Int_t
*
vIns
=
Vec_WecPushLevel
(
p
->
vDelayIns
);
Vec_Int_t
*
vOuts
=
Vec_WecPushLevel
(
p
->
vDelayOuts
);
Vec_IntWriteEntry
(
p
->
vIndexes
,
iObj
,
Vec_IntSize
(
p
->
vDelays
)
);
Vec_IntPush
(
vIns
,
Entry
);
if
(
*
pLine
!=
')'
)
{
for
(
k
=
1
;
;
k
++
)
{
if
(
*
pLine
!=
','
)
break
;
pLine
++
;
Entry
=
Gls_ManParseOne
(
&
pLine
);
Vec_IntPush
(
vIns
,
Entry
);
}
}
assert
(
*
pLine
==
')'
);
pLine
++
;
while
(
*
pLine
)
if
(
*
pLine
++
==
'['
)
break
;
iItem
=
atoi
(
pLine
);
Vec_IntPush
(
p
->
vDelays
,
iItem
);
Vec_IntPush
(
p
->
vOrderDelays
,
iObj
);
}
else
assert
(
0
);
}
}
printf
(
"
\n
"
);
ABC_FREE
(
pBuffer
);
Vec_IntFree
(
vFanCount
)
;
return
1
;
}
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -135,59 +376,83 @@ void Gia_ManPrintDelays( Vec_Int_t * vObjs, Vec_Int_t * vStore )
...
@@ -135,59 +376,83 @@ void Gia_ManPrintDelays( Vec_Int_t * vObjs, Vec_Int_t * vStore )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
Gia_Man_t
*
G
ia_ManBuildGig2
(
Vec_Int_t
*
vObjs
,
Vec_Int_t
*
vStore
,
char
*
pFileName
)
Gia_Man_t
*
G
ls_ManConstruct
(
Gls_Man_t
*
p
,
char
*
pFileName
)
{
{
Gia_Man_t
*
pNew
,
*
pTemp
;
extern
int
Kit_TruthToGia
(
Gia_Man_t
*
pMan
,
unsigned
*
pTruth
,
int
nVars
,
Vec_Int_t
*
vMemory
,
Vec_Int_t
*
vLeaves
,
int
fHash
);
//int * nObjs = Gia_ManGigCount( vObjs, vStore );
Gia_Man_t
*
pGia
=
NULL
;
Vec_Int_t
*
vNets
=
Vec_IntAlloc
(
Vec_IntSize
(
vObjs
)
);
Vec_Int_t
*
vMap
,
*
vArray
;
Vec_Int_t
*
vTypes
=
Vec_IntAlloc
(
Vec_IntSize
(
vObjs
)
);
Vec_Int_t
*
vCover
=
Vec_IntAlloc
(
0
);
Vec_Int_t
*
vMap
;
Vec_Int_t
*
vLeaves
=
Vec_IntAlloc
(
6
);
int
i
,
Type
;
int
k
,
iObj
,
iLit
,
Index
;
char
Type
;
// connect net IDs
// create new manager
for
(
i
=
0
;
i
<
Vec_IntSize
(
vObjs
);
i
++
)
pGia
=
Gia_ManStart
(
Vec_StrSize
(
p
->
vTypes
)
);
{
pGia
->
pName
=
Abc_UtilStrsav
(
pFileName
);
Vec_IntPush
(
vNets
,
Vec_IntEntry
(
vStore
,
Vec_IntEntry
(
vObjs
,
i
))
);
pGia
->
pSpec
=
Abc_UtilStrsav
(
pFileName
);
Vec_IntPush
(
vTypes
,
Vec_IntEntry
(
vStore
,
Vec_IntEntry
(
vObjs
,
i
)
+
1
)
);
// create constants
}
vMap
=
Vec_IntStartFull
(
Vec_StrSize
(
p
->
vTypes
)
);
// create mapping for net IDs into GIA IDs
vMap
=
Vec_IntStartFull
(
Vec_IntFindMax
(
vNets
)
+
1
);
Vec_IntWriteEntry
(
vMap
,
0
,
0
);
Vec_IntWriteEntry
(
vMap
,
0
,
0
);
Vec_IntWriteEntry
(
vMap
,
1
,
1
);
Vec_IntWriteEntry
(
vMap
,
1
,
1
);
// create new manager
pNew
=
Gia_ManStart
(
Vec_IntSize
(
vObjs
)
);
pNew
->
pName
=
Abc_UtilStrsav
(
pFileName
);
pNew
->
pSpec
=
Abc_UtilStrsav
(
pFileName
);
// create primary inputs
// create primary inputs
for
(
i
=
0
;
i
<
Vec_IntSize
(
vObjs
);
i
++
)
Vec_IntForEachEntry
(
p
->
vOrderPis
,
iObj
,
k
)
if
(
Vec_IntEntry
(
vTypes
,
i
)
==
GIG_PI
)
Vec_IntWriteEntry
(
vMap
,
iObj
,
Gia_ManAppendCi
(
pGia
)
);
Vec_IntWriteEntry
(
vMap
,
Vec_IntEntry
(
vNets
,
i
),
Gia_ManAppendCi
(
pNew
)
);
// create box outputs
// create box outputs
for
(
i
=
0
;
i
<
Vec_IntSize
(
vObjs
);
i
++
)
Vec_IntForEachEntry
(
p
->
vOrderBoxes
,
iObj
,
k
)
if
(
Vec_IntEntry
(
vTypes
,
i
)
==
GIG_BOX
)
Vec_IntWriteEntry
(
vMap
,
iObj
,
Gia_ManAppendCi
(
pGia
)
);
Vec_IntWriteEntry
(
vMap
,
Vec_IntEntry
(
vNets
,
i
),
Gia_ManAppendCi
(
pNew
)
);
// create delay outputs
// create internal nodes
Vec_IntForEachEntry
(
p
->
vOrderDelays
,
iObj
,
Index
)
Gia_ManHashAlloc
(
pNew
);
for
(
i
=
0
;
i
<
Vec_IntSize
(
vObjs
);
i
++
)
{
{
Type
=
Vec_IntEntry
(
vTypes
,
i
);
assert
(
Index
==
Vec_IntEntry
(
p
->
vIndexes
,
iObj
)
);
if
(
Type
!=
GIG_LUT
&&
Type
!=
GIG_DELAY
&&
Type
!=
GIG_BAR
)
vArray
=
Vec_WecEntry
(
p
->
vDelayOuts
,
Index
);
continue
;
if
(
Vec_IntSize
(
vArray
)
==
0
)
Vec_IntWriteEntry
(
vMap
,
iObj
,
Gia_ManAppendCi
(
pGia
)
);
else
Vec_IntForEachEntry
(
vArray
,
iObj
,
k
)
Vec_IntWriteEntry
(
vMap
,
iObj
,
Gia_ManAppendCi
(
pGia
)
);
}
// construct LUTs
Vec_IntForEachEntry
(
p
->
vOrderLuts
,
iObj
,
Index
)
{
Type
=
Vec_StrEntry
(
p
->
vTypes
,
iObj
);
if
(
Type
==
GLS_LUT4
||
Type
==
GLS_LUT6
)
{
int
Limit
=
Type
==
GLS_LUT4
?
4
:
6
;
int
Index
=
Vec_IntEntry
(
p
->
vIndexes
,
iObj
);
int
*
pFanins
=
Type
==
GLS_LUT4
?
Vec_IntEntryP
(
p
->
vLut4s
,
4
*
Index
)
:
Vec_IntEntryP
(
p
->
vLut6s
,
6
*
Index
);
word
Truth
=
Type
==
GLS_LUT4
?
(
word
)
Vec_IntEntry
(
p
->
vLut4TTs
,
Index
)
:
Vec_WrdEntry
(
p
->
vLut6TTs
,
Index
);
Vec_IntClear
(
vLeaves
);
for
(
k
=
0
;
k
<
Limit
;
k
++
)
Vec_IntPush
(
vLeaves
,
pFanins
[
k
]
==
GLS_NONE
?
0
:
Vec_IntEntry
(
vMap
,
pFanins
[
k
])
);
iLit
=
Kit_TruthToGia
(
pGia
,
(
unsigned
*
)
&
Truth
,
Vec_IntSize
(
vLeaves
),
vCover
,
vLeaves
,
0
);
Vec_IntWriteEntry
(
vMap
,
iObj
,
iLit
);
}
else
if
(
Type
==
GLS_BAR
||
Type
==
GLS_SEL
)
{
iLit
=
Vec_IntEntry
(
vMap
,
Vec_IntEntry
(
p
->
vIndexes
,
iObj
)
);
Vec_IntWriteEntry
(
vMap
,
iObj
,
iLit
);
}
}
// delay inputs
Vec_IntForEachEntry
(
p
->
vOrderDelays
,
iObj
,
Index
)
{
vArray
=
Vec_WecEntry
(
p
->
vDelayIns
,
Index
);
assert
(
Vec_IntSize
(
vArray
)
>
0
);
Vec_IntForEachEntry
(
vArray
,
iObj
,
k
)
Gia_ManAppendCo
(
pGia
,
Vec_IntEntry
(
vMap
,
iObj
)
);
}
}
// create primary outputs
Vec_IntForEachEntry
(
p
->
vOrderPos
,
iObj
,
k
)
Gia_ManAppendCo
(
pGia
,
Vec_IntEntry
(
vMap
,
Vec_IntEntry
(
p
->
vIndexes
,
iObj
))
);
// create sequential nodes
Vec_IntForEachEntry
(
p
->
vOrderSeqs
,
iObj
,
k
)
Gia_ManAppendCo
(
pGia
,
Vec_IntEntry
(
vMap
,
Vec_IntEntry
(
p
->
vIndexes
,
iObj
))
);
Vec_IntFree
(
vMap
);
Vec_IntFree
(
vMap
);
Vec_IntFree
(
vNets
);
Vec_IntFree
(
vCover
);
Vec_IntFree
(
vTypes
);
Vec_IntFree
(
vLeaves
);
// rehash
// print delay boxes
pNew
=
Gia_ManCleanup
(
pTemp
=
pNew
);
// for ( k = 0; k < Vec_IntSize(p->vDelays); k++ )
Gia_ManStop
(
pTemp
);
// printf( "%d:%d ", Vec_IntSize(Vec_WecEntry(p->vDelayIns, k)), Vec_IntSize(Vec_WecEntry(p->vDelayOuts, k)) );
return
pNew
;
// printf( "\n" );
}
return
pGia
;
Gia_Man_t
*
Gia_ManBuildGig
(
Vec_Int_t
*
vObjs
,
Vec_Int_t
*
vStore
,
char
*
pFileName
)
{
printf
(
"Parsed %d objects and %d tokens.
\n
"
,
Vec_IntSize
(
vObjs
),
Vec_IntSize
(
vStore
)
);
Gia_ManGigPrint
(
Gia_ManGigCount
(
vObjs
,
vStore
)
);
Gia_ManPrintDelays
(
vObjs
,
vStore
);
return
NULL
;
}
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -203,93 +468,32 @@ Gia_Man_t * Gia_ManBuildGig( Vec_Int_t * vObjs, Vec_Int_t * vStore, char * pFile
...
@@ -203,93 +468,32 @@ Gia_Man_t * Gia_ManBuildGig( Vec_Int_t * vObjs, Vec_Int_t * vStore, char * pFile
***********************************************************************/
***********************************************************************/
Gia_Man_t
*
Gia_ManReadGig
(
char
*
pFileName
)
Gia_Man_t
*
Gia_ManReadGig
(
char
*
pFileName
)
{
{
Gia_Man_t
*
pNew
;
abctime
clk
=
Abc_Clock
();
int
Type
,
Offset
,
fEndOfLine
,
Digit
,
nObjs
;
Gls_Man_t
*
p
=
NULL
;
char
*
pChars
=
" w(-,)]
\r\t
"
;
Gia_Man_t
*
pGia
=
NULL
;
char
*
pBuffer
=
Extra_FileReadContents
(
pFileName
);
Vec_Str_t
*
vLines
;
char
*
pStart
=
pBuffer
,
*
pToken
;
int
i
,
pCounts
[
GLS_FINAL
];
Vec_Int_t
*
vObjs
,
*
vStore
;
FILE
*
pFile
=
fopen
(
pFileName
,
"rb"
);
if
(
pBuffer
==
NULL
)
if
(
pFile
==
NULL
)
printf
(
"Cannot open input file %s
\n
"
,
pFileName
);
// count objects
for
(
nObjs
=
0
,
pToken
=
pBuffer
;
*
pToken
;
pToken
++
)
nObjs
+=
(
int
)(
*
pToken
==
'\n'
);
// read objects
vObjs
=
Vec_IntAlloc
(
nObjs
);
vStore
=
Vec_IntAlloc
(
10
*
nObjs
);
while
(
1
)
{
{
// read net ID
printf
(
"Cannot read file
\"
%s
\"
.
\n
"
,
pFileName
);
pToken
=
strtok
(
pStart
,
pChars
);
return
NULL
;
pStart
=
NULL
;
if
(
pToken
==
NULL
)
break
;
// start new object
Vec_IntPush
(
vObjs
,
Vec_IntSize
(
vStore
)
);
// save net ID
assert
(
pToken
[
0
]
>=
'0'
&&
pToken
[
0
]
<=
'9'
);
Vec_IntPush
(
vStore
,
atoi
(
pToken
)
);
// read equal
pToken
=
strtok
(
pStart
,
pChars
);
assert
(
pToken
[
0
]
==
'='
);
// read type
pToken
=
strtok
(
pStart
,
pChars
);
fEndOfLine
=
0
;
if
(
pToken
[
strlen
(
pToken
)
-
1
]
==
'\n'
)
{
pToken
[
strlen
(
pToken
)
-
1
]
=
0
;
fEndOfLine
=
1
;
}
for
(
Type
=
GIG_RESET
;
Type
<
GIG_UNUSED
;
Type
++
)
if
(
!
strcmp
(
pToken
,
s_GigNames
[
Type
])
)
break
;
assert
(
Type
<
GIG_UNUSED
);
Vec_IntPush
(
vStore
,
Type
);
if
(
fEndOfLine
)
continue
;
// read fanins
Offset
=
Vec_IntSize
(
vStore
);
Vec_IntPush
(
vStore
,
0
);
while
(
1
)
{
pToken
=
strtok
(
pStart
,
pChars
);
if
(
pToken
==
NULL
||
pToken
[
0
]
==
'\n'
||
pToken
[
0
]
==
'['
)
break
;
assert
(
pToken
[
0
]
>=
'0'
&&
pToken
[
0
]
<=
'9'
);
Vec_IntPush
(
vStore
,
atoi
(
pToken
)
);
Vec_IntAddToEntry
(
vStore
,
Offset
,
1
);
}
assert
(
pToken
!=
NULL
);
if
(
pToken
[
0
]
==
'\n'
)
continue
;
assert
(
pToken
[
0
]
==
'['
);
// read attribute
pToken
++
;
if
(
Type
==
GIG_LUT
)
{
assert
(
strlen
(
pToken
)
==
4
);
Digit
=
Abc_TtReadHexDigit
(
pToken
[
0
]);
Digit
|=
Abc_TtReadHexDigit
(
pToken
[
1
])
<<
4
;
Digit
|=
Abc_TtReadHexDigit
(
pToken
[
2
])
<<
8
;
Digit
|=
Abc_TtReadHexDigit
(
pToken
[
3
])
<<
12
;
Vec_IntPush
(
vStore
,
Digit
);
}
else
{
assert
(
Type
==
GIG_DELAY
);
Vec_IntPush
(
vStore
,
atoi
(
pToken
)
);
}
// read end of line
pToken
=
strtok
(
pStart
,
pChars
);
assert
(
pToken
[
0
]
==
'\n'
);
}
}
ABC_FREE
(
pBuffer
);
vLines
=
Gls_ManCount
(
pFile
,
pCounts
);
// create AIG
rewind
(
pFile
);
pNew
=
Gia_ManBuildGig
(
vObjs
,
vStore
,
pFileName
);
// statistics
// cleanup
for
(
i
=
0
;
i
<
GLS_FINAL
;
i
++
)
Vec_IntFree
(
vObjs
);
if
(
pCounts
[
i
]
)
Vec_IntFree
(
vStore
);
printf
(
"%s=%d "
,
s_Strs
[
i
],
pCounts
[
i
]
);
return
pNew
;
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
// collect data and derive AIG
p
=
Gls_ManAlloc
(
vLines
,
pCounts
);
if
(
Gls_ManParse
(
pFile
,
p
)
)
pGia
=
Gls_ManConstruct
(
p
,
pFileName
);
Gls_ManStop
(
p
);
fclose
(
pFile
);
//printf( "\n" );
return
pGia
;
}
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
...
...
src/base/io/io.c
View file @
11f1a249
...
@@ -1205,7 +1205,7 @@ int IoCommandReadGig( Abc_Frame_t * pAbc, int argc, char ** argv )
...
@@ -1205,7 +1205,7 @@ int IoCommandReadGig( Abc_Frame_t * pAbc, int argc, char ** argv )
// set the new network
// set the new network
pAig
=
Gia_ManReadGig
(
pFileName
);
pAig
=
Gia_ManReadGig
(
pFileName
);
//
Abc_FrameUpdateGia( pAbc, pAig );
Abc_FrameUpdateGia
(
pAbc
,
pAig
);
return
0
;
return
0
;
usage:
usage:
...
...
src/bool/kit/kitHop.c
View file @
11f1a249
...
@@ -62,7 +62,7 @@ int Kit_GraphToGiaInternal( Gia_Man_t * pMan, Kit_Graph_t * pGraph, int fHash )
...
@@ -62,7 +62,7 @@ int Kit_GraphToGiaInternal( Gia_Man_t * pMan, Kit_Graph_t * pGraph, int fHash )
if
(
fHash
)
if
(
fHash
)
pNode
->
iFunc
=
Gia_ManHashAnd
(
pMan
,
pAnd0
,
pAnd1
);
pNode
->
iFunc
=
Gia_ManHashAnd
(
pMan
,
pAnd0
,
pAnd1
);
else
else
pNode
->
iFunc
=
Gia_ManAppendAnd
(
pMan
,
pAnd0
,
pAnd1
);
pNode
->
iFunc
=
Gia_ManAppendAnd
2
(
pMan
,
pAnd0
,
pAnd1
);
}
}
// complement the result if necessary
// complement the result if necessary
return
Abc_LitNotCond
(
pNode
->
iFunc
,
Kit_GraphIsComplement
(
pGraph
)
);
return
Abc_LitNotCond
(
pNode
->
iFunc
,
Kit_GraphIsComplement
(
pGraph
)
);
...
...
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