source: icGREP/icgrep-devel/cudd-2.5.1/nanotrav/bnet.h @ 5815

Last change on this file since 5815 was 4597, checked in by nmedfort, 4 years ago

Upload of the CUDD library.

File size: 7.8 KB
Line 
1/**CHeaderFile*****************************************************************
2
3  FileName    [bnet.h]
4
5  PackageName [bnet]
6
7  Synopsis    [Simple-minded package to read a blif file.]
8
9  Description []
10
11  SeeAlso     []
12
13  Author      [Fabio Somenzi]
14
15  Copyright   [Copyright (c) 1995-2012, Regents of the University of Colorado
16
17  All rights reserved.
18
19  Redistribution and use in source and binary forms, with or without
20  modification, are permitted provided that the following conditions
21  are met:
22
23  Redistributions of source code must retain the above copyright
24  notice, this list of conditions and the following disclaimer.
25
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.
29
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.
33
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.]
46
47  Revision    [$Id: bnet.h,v 1.13 2012/02/05 01:53:01 fabio Exp fabio $]
48
49******************************************************************************/
50
51#ifndef _BNET
52#define _BNET
53
54/*---------------------------------------------------------------------------*/
55/* Nested includes                                                           */
56/*---------------------------------------------------------------------------*/
57
58#include "util.h"
59#include "st.h"
60#include "cudd.h"
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66/*---------------------------------------------------------------------------*/
67/* Constant declarations                                                     */
68/*---------------------------------------------------------------------------*/
69
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
77
78/* Type of DD of a node. */
79#define BNET_LOCAL_DD 0
80#define BNET_GLOBAL_DD 1
81
82
83/*---------------------------------------------------------------------------*/
84/* Stucture declarations                                                     */
85/*---------------------------------------------------------------------------*/
86
87/*---------------------------------------------------------------------------*/
88/* Type declarations                                                         */
89/*---------------------------------------------------------------------------*/
90
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.
95*/
96
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.
99*/
100typedef struct BnetTabline {
101    char *values;               /* string of 1, 0, and - */
102    struct BnetTabline *next;   /* pointer to next table line */
103} BnetTabline;
104
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.)
114*/
115typedef 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;
133
134/* Very simple boolean network data structure. */
135typedef 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;
149
150/*---------------------------------------------------------------------------*/
151/* Variable declarations                                                     */
152/*---------------------------------------------------------------------------*/
153
154/*---------------------------------------------------------------------------*/
155/* Macro declarations                                                        */
156/*---------------------------------------------------------------------------*/
157
158#ifndef TRUE
159#   define TRUE 1
160#endif
161#ifndef FALSE
162#   define FALSE 0
163#endif
164
165/**AutomaticStart*************************************************************/
166
167/*---------------------------------------------------------------------------*/
168/* Function prototypes                                                       */
169/*---------------------------------------------------------------------------*/
170
171extern BnetNetwork * Bnet_ReadNetwork (FILE *fp, int pr);
172extern void Bnet_PrintNetwork (BnetNetwork *net);
173extern void Bnet_FreeNetwork (BnetNetwork *net);
174extern int Bnet_BuildNodeBDD (DdManager *dd, BnetNode *nd, st_table *hash, int params, int nodrop);
175extern int Bnet_DfsVariableOrder (DdManager *dd, BnetNetwork *net);
176extern int Bnet_bddDump (DdManager *dd, BnetNetwork *network, char *dfile, int dumpFmt, int reencoded);
177extern int Bnet_bddArrayDump (DdManager *dd, BnetNetwork *network, char *dfile, DdNode **outputs, char **onames, int noutputs, int dumpFmt);
178extern int Bnet_ReadOrder (DdManager *dd, char *ordFile, BnetNetwork *net, int locGlob, int nodrop);
179extern int Bnet_PrintOrder (BnetNetwork * net, DdManager *dd);
180
181/**AutomaticEnd***************************************************************/
182
183#ifdef __cplusplus
184} /* end of extern "C" */
185#endif
186
187#endif /* _BNET */
Note: See TracBrowser for help on using the repository browser.