ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cvrmisc.c
Go to the documentation of this file.
1/*
2 * Revision Control Information
3 *
4 * $Source$
5 * $Author$
6 * $Revision$
7 * $Date$
8 *
9 */
10#include "espresso.h"
11
13
14
15
16/* cost -- compute the cost of a cover */
17void cover_cost(F, cost)
18IN pcover F;
19INOUT pcost cost;
20{
21 register pcube p, last;
22 pcube *T;
23 int var;
24
25 /* use the routine used by cofactor to decide splitting variables */
28
29 cost->cubes = F->count;
30 cost->total = cost->in = cost->out = cost->mv = cost->primes = 0;
31
32 /* Count transistors (zeros) for each binary variable (inputs) */
33 for(var = 0; var < cube.num_binary_vars; var++)
34 cost->in += cdata.var_zeros[var];
35
36 /* Count transistors for each mv variable based on sparse/dense */
37 for(var = cube.num_binary_vars; var < cube.num_vars - 1; var++)
38 if (cube.sparse[var])
39 cost->mv += F->count * cube.part_size[var] - cdata.var_zeros[var];
40 else
41 cost->mv += cdata.var_zeros[var];
42
43 /* Count the transistors (ones) for the output variable */
44 if (cube.num_binary_vars != cube.num_vars) {
45 var = cube.num_vars - 1;
46 cost->out = F->count * cube.part_size[var] - cdata.var_zeros[var];
47 }
48
49 /* Count the number of nonprime cubes */
50 foreach_set(F, last, p)
51 cost->primes += TESTP(p, PRIME) != 0;
52
53 /* Count the total number of literals */
54 cost->total = cost->in + cost->out + cost->mv;
55}
56
57
58/* fmt_cost -- return a string which reports the "cost" of a cover */
59char *fmt_cost(cost)
60IN pcost cost;
61{
62 static char s[200];
63
64 if (cube.num_binary_vars == cube.num_vars - 1)
65 (void) sprintf(s, "c=%d(%d) in=%d out=%d tot=%d",
66 cost->cubes, cost->cubes - cost->primes, cost->in,
67 cost->out, cost->total);
68 else
69 (void) sprintf(s, "c=%d(%d) in=%d mv=%d out=%d",
70 cost->cubes, cost->cubes - cost->primes, cost->in,
71 cost->mv, cost->out);
72 return s;
73}
74
75
76char *print_cost(F)
77IN pcover F;
78{
79 cost_t cost;
80 cover_cost(F, &cost);
81 return fmt_cost(&cost);
82}
83
84
85/* copy_cost -- copy a cost function from s to d */
86void copy_cost(s, d)
87pcost s, d;
88{
89 d->cubes = s->cubes;
90 d->in = s->in;
91 d->out = s->out;
92 d->mv = s->mv;
93 d->total = s->total;
94 d->primes = s->primes;
95}
96
97
98/* size_stamp -- print single line giving the size of a cover */
100IN pcover T;
101IN char *name;
102{
103 (void) printf("# %s\tCost is %s\n", name, print_cost(T));
104 (void) fflush(stdout);
105}
106
107
108/* print_trace -- print a line reporting size and time after a function */
109void print_trace(T, name, time)
110pcover T;
111char *name;
112long time;
113{
114 (void) printf("# %s\tTime was %s, cost is %s\n",
115 name, print_time(time), print_cost(T));
116 (void) fflush(stdout);
117}
118
119
120/* totals -- add time spent in the function into the totals */
121void totals(time, i, T, cost)
122long time;
123int i;
124pcover T;
125pcost cost;
126{
127 time = ptime() - time;
128 total_time[i] += time;
129 total_calls[i]++;
130 cover_cost(T, cost);
131 if (trace) {
132 (void) printf("# %s\tTime was %s, cost is %s\n",
133 total_name[i], print_time(time), fmt_cost(cost));
134 (void) fflush(stdout);
135 }
136}
137
138
139/* fatal -- report fatal error message and take a dive */
140void fatal(s)
141char *s;
142{
143 (void) fprintf(stderr, "espresso: %s\n", s);
144 exit(1);
145}
147
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define pcover
Definition espresso.h:264
struct cost_struct * pcost
void copy_cost()
void totals()
#define TESTP(set, flag)
Definition espresso.h:124
struct cost_struct cost_t
void fatal()
#define print_time(t)
Definition espresso.h:22
void massive_count()
#define INOUT
Definition espresso.h:334
int total_calls[TIME_COUNT]
Definition globals.c:23
#define pcube
Definition espresso.h:261
void print_trace()
bool trace
Definition globals.c:36
long total_time[TIME_COUNT]
Definition globals.c:22
char * fmt_cost()
char * print_cost()
#define foreach_set(R, last, p)
Definition espresso.h:135
void cover_cost()
#define IN
Definition espresso.h:332
void size_stamp()
#define PRIME
Definition espresso.h:127
char * total_name[TIME_COUNT]
Definition globals.c:21
#define free_cubelist(T)
Definition espresso.h:267
pcube * cube1list()
Cube * p
Definition exorList.c:222
char * name
Definition main.h:24
Definition exor.h:123
#define ptime()
Definition util_old.h:283
char * sprintf()
VOID_HACK exit()