ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioWriteList.c
Go to the documentation of this file.
1
20
21#include "ioAbc.h"
22
24
25
26/*
27-------- Original Message --------
28Subject: Re: abc release and retiming
29Date: Sun, 13 Nov 2005 20:31:18 -0500 (EST)
30From: Luca Carloni <luca@cs.columbia.edu>
31To: Alan Mishchenko <alanmi@eecs.berkeley.edu>
32
33Alan,
34
35My graph-representation file format is based on an adjacency list
36representation and is indeed quite simple, in fact maybe too simple... I
37used it in order to reason on relatively small weighed direct graphs. I
38simply list all vertices, one per line and for each vertex "V_source" I
39list all vertices that are "sinks" with respect to it, i.e. such that
40there is a distinct arc between "V_source" and each of them (in
41parenthesis I list the name of the edge and its weight (number of latency
42on that path). For instance, if you look at the following graph, you have
43that vertex "v_5" is connected to vertex "v_6" through a directed arc
44called "v_5_to_v_6" whose latency is equal to 3, i.e. there are three
45flip-flops on this arc. Still, notice that I sometime interpret the graph
46also as the representation of a LIS where each node corresponds to a
47shell encapsulating a sequential core module (i.e. a module which does not
48contain any combinational path between its inputs and its outputs). With
49this representation an arc of latency 3 is interpreted as a wire where two
50relay stations have been inserted in addition to the flip-flop terminating
51the output of the core module.
52
53Finally, notice that the name of the arc does not necessarily have to be
54"v_5_to_v_6", but it could have been something like "arc_222" or "xyz" as
55long as it is a unique name in the graph.
56
57Thanks,
58Luca
59
60Example of graph representation
61-----------------------------------------------------------------------------
62v_5 > v_6 ([v_5_to_v_6] = 3), v_12 ([v_5_to_v_12] = 2).
63v_2 > v_4 ([v_2_to_v_4] = 1), v_10_s0 ([v_2_to_v_10_s0] = 6), v_12 ([v_2_to_v_12] = 3).
64v_9 > v_10_s0 ([v_9_to_v_10_s0] = 5), v_12 ([v_9_to_v_12] = 2).
65v_12 > v_13 ([v_12_to_v_13] = 5).
66v_13 > v_14 ([v_13_to_v_14] = 1).
67v_6 > v_7 ([v_6_to_v_7] = 2).
68v_4 > v_5 ([v_4_to_v_5] = 2).
69v_1 > v_2 ([v_1_to_v_2] = 1).
70v_7 > v_8 ([v_7_to_v_8] = 2).
71t > .
72v_14 > t ([v_14_to_t] = 1), v_5 ([v_14_to_v_5] = 1).
73v_8 > v_9 ([v_8_to_v_9] = 2).
74s > v_1 ([s_to_v_1] = 1).
75v_10_s0 > v_10_s1 ([v_10_s0_to_v_10_s1] = 1).
76v_10_s1 > v_4 ([v_10_s1__v_4] = 1), v_8 ([v_10_s1__v_8] = 1).
77-----------------------------------------------------------------------------
78*/
79
83
84static void Io_WriteListEdge( FILE * pFile, Abc_Obj_t * pObj );
85static void Io_WriteListHost( FILE * pFile, Abc_Ntk_t * pNtk );
86
90
102void Io_WriteList( Abc_Ntk_t * pNtk, char * pFileName, int fUseHost )
103{
104 FILE * pFile;
105 Abc_Obj_t * pObj;
106 int i;
107
108// assert( Abc_NtkIsSeq(pNtk) );
109
110 // start the output stream
111 pFile = fopen( pFileName, "w" );
112 if ( pFile == NULL )
113 {
114 fprintf( stdout, "Io_WriteList(): Cannot open the output file \"%s\".\n", pFileName );
115 return;
116 }
117
118 fprintf( pFile, "# Adjacency list for sequential AIG \"%s\"\n", pNtk->pName );
119 fprintf( pFile, "# written by ABC on %s\n", Extra_TimeStamp() );
120
121 // write the constant node
122 if ( Abc_ObjFanoutNum( Abc_AigConst1(pNtk) ) > 0 )
123 Io_WriteListEdge( pFile, Abc_AigConst1(pNtk) );
124
125 // write the PI edges
126 Abc_NtkForEachPi( pNtk, pObj, i )
127 Io_WriteListEdge( pFile, pObj );
128
129 // write the internal nodes
130 Abc_AigForEachAnd( pNtk, pObj, i )
131 Io_WriteListEdge( pFile, pObj );
132
133 // write the host node
134 if ( fUseHost )
135 Io_WriteListHost( pFile, pNtk );
136 else
137 Abc_NtkForEachPo( pNtk, pObj, i )
138 Io_WriteListEdge( pFile, pObj );
139
140 fprintf( pFile, "\n" );
141 fclose( pFile );
142}
143
155void Io_WriteListEdge( FILE * pFile, Abc_Obj_t * pObj )
156{
157 Abc_Obj_t * pFanout;
158 int i;
159 fprintf( pFile, "%-10s > ", Abc_ObjName(pObj) );
160 Abc_ObjForEachFanout( pObj, pFanout, i )
161 {
162 fprintf( pFile, " %s", Abc_ObjName(pFanout) );
163 fprintf( pFile, " ([%s_to_", Abc_ObjName(pObj) );
164// fprintf( pFile, "%s] = %d)", Abc_ObjName(pFanout), Seq_ObjFanoutL(pObj, pFanout) );
165 fprintf( pFile, "%s] = %d)", Abc_ObjName(pFanout), 0 );
166 if ( i != Abc_ObjFanoutNum(pObj) - 1 )
167 fprintf( pFile, "," );
168 }
169 fprintf( pFile, "." );
170 fprintf( pFile, "\n" );
171}
172
184void Io_WriteListHost( FILE * pFile, Abc_Ntk_t * pNtk )
185{
186 Abc_Obj_t * pObj;
187 int i;
188
189 Abc_NtkForEachPo( pNtk, pObj, i )
190 {
191 fprintf( pFile, "%-10s > ", Abc_ObjName(pObj) );
192 fprintf( pFile, " %s ([%s_to_%s] = %d)", "HOST", Abc_ObjName(pObj), "HOST", 0 );
193 fprintf( pFile, "." );
194 fprintf( pFile, "\n" );
195 }
196
197 fprintf( pFile, "%-10s > ", "HOST" );
198 Abc_NtkForEachPi( pNtk, pObj, i )
199 {
200 fprintf( pFile, " %s", Abc_ObjName(pObj) );
201 fprintf( pFile, " ([%s_to_%s] = %d)", "HOST", Abc_ObjName(pObj), 0 );
202 if ( i != Abc_NtkPiNum(pNtk) - 1 )
203 fprintf( pFile, "," );
204 }
205 fprintf( pFile, "." );
206 fprintf( pFile, "\n" );
207}
208
209
221void Io_WriteCellNet( Abc_Ntk_t * pNtk, char * pFileName )
222{
223 FILE * pFile;
224 Abc_Obj_t * pObj, * pFanout;
225 int i, k;
226
227 assert( Abc_NtkIsLogic(pNtk) );
228
229 // start the output stream
230 pFile = fopen( pFileName, "w" );
231 if ( pFile == NULL )
232 {
233 fprintf( stdout, "Io_WriteCellNet(): Cannot open the output file \"%s\".\n", pFileName );
234 return;
235 }
236
237 fprintf( pFile, "# CellNet file for network \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
238
239 // the only tricky part with writing is handling latches:
240 // each latch comes with (a) single-input latch-input node, (b) latch proper, (c) single-input latch-output node
241 // we arbitrarily decide to use the interger ID of the latch-input node to represent the latch in the file
242 // (this ID is used for both the cell and the net driven by that cell)
243
244 // write the PIs
245 Abc_NtkForEachPi( pNtk, pObj, i )
246 fprintf( pFile, "cell %d is 0\n", pObj->Id );
247 // write the POs
248 Abc_NtkForEachPo( pNtk, pObj, i )
249 fprintf( pFile, "cell %d is 1\n", pObj->Id );
250 // write the latches (use the ID of latch input)
251 Abc_NtkForEachLatch( pNtk, pObj, i )
252 fprintf( pFile, "cell %d is 2\n", Abc_ObjFanin0(pObj)->Id );
253 // write the logic nodes
254 Abc_NtkForEachNode( pNtk, pObj, i )
255 fprintf( pFile, "cell %d is %d\n", pObj->Id, 3+Abc_ObjFaninNum(pObj) );
256
257 // write the nets driven by PIs
258 Abc_NtkForEachPi( pNtk, pObj, i )
259 {
260 fprintf( pFile, "net %d %d 0", pObj->Id, pObj->Id );
261 Abc_ObjForEachFanout( pObj, pFanout, k )
262 fprintf( pFile, " %d %d", pFanout->Id, 1 + Abc_ObjFanoutFaninNum(pFanout, pObj) );
263 fprintf( pFile, "\n" );
264 }
265 // write the nets driven by latches
266 Abc_NtkForEachLatch( pNtk, pObj, i )
267 {
268 fprintf( pFile, "net %d %d 0", Abc_ObjFanin0(pObj)->Id, Abc_ObjFanin0(pObj)->Id );
269 pObj = Abc_ObjFanout0(pObj);
270 Abc_ObjForEachFanout( pObj, pFanout, k )
271 fprintf( pFile, " %d %d", pFanout->Id, 1 + Abc_ObjFanoutFaninNum(pFanout, pObj) );
272 fprintf( pFile, "\n" );
273 }
274 // write the nets driven by nodes
275 Abc_NtkForEachNode( pNtk, pObj, i )
276 {
277 fprintf( pFile, "net %d %d 0", pObj->Id, pObj->Id );
278 Abc_ObjForEachFanout( pObj, pFanout, k )
279 fprintf( pFile, " %d %d", pFanout->Id, 1 + Abc_ObjFanoutFaninNum(pFanout, pObj) );
280 fprintf( pFile, "\n" );
281 }
282
283 fprintf( pFile, "\n" );
284 fclose( pFile );
285}
286
290
291
293
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition abc.h:488
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition abc.h:500
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
ABC_DLL int Abc_ObjFanoutFaninNum(Abc_Obj_t *pFanout, Abc_Obj_t *pFanin)
Definition abcFanio.c:373
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
char * Extra_TimeStamp()
void Io_WriteCellNet(Abc_Ntk_t *pNtk, char *pFileName)
void Io_WriteList(Abc_Ntk_t *pNtk, char *pFileName, int fUseHost)
FUNCTION DEFINITIONS ///.
char * pName
Definition abc.h:158
int Id
Definition abc.h:132
#define assert(ex)
Definition util_old.h:213