1 | #include "debug.h" |
---|
2 | void printLatch(st_table* CoiTable) |
---|
3 | { |
---|
4 | // COI contents |
---|
5 | printf("*** COI ***\n"); |
---|
6 | st_generator *stGen; |
---|
7 | Ntk_Node_t * latch; |
---|
8 | st_foreach_item(CoiTable, stGen, &latch, NULL) { |
---|
9 | printf("%s\n",Ntk_NodeReadName(latch)); |
---|
10 | } |
---|
11 | } |
---|
12 | |
---|
13 | |
---|
14 | st_table * generateAllLatches(Ntk_Network_t * ntk) |
---|
15 | { |
---|
16 | st_table *CoiTable = st_init_table(st_ptrcmp, st_ptrhash); |
---|
17 | lsGen gen ; |
---|
18 | Ntk_Node_t *node; |
---|
19 | |
---|
20 | Ntk_NetworkForEachNode(ntk,gen, node){ |
---|
21 | if (Ntk_NodeTestIsLatch(node)){ |
---|
22 | st_insert(CoiTable, (char *) node, Ntk_NodeReadName(node)); |
---|
23 | } |
---|
24 | } |
---|
25 | return CoiTable; |
---|
26 | |
---|
27 | } |
---|
28 | |
---|
29 | |
---|
30 | void mdd_GetState_Values( |
---|
31 | mdd_manager *mgr , |
---|
32 | mdd_t * top, |
---|
33 | FILE * f) |
---|
34 | { |
---|
35 | mdd_t * T; |
---|
36 | mdd_t * E; |
---|
37 | int id; |
---|
38 | array_t * val = array_alloc(int, 4); |
---|
39 | static int level; |
---|
40 | char c = ' ' ; |
---|
41 | |
---|
42 | level++; |
---|
43 | |
---|
44 | id = bdd_top_var_id(top); |
---|
45 | |
---|
46 | mvar_type mv = |
---|
47 | array_fetch(mvar_type, mdd_ret_mvar_list((mgr)),(id)); |
---|
48 | // fprintf(f,"("); |
---|
49 | |
---|
50 | // Pour le Then |
---|
51 | T=bdd_then(top); |
---|
52 | |
---|
53 | //variable belongs to what we are looking for |
---|
54 | // if(strstr(mv.name,var_name) !=NULL) |
---|
55 | if(bdd_is_tautology(T,1)){ |
---|
56 | //array_insert(type, array, position, object) |
---|
57 | fprintf(f,"%s = 1 ",mv.name); |
---|
58 | //c = '+'; |
---|
59 | } else |
---|
60 | if(!bdd_is_tautology(T,0)){ |
---|
61 | fprintf(f,"%s = 1 * ",mv.name); |
---|
62 | //mdd_FunctionPrint(mgr, T,f); |
---|
63 | // c = '+'; |
---|
64 | } |
---|
65 | |
---|
66 | mdd_free(T); |
---|
67 | |
---|
68 | //pour le Else |
---|
69 | E=bdd_else(top); |
---|
70 | if(bdd_is_tautology(E,0)){ |
---|
71 | goto fin; |
---|
72 | } |
---|
73 | |
---|
74 | if(bdd_is_tautology(E,1)){ |
---|
75 | fprintf(f,"%c %s = 0",c, mv.name); |
---|
76 | goto fin; |
---|
77 | } |
---|
78 | |
---|
79 | fprintf(f,"%c %s = 0 * ",c, mv.name); |
---|
80 | /* |
---|
81 | mdd_FunctionPrint(mgr, E,f); |
---|
82 | mdd_free(E); |
---|
83 | */ |
---|
84 | fin: |
---|
85 | fprintf(f,")"); |
---|
86 | level--; |
---|
87 | return; |
---|
88 | } |
---|