forked from JackHack96/logic-synthesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom.c
58 lines (52 loc) · 1.27 KB
/
random.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Symbolic encoding program for compiling a symbolic
* description into a binary representation. Target
* is multi-level logic synthesis
*
* History:
*
* Bill Lin
* University of California, Berkeley
* Comments to [email protected]
*
* Copyright (c) 1989 Bill Lin, UC Berkeley CAD Group
* Permission is granted to do anything with this
* code except sell it or remove this message.
*/
#include "jedi.h"
random_embedding()
{
int i, j;
int random_code;
long time();
/*
* generate random seed
*/
if (drandomFlag) {
srandom((int) time(NIL(long)));
}
/*
* for each enumerated type
*/
for (i=0; i<ne ; i++) {
/*
* erase previous assignments
*/
for (j=0; j<enumtypes[i].nc; j++) {
enumtypes[i].codes[j].assigned = FALSE;
enumtypes[i].codes[j].symbol_ptr = 0;
}
/*
* reassign using random encoding
*/
for (j=0; j<enumtypes[i].ns; j++) {
random_code = random() % enumtypes[i].nc;
while (enumtypes[i].codes[random_code].assigned) {
random_code = random() % enumtypes[i].nc;
}
enumtypes[i].codes[random_code].assigned = TRUE;
enumtypes[i].codes[random_code].symbol_ptr = j;
enumtypes[i].symbols[j].code_ptr = random_code;
}
}
} /* end of random_embedding */