emergency commit
[cl-cudd.git] / distr / nanotrav / bnet.h
blob195b8f2e036995d94a7cd4c2b01f86c3fec0bcfd
1 /**CHeaderFile*****************************************************************
3 FileName [bnet.h]
5 PackageName [bnet]
7 Synopsis [Simple-minded package to read a blif file.]
9 Description []
11 SeeAlso []
13 Author [Fabio Somenzi]
15 Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado
17 All rights reserved.
19 Redistribution and use in source and binary forms, with or without
20 modification, are permitted provided that the following conditions
21 are met:
23 Redistributions of source code must retain the above copyright
24 notice, this list of conditions and the following disclaimer.
26 Redistributions in binary form must reproduce the above copyright
27 notice, this list of conditions and the following disclaimer in the
28 documentation and/or other materials provided with the distribution.
30 Neither the name of the University of Colorado nor the names of its
31 contributors may be used to endorse or promote products derived from
32 this software without specific prior written permission.
34 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
37 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
38 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
39 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
40 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
41 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
42 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
44 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45 POSSIBILITY OF SUCH DAMAGE.]
47 Revision [$Id: bnet.h,v 1.12 2004/08/13 18:28:28 fabio Exp fabio $]
49 ******************************************************************************/
51 #ifndef _BNET
52 #define _BNET
54 /*---------------------------------------------------------------------------*/
55 /* Nested includes */
56 /*---------------------------------------------------------------------------*/
58 #include "util.h"
59 #include "st.h"
60 #include "cudd.h"
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
66 /*---------------------------------------------------------------------------*/
67 /* Constant declarations */
68 /*---------------------------------------------------------------------------*/
70 /* Different types of nodes. (Used in the "BnetNode" type.) */
71 #define BNET_CONSTANT_NODE 0
72 #define BNET_INPUT_NODE 1
73 #define BNET_PRESENT_STATE_NODE 2
74 #define BNET_INTERNAL_NODE 3
75 #define BNET_OUTPUT_NODE 4
76 #define BNET_NEXT_STATE_NODE 5
78 /* Type of DD of a node. */
79 #define BNET_LOCAL_DD 0
80 #define BNET_GLOBAL_DD 1
83 /*---------------------------------------------------------------------------*/
84 /* Stucture declarations */
85 /*---------------------------------------------------------------------------*/
87 /*---------------------------------------------------------------------------*/
88 /* Type declarations */
89 /*---------------------------------------------------------------------------*/
91 /* The following types implement a very simple data structure for a boolean
92 ** network. The intent is to be able to read a minimal subset of the blif
93 ** format in a data structure from which it's easy to build DDs for the
94 ** circuit.
97 /* Type to store a line of the truth table of a node. The entire truth table
98 ** implemented as a linked list of objects of this type.
100 typedef struct BnetTabline {
101 char *values; /* string of 1, 0, and - */
102 struct BnetTabline *next; /* pointer to next table line */
103 } BnetTabline;
105 /* Node of the boolean network. There is one node in the network for each
106 ** primary input and for each .names directive. This structure
107 ** has a field to point to the DD of the node function. The function may
108 ** be either in terms of primary inputs, or it may be in terms of the local
109 ** inputs. The latter implies that each node has a variable index
110 ** associated to it at some point in time. The field "var" stores that
111 ** variable index, and "active" says if the association is currently valid.
112 ** (It is indeed possible for an index to be associated to different nodes
113 ** at different times.)
115 typedef struct BnetNode {
116 char *name; /* name of the output signal */
117 int type; /* input, internal, constant, ... */
118 int ninp; /* number of inputs to the node */
119 int nfo; /* number of fanout nodes for this node */
120 char **inputs; /* input names */
121 BnetTabline *f; /* truth table for this node */
122 int polarity; /* f is the onset (0) or the offset (1) */
123 int active; /* node has variable associated to it (1) or not (0) */
124 int var; /* DD variable index associated to this node */
125 DdNode *dd; /* decision diagram for the function of this node */
126 int exdc_flag; /* whether an exdc node or not */
127 struct BnetNode *exdc; /* pointer to exdc of dd node */
128 int count; /* auxiliary field for DD dropping */
129 int level; /* maximum distance from the inputs */
130 int visited; /* flag for search */
131 struct BnetNode *next; /* pointer to implement the linked list of nodes */
132 } BnetNode;
134 /* Very simple boolean network data structure. */
135 typedef struct BnetNetwork {
136 char *name; /* network name: from the .model directive */
137 int npis; /* number of primary inputs */
138 int ninputs; /* number of inputs */
139 char **inputs; /* primary input names: from the .inputs directive */
140 int npos; /* number of primary outputs */
141 int noutputs; /* number of outputs */
142 char **outputs; /* primary output names: from the .outputs directive */
143 int nlatches; /* number of latches */
144 char ***latches; /* next state names: from the .latch directives */
145 BnetNode *nodes; /* linked list of the nodes */
146 st_table *hash; /* symbol table to access nodes by name */
147 char *slope; /* wire_load_slope */
148 } BnetNetwork;
150 /*---------------------------------------------------------------------------*/
151 /* Variable declarations */
152 /*---------------------------------------------------------------------------*/
154 /*---------------------------------------------------------------------------*/
155 /* Macro declarations */
156 /*---------------------------------------------------------------------------*/
158 #ifndef TRUE
159 # define TRUE 1
160 #endif
161 #ifndef FALSE
162 # define FALSE 0
163 #endif
165 /**AutomaticStart*************************************************************/
167 /*---------------------------------------------------------------------------*/
168 /* Function prototypes */
169 /*---------------------------------------------------------------------------*/
171 extern BnetNetwork * Bnet_ReadNetwork (FILE *fp, int pr);
172 extern void Bnet_PrintNetwork (BnetNetwork *net);
173 extern void Bnet_FreeNetwork (BnetNetwork *net);
174 extern int Bnet_BuildNodeBDD (DdManager *dd, BnetNode *nd, st_table *hash, int params, int nodrop);
175 extern int Bnet_DfsVariableOrder (DdManager *dd, BnetNetwork *net);
176 extern int Bnet_bddDump (DdManager *dd, BnetNetwork *network, char *dfile, int dumpFmt, int reencoded);
177 extern int Bnet_bddArrayDump (DdManager *dd, BnetNetwork *network, char *dfile, DdNode **outputs, char **onames, int noutputs, int dumpFmt);
178 extern int Bnet_ReadOrder (DdManager *dd, char *ordFile, BnetNetwork *net, int locGlob, int nodrop);
179 extern int Bnet_PrintOrder (BnetNetwork * net, DdManager *dd);
181 /**AutomaticEnd***************************************************************/
183 #ifdef __cplusplus
184 } /* end of extern "C" */
185 #endif
187 #endif /* _BNET */