forked from JackHack96/logic-synthesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhot.c
61 lines (53 loc) · 1.58 KB
/
hot.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
59
60
61
/*
* 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"
int write_one_hot(); /* forward declaration */
write_one_hot(fptr)
FILE *fptr;
{
int i, j, c;
/* print header */
(void) fprintf(fptr, ".model jedi_output\n");
/* print state table */
(void) fprintf(fptr, ".start_kiss\n");
(void) fprintf(fptr, ".i %d\n", ni-1);
(void) fprintf(fptr, ".o %d\n", no-1);
(void) fprintf(fptr, ".s %d\n", enumtypes[0].ns);
(void) fprintf(fptr, ".p %d\n", np);
(void) fprintf(fptr, ".r %s\n", reset_state);
for (i=0; i<np; i++) {
for (j=0; j<ni-1; j++) {
(void) fprintf(fptr, "%s", inputs[j].entries[i].token);
}
(void) fprintf(fptr, " ");
(void) fprintf(fptr, "%s", inputs[ni-1].entries[i].token);
(void) fprintf(fptr, " ");
(void) fprintf(fptr, "%s", outputs[0].entries[i].token);
(void) fprintf(fptr, " ");
for (j=1; j<no; j++) {
(void) fprintf(fptr, "%s", outputs[j].entries[i].token);
}
(void) fprintf(fptr, "\n");
}
(void) fprintf(fptr, ".end_kiss\n");
/* print encodings */
for (i=0; i<enumtypes[0].ns; i++) {
(void) fprintf(fptr, ".code %s ", enumtypes[0].symbols[i].token);
for (j=0; j<enumtypes[0].ns; j++) {
if (i == j) {
(void) fprintf(fptr, "1");
} else {
(void) fprintf(fptr, "0");
}
}
(void) fprintf(fptr, "\n");
}
(void) fprintf(fptr, ".end\n");
} /* end of write_one_hot */