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
f4c305fc
Commit
f4c305fc
authored
Feb 20, 2013
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding STG generation (&era -d) and STG encoding (&read_stg <file>).
parent
a82b0a8a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
18 deletions
+54
-18
src/aig/gia/giaStg.c
+54
-18
No files found.
src/aig/gia/giaStg.c
View file @
f4c305fc
...
@@ -43,10 +43,42 @@ ABC_NAMESPACE_IMPL_START
...
@@ -43,10 +43,42 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
int
Gia_ManCreateOrGate
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vLits
)
{
if
(
Vec_IntSize
(
vLits
)
==
0
)
return
0
;
while
(
Vec_IntSize
(
vLits
)
>
1
)
{
int
i
,
k
=
0
,
Lit1
,
Lit2
,
LitRes
;
Vec_IntForEachEntryDouble
(
vLits
,
Lit1
,
Lit2
,
i
)
{
LitRes
=
Gia_ManHashOr
(
p
,
Lit1
,
Lit2
);
Vec_IntWriteEntry
(
vLits
,
k
++
,
LitRes
);
}
if
(
Vec_IntSize
(
vLits
)
&
1
)
Vec_IntWriteEntry
(
vLits
,
k
++
,
Vec_IntEntryLast
(
vLits
)
);
Vec_IntShrink
(
vLits
,
k
);
}
assert
(
Vec_IntSize
(
vLits
)
==
1
);
return
Vec_IntEntry
(
vLits
,
0
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManStgOneHot
(
Vec_Int_t
*
vLines
,
int
nIns
,
int
nOuts
,
int
nStates
)
Gia_Man_t
*
Gia_ManStgOneHot
(
Vec_Int_t
*
vLines
,
int
nIns
,
int
nOuts
,
int
nStates
)
{
{
Gia_Man_t
*
p
;
Gia_Man_t
*
p
;
Vec_Int_t
*
vInMints
,
*
vCurs
,
*
vOuts
,
*
vNexts
;
Vec_Int_t
*
vInMints
,
*
vCurs
,
*
vVec
;
Vec_Vec_t
*
vLitsNext
,
*
vLitsOuts
;
int
i
,
b
,
LitC
,
Lit
;
int
i
,
b
,
LitC
,
Lit
;
assert
(
Vec_IntSize
(
vLines
)
%
4
==
0
);
assert
(
Vec_IntSize
(
vLines
)
%
4
==
0
);
...
@@ -71,11 +103,9 @@ Gia_Man_t * Gia_ManStgOneHot( Vec_Int_t * vLines, int nIns, int nOuts, int nStat
...
@@ -71,11 +103,9 @@ Gia_Man_t * Gia_ManStgOneHot( Vec_Int_t * vLines, int nIns, int nOuts, int nStat
for
(
i
=
0
;
i
<
nStates
;
i
++
)
for
(
i
=
0
;
i
<
nStates
;
i
++
)
Vec_IntPush
(
vCurs
,
Abc_Var2Lit
(
1
+
nIns
+
i
,
!
i
)
);
Vec_IntPush
(
vCurs
,
Abc_Var2Lit
(
1
+
nIns
+
i
,
!
i
)
);
// start outputs and current states
vOuts
=
Vec_IntStart
(
nOuts
);
vNexts
=
Vec_IntStart
(
nStates
);
// go through the lines
// go through the lines
vLitsNext
=
Vec_VecStart
(
nStates
);
vLitsOuts
=
Vec_VecStart
(
nOuts
);
for
(
i
=
0
;
i
<
Vec_IntSize
(
vLines
);
)
for
(
i
=
0
;
i
<
Vec_IntSize
(
vLines
);
)
{
{
int
iMint
=
Vec_IntEntry
(
vLines
,
i
++
);
int
iMint
=
Vec_IntEntry
(
vLines
,
i
++
);
...
@@ -89,33 +119,34 @@ Gia_Man_t * Gia_ManStgOneHot( Vec_Int_t * vLines, int nIns, int nOuts, int nStat
...
@@ -89,33 +119,34 @@ Gia_Man_t * Gia_ManStgOneHot( Vec_Int_t * vLines, int nIns, int nOuts, int nStat
// create condition
// create condition
LitC
=
Gia_ManHashAnd
(
p
,
Vec_IntEntry
(
vInMints
,
iMint
),
Vec_IntEntry
(
vCurs
,
iCur
)
);
LitC
=
Gia_ManHashAnd
(
p
,
Vec_IntEntry
(
vInMints
,
iMint
),
Vec_IntEntry
(
vCurs
,
iCur
)
);
// update next state
// update next state
Lit
=
Gia_ManHashOr
(
p
,
LitC
,
Vec_IntEntry
(
vNexts
,
iNext
)
);
// Lit = Gia_ManHashOr( p, LitC, Vec_IntEntry(vNexts, iNext) );
Vec_IntWriteEntry
(
vNexts
,
iNext
,
Lit
);
// Vec_IntWriteEntry( vNexts, iNext, Lit );
Vec_VecPushInt
(
vLitsNext
,
iNext
,
LitC
);
// update outputs
// update outputs
for
(
b
=
0
;
b
<
nOuts
;
b
++
)
for
(
b
=
0
;
b
<
nOuts
;
b
++
)
if
(
(
iOut
>>
b
)
&
1
)
if
(
(
iOut
>>
b
)
&
1
)
{
{
Lit
=
Gia_ManHashOr
(
p
,
LitC
,
Vec_IntEntry
(
vOuts
,
b
)
);
// Lit = Gia_ManHashOr( p, LitC, Vec_IntEntry(vOuts, b) );
Vec_IntWriteEntry
(
vOuts
,
b
,
Lit
);
// Vec_IntWriteEntry( vOuts, b, Lit );
Vec_VecPushInt
(
vLitsOuts
,
b
,
LitC
);
}
}
}
}
Vec_IntFree
(
vInMints
);
Vec_IntFree
(
vCurs
);
// create POs
// create POs
Vec_IntForEachEntry
(
vOuts
,
Lit
,
i
)
Vec_VecForEachLevelInt
(
vLitsOuts
,
vVec
,
i
)
Gia_ManAppendCo
(
p
,
Lit
);
Gia_ManAppendCo
(
p
,
Gia_ManCreateOrGate
(
p
,
vVec
)
);
Vec_VecFree
(
vLitsOuts
);
// create next states
// create next states
Vec_IntForEachEntry
(
vNexts
,
Lit
,
i
)
Vec_VecForEachLevelInt
(
vLitsNext
,
vVec
,
i
)
Gia_ManAppendCo
(
p
,
Abc_LitNotCond
(
Lit
,
!
i
)
);
Gia_ManAppendCo
(
p
,
Abc_LitNotCond
(
Gia_ManCreateOrGate
(
p
,
vVec
),
!
i
)
);
Vec_VecFree
(
vLitsNext
);
Gia_ManSetRegNum
(
p
,
nStates
);
Gia_ManSetRegNum
(
p
,
nStates
);
Gia_ManHashStop
(
p
);
Gia_ManHashStop
(
p
);
Vec_IntFree
(
vInMints
);
Vec_IntFree
(
vCurs
);
Vec_IntFree
(
vOuts
);
Vec_IntFree
(
vNexts
);
assert
(
!
Gia_ManHasDangling
(
p
)
);
assert
(
!
Gia_ManHasDangling
(
p
)
);
return
p
;
return
p
;
}
}
...
@@ -171,6 +202,11 @@ Vec_Int_t * Gia_ManStgReadLines( char * pFileName, int * pnIns, int * pnOuts, in
...
@@ -171,6 +202,11 @@ Vec_Int_t * Gia_ManStgReadLines( char * pFileName, int * pnIns, int * pnOuts, in
char
*
pToken
;
char
*
pToken
;
int
Number
,
nInputs
=
-
1
,
nOutputs
=
-
1
,
nStates
=
1
;
int
Number
,
nInputs
=
-
1
,
nOutputs
=
-
1
,
nStates
=
1
;
FILE
*
pFile
;
FILE
*
pFile
;
if
(
!
strcmp
(
pFileName
+
strlen
(
pFileName
)
-
3
,
"aig"
)
)
{
printf
(
"Input file
\"
%s
\"
has extension
\"
aig
\"
.
\n
"
,
pFileName
,
"aig"
);
return
NULL
;
}
pFile
=
fopen
(
pFileName
,
"rb"
);
pFile
=
fopen
(
pFileName
,
"rb"
);
if
(
pFile
==
NULL
)
if
(
pFile
==
NULL
)
{
{
...
...
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