Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / beh / beg / beg_main.c
1 #include MUT_H
2 #include LOG_H
3 #include BEH_H
4 #include BEG_H
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include "beg_gen.h"
9
10 extern void avtenv(void);
11 extern void savebefig(befig_list *ptbefig, unsigned int trace_mode);
12
13 befig_list *befig;
14 befig_list *befig2;
15
16 void dotest()
17 {
18 verilogloadlofig(NULL,"testeat",'A');
19 return;
20 }
21
22 void addaccutest()
23 {
24 //{{{
25 beg_def_befig ("addaccu");
26
27 beg_def_por ("a(0:3)" ,'I');
28 beg_def_por ("b(0:3)" ,'I');
29 beg_def_por ("sel" ,'I');
30 beg_def_por ("ck" ,'I');
31 beg_def_por ("s(0:3)" ,'O');
32 beg_def_por ("vdd" ,'I');
33 beg_def_por ("vdde" ,'I');
34 beg_def_por ("vss" ,'I');
35 beg_def_por ("vsse" ,'I');
36
37 beg_assertion ("vdd and not vss" ,"Wrong power supplies" ,
38 'W',NULL);
39 beg_assertion ("vdde and not vsse" ,"Wrong power external supplies",
40 'W',NULL);
41
42 beg_def_mux ("outmux(0:3)" ,"sel" ,"0b 0" ,"a(0:3)" ,0);
43 beg_def_mux ("outmux(0:3)" ,"sel" ,"0b 1" ,"outreg(0:3)" ,0);
44
45 beg_def_sig ("sum(0)" ,"outmux(0) xor b(0)" ,0);
46 beg_def_sig ("carry(0)" ,"outmux(0) and b(0)" ,0);
47 beg_def_sig ("sum(1)" ,"outmux(1) xor b(1) xor carry(0)" ,0);
48 beg_def_sig ("carry(1)" ,"(outmux(1) and b(1)) or (outmux(1) "
49 "and carry(0)) or (b(1) and carry(0))" ,0);
50 beg_def_sig ("sum(2)" ,"outmux(2) xor b(2) xor carry(1)" ,0);
51 beg_def_sig ("carry(2)" ,"(outmux(2) and b(2)) or (outmux(2) "
52 "and carry(1)) or (b(2) and carry(1))" ,0);
53 beg_def_sig ("sum(3)" ,"outmux(3) xor b(3) xor carry(2)" ,0);
54 beg_def_sig ("s(0:3)" ,"sum(0:3)" ,0);
55
56 beg_def_process("reg(0:3)" ,"not ck and ck'event" ,"not sum(0:3)" ,0,
57 BEG_REG);
58
59 beg_def_sig ("outreg(0:3)" ,"not reg(0:3)" ,0);
60
61 befig = beg_get_befig(0);
62 savebefig (befig,0);
63 //}}}
64 }
65
66 void amdtest()
67 {
68 //{{{
69 beg_def_befig ("amd");
70 //beg_def_por ("cke" ,'I');
71 //beg_def_por ("fonc" ,'I');
72 //beg_def_por ("test" ,'I');
73 //beg_def_por ("scin" ,'I');
74 beg_def_por ("scout" ,'O');
75 //beg_def_por ("i(8:0)" ,'I');
76 //beg_def_por ("a(3:0)" ,'I');
77 //beg_def_por ("b(3:0)" ,'I');
78 //beg_def_por ("d(3:0)" ,'I');
79 //beg_def_por ("noe" ,'I');
80 beg_def_por ("r0" ,'O');
81 beg_def_por ("r3" ,'O');
82 beg_def_por ("q0" ,'O');
83 beg_def_por ("q3" ,'O');
84 beg_def_por ("ovr" ,'O');
85 beg_def_por ("zero" ,'O');
86 beg_def_por ("signe" ,'O');
87 beg_def_por ("np" ,'O');
88 beg_def_por ("ng" ,'O');
89 //beg_def_por ("cin" ,'I');
90 beg_def_por ("cout" ,'O');
91 beg_def_por ("y(3:0)" ,'O');
92 beg_def_por ("vddi" ,'I');
93 beg_def_por ("vssi" ,'I');
94 beg_def_por ("vdde" ,'I');
95 beg_def_por ("vsse" ,'I');
96
97 beg_assertion ("vddi and not vssi" ,"Wrong power supplies",'W',NULL);
98 beg_assertion ("vdde and not vsse" ,"Wrong power external supplies",'W',NULL);
99
100 beg_def_mux ("s(3:0)" ,"i(2:0)" ,"0o4" ,"ra(3:0)" ,0);
101 beg_def_mux ("s(3:0)" ,0 ,"0o5" ,"ra(3:0)" ,0);
102 beg_def_mux ("s(3:0)" ,0 ,"0o1" ,"rb(3:0)" ,0);
103 beg_def_mux ("s(3:0)" ,0 ,"0o3" ,"rb(3:0)" ,0);
104 beg_def_mux ("s(3:0)" ,0 ,"0o0" ,"not accu(3:0)",0);
105 beg_def_mux ("s(3:0)" ,0 ,"0o2" ,"not accu(3:0)",0);
106 beg_def_mux ("s(3:0)" ,0 ,"0o6" ,"not accu(3:0)",0);
107 beg_def_mux ("s(3:0)" ,0 ,"0o7" ,"0x 0" ,0);
108
109 beg_def_mux ("r(3:0)" ,"i(2:0)" ,"0o0" ,"ra(3:0)" ,0);
110 beg_def_mux ("r(3:0)" ,0 ,"0o1" ,"ra(3:0)" ,0);
111 beg_def_mux ("r(3:0)" ,0 ,"0o2" ,"0x 0" ,0);
112 beg_def_mux ("r(3:0)" ,0 ,"0o3" ,"0x 0" ,0);
113 beg_def_mux ("r(3:0)" ,0 ,"0o4" ,"0x 0" ,0);
114 beg_def_mux ("r(3:0)" ,0 ,"0o5" ,"d(3:0)" ,0);
115 beg_def_mux ("r(3:0)" ,0 ,"0o6" ,"d(3:0)" ,0);
116 beg_def_mux ("r(3:0)" ,0 ,"0o7" ,"d(3:0)" ,0);
117
118 beg_def_process("y(3:0)" ,"not noe and i(8:6)=0o2" ,"ra(3:0)" ,0,BEG_PRE|BEG_REG);
119 beg_def_process("y(3:0)" ,"not noe" ,"alu_out(3:0)" ,0,BEG_PRE|BEG_REG);
120 beg_def_process("y(3:0)" ,"0b1" ,"0xZ" ,0,BEG_PRE|BEG_REG);
121
122
123 beg_def_sig ("sumrs(3:0)" ,"r(3:0) xor s(3:0) xor (c_sumrs(2:0)&cin)" ,0);
124 beg_def_sig ("c_sumrs(3:0)" ,"( r(3:0) and s(3:0) ) or ( r(3:0) and (c_sumrs(2:0)&cin) ) or ( s(3:0) and (c_sumrs(2:0)&cin) )" ,0);
125
126 beg_def_sig ("difrs(3:0)" ,"r(3:0) xor not s(3:0) xor (c_difrs(2:0)&cin)" ,0);
127 beg_def_sig ("c_difrs(3:0)" ,"( r(3:0) and not s(3:0) ) or ( r(3:0) and (c_difrs(2:0)&cin) ) or ( not s(3:0) and (c_difrs(2:0)&cin) )" ,0);
128
129 beg_def_sig ("difsr(3:0)" ,"not r(3:0) xor s(3:0) xor (c_difsr(2:0)&cin)" ,0);
130 beg_def_sig ("c_difsr(3:0)" ,"( not r(3:0) and s(3:0) ) or ( not r(3:0) and (c_difsr(2:0)&cin) ) or ( s(3:0) and (c_difsr(2:0)&cin) )" ,0);
131
132 beg_def_mux ("ng" ,"i(5:3)" ,"0o0" ,"not ((r(3) and s(3)) or ((r(3) or s(3)) and (r(2) and s(2))) or ((r(3) or s(3)) and (r(2) or s(2)) and (r(1) and s(1))) or ((r(3) or s(3)) and (r(2) or s(2)) and (r(1) or s(1)) and (r(0) and s(0))))" ,0);
133 beg_def_mux ("ng" ,0 ,"0o1" ,"NOT ((NOT r(3) AND s(3)) OR ((NOT r(3) OR s(3)) AND (NOT r(2) AND s(2))) OR ((NOT r(3) OR s(3)) AND (NOT r(2) OR s(2)) AND (NOT r(1) AND s(1))) OR ((NOT r(3) OR s(3)) AND (NOT r(2) OR s(2)) AND (NOT r(1) OR s(1)) AND (NOT r(0) AND s(0))))" ,0);
134 beg_def_mux ("ng" ,0 ,"0o2" ,"NOT ((r(3) AND NOT s(3)) OR ((r(3) OR NOT s(3)) AND (r(2) AND NOT s(2))) OR ((r(3) OR NOT s(3)) AND (r(2) OR NOT s(2)) AND (r(1) AND NOT s(1))) OR ((r(3) OR NOT s(3)) AND (r(2) OR NOT s(2)) AND (r(1) OR NOT s(1)) AND (r(0) AND NOT s(0))))" ,0);
135
136 beg_def_mux ("np" ,"i(5:3)" ,"0o0" ,"NOT ((r(3) OR s(3)) AND (r(2) OR s(2)) AND (r(1) OR s(1)) AND (r(0) OR s(0)))" ,0);
137 beg_def_mux ("np" ,0 ,"0o1" ,"NOT ((NOT r(3) OR s(3)) AND (NOT r(2) OR s(2)) AND (NOT r(1) OR s(1)) AND (NOT r(0) OR s(0)))" ,0);
138 beg_def_mux ("np" ,0 ,"0o2" ,"NOT ((r(3) OR NOT s(3)) AND (r(2) OR NOT s(2)) AND (r(1) OR NOT s(1)) AND (r(0) OR NOT s(0)))" ,0);
139
140 beg_def_sig ("signe" ,"alu_out(3)" ,0);
141 beg_def_sig ("zero" ,"NOT (alu_out(3) OR alu_out(2) OR alu_out(1) OR alu_out(0))" ,0);
142
143 beg_def_mux ("ovr" ,"i(5:3)" ,"0o0" ,"c_sumrs(3) xor c_sumrs(2)" ,0);
144 beg_def_mux ("ovr" ,0 ,"0o1" ,"c_difsr(3) xor c_difsr(2)" ,0);
145 beg_def_mux ("ovr" ,0 ,"0o2" ,"c_difrs(3) xor c_difrs(2)" ,0);
146 beg_def_mux ("ovr" ,0 ,"default","0b 0" ,0);
147
148 beg_def_mux ("alu_out(3:0)" ,"i(5:3)" ,"0o0" ,"sumrs(3:0)" ,0);
149 beg_def_mux ("alu_out(3:0)" ,0 ,"0o1" ,"difsr(3:0)" ,0);
150 beg_def_mux ("alu_out(3:0)" ,0 ,"0o2" ,"difrs(3:0)" ,0);
151 beg_def_mux ("alu_out(3:0)" ,0 ,"0o3" ,"r(3:0) or s(3:0)" ,0);
152 beg_def_mux ("alu_out(3:0)" ,0 ,"0o4" ,"r(3:0) and s(3:0)" ,0);
153 beg_def_mux ("alu_out(3:0)" ,0 ,"0o5" ,"not r(3:0) and s(3:0)" ,0);
154 beg_def_mux ("alu_out(3:0)" ,0 ,"0o6" ,"r(3:0) xor s(3:0)" ,0);
155 beg_def_mux ("alu_out(3:0)" ,0 ,"0o7" ,"not (r(3:0) xor s(3:0))" ,0);
156
157 beg_def_mux ("cout" ,"i(5:3)" ,"0o0" ,"c_sumrs(3)" ,0);
158 beg_def_mux ("cout" ,0 ,"0o1" ,"c_difsr(3)" ,0);
159 beg_def_mux ("cout" ,0 ,"0o2" ,"c_difrs(3)" ,0);
160 beg_def_mux ("cout" ,0 ,"default","0b 0" ,0);
161
162 beg_def_sig ("wram" ,"(i(8) OR i(7)) AND fonc_mode" ,0);
163 beg_def_sig ("waccu" ,"NOT (i(6)) AND ((NOT i(7)) OR i(8))" ,0);
164 beg_def_sig ("fonc_mode" ,"fonc AND (NOT test)" ,0);
165 beg_def_sig ("test_mode" ,"test AND (NOT fonc)" ,0);
166 beg_def_sig ("shift_r" ,"i(8) AND (NOT i(7))" ,0);
167 beg_def_sig ("shift_l" ,"i(8) AND i(7)" ,0);
168 beg_def_sig ("shift_n" ,"NOT i(8)" ,0);
169
170 beg_def_mux ("sh_acc(3)" ,"i(8:6)" ,"0o0" ,"alu_out(3)" ,0);
171 beg_def_mux ("sh_acc(3)" ,0 ,"0o6" ,"not accu(2)" ,0);
172 beg_def_mux ("sh_acc(3)" ,0 ,"0o7" ,"not accu(2)" ,0);
173 beg_def_mux ("sh_acc(3)" ,0 ,"0o4" ,"q3" ,0);
174 beg_def_mux ("sh_acc(3)" ,0 ,"0o5" ,"q3" ,0);
175 beg_def_mux ("sh_acc(3)" ,0 ,"default","0b 0" ,0);
176
177 beg_def_mux ("sh_acc(2)" ,"i(8:6)" ,"0o0" ,"alu_out(2)" ,0);
178 beg_def_mux ("sh_acc(2)" ,0 ,"0o6" ,"not accu(1)" ,0);
179 beg_def_mux ("sh_acc(2)" ,0 ,"0o7" ,"not accu(1)" ,0);
180 beg_def_mux ("sh_acc(2)" ,0 ,"0o4" ,"not accu(3)" ,0);
181 beg_def_mux ("sh_acc(2)" ,0 ,"0o5" ,"not accu(3)" ,0);
182 beg_def_mux ("sh_acc(2)" ,0 ,"default","0b 0" ,0);
183
184 beg_def_mux ("sh_acc(1)" ,"i(8:6)" ,"0o0" ,"alu_out(1)" ,0);
185 beg_def_mux ("sh_acc(1)" ,0 ,"0o6" ,"not accu(0)" ,0);
186 beg_def_mux ("sh_acc(1)" ,0 ,"0o7" ,"not accu(0)" ,0);
187 beg_def_mux ("sh_acc(1)" ,0 ,"0o4" ,"not accu(2)" ,0);
188 beg_def_mux ("sh_acc(1)" ,0 ,"0o5" ,"not accu(2)" ,0);
189 beg_def_mux ("sh_acc(1)" ,0 ,"default","0b 0" ,0);
190
191 beg_def_mux ("sh_acc(0)" ,"i(8:6)" ,"0o0" ,"alu_out(0)" ,0);
192 beg_def_mux ("sh_acc(0)" ,0 ,"0o6" ,"q0" ,0);
193 beg_def_mux ("sh_acc(0)" ,0 ,"0o7" ,"q0" ,0);
194 beg_def_mux ("sh_acc(0)" ,0 ,"0o4" ,"not accu(1)" ,0);
195 beg_def_mux ("sh_acc(0)" ,0 ,"0o5" ,"not accu(1)" ,0);
196 beg_def_mux ("sh_acc(0)" ,0 ,"default","0b 0" ,0);
197
198 beg_def_process("q3" ,"i(8:6)=0o6 or i(8:6)=0o7","not accu(3)",0,BEG_REG);
199 beg_def_process("q0" ,"i(8:6)=0o4 or i(8:6)=0o5","not accu(0)",0,BEG_REG);
200
201 beg_def_sig ("wckaccu" ,"cke AND (test_mode OR (waccu AND fonc_mode))" ,0);
202
203 beg_def_mux ("accu_in(3:0)" ,"test_mode","0b0","sh_acc(3:0)" ,0);
204 beg_def_mux ("accu_in(3:0)" ,0 ,"0b1","not accu(2:0) & scin",0);
205
206 beg_def_process("accu(3:0)" ,"not wckaccu and not wckaccu'stable" ,"not accu_in(3:0)",0,BEG_REG);
207
208 beg_def_sig ("scout" ,"not accu(3) and test_mode" ,0);
209
210 beg_def_mux ("sh_ram(3)" ,"shift_n & shift_l & shift_r","0o4","alu_out(3)" ,0);
211 beg_def_mux ("sh_ram(3)" ,0 ,"0o2" ,"alu_out(2)",0);
212 beg_def_mux ("sh_ram(3)" ,0 ,"0o1" ,"r3" ,0);
213 beg_def_mux ("sh_ram(3)" ,0 ,"default","0b0" ,0);
214
215 beg_def_mux ("sh_ram(2)" ,"shift_n & shift_l & shift_r","0o4","alu_out(2)" ,0);
216 beg_def_mux ("sh_ram(2)" ,0 ,"0o2" ,"alu_out(1)",0);
217 beg_def_mux ("sh_ram(2)" ,0 ,"0o1" ,"alu_out(3)",0);
218 beg_def_mux ("sh_ram(2)" ,0 ,"default","0b0" ,0);
219
220 beg_def_mux ("sh_ram(1)" ,"shift_n & shift_l & shift_r","0o4","alu_out(1)" ,0);
221 beg_def_mux ("sh_ram(1)" ,0 ,"0o2" ,"alu_out(0)",0);
222 beg_def_mux ("sh_ram(1)" ,0 ,"0o1" ,"alu_out(2)",0);
223 beg_def_mux ("sh_ram(1)" ,0 ,"default","0b0" ,0);
224
225 beg_def_mux ("sh_ram(0)" ,"shift_n & shift_l & shift_r","0o4","alu_out(0)" ,0);
226 beg_def_mux ("sh_ram(0)" ,0 ,"0o2" ,"r0" ,0);
227 beg_def_mux ("sh_ram(0)" ,0 ,"0o1" ,"alu_out(1)",0);
228 beg_def_mux ("sh_ram(0)" ,0 ,"default","0b0" ,0);
229
230 beg_def_process("r3" ,"shift_l" ,"not alu_out(3)" ,0,BEG_REG);
231 beg_def_process("r0" ,"shift_l" ,"not alu_out(0)" ,0,BEG_REG);
232
233 beg_def_sig ("wck(0)" ,"cke and wram and not b(3) and not b(2) and not b(1) and not b(0)",0);
234 beg_def_sig ("wck(1)" ,"cke and wram and not b(3) and not b(2) and not b(1) and b(0)",0);
235 beg_def_sig ("wck(2)" ,"cke and wram and not b(3) and not b(2) and b(1) and not b(0)",0);
236 beg_def_sig ("wck(3)" ,"cke and wram and not b(3) and not b(2) and b(1) and b(0)",0);
237 beg_def_sig ("wck(4)" ,"cke and wram and not b(3) and b(2) and not b(1) and not b(0)",0);
238 beg_def_sig ("wck(5)" ,"cke and wram and not b(3) and b(2) and not b(1) and b(0)",0);
239 beg_def_sig ("wck(6)" ,"cke and wram and not b(3) and b(2) and b(1) and not b(0)",0);
240 beg_def_sig ("wck(7)" ,"cke and wram and not b(3) and b(2) and b(1) and b(0)",0);
241 beg_def_sig ("wck(8)" ,"cke and wram and b(3) and not b(2) and not b(1) and not b(0)",0);
242 beg_def_sig ("wck(9)" ,"cke and wram and b(3) and not b(2) and not b(1) and b(0)",0);
243 beg_def_sig ("wck(10)" ,"cke and wram and b(3) and not b(2) and b(1) and not b(0)",0);
244 beg_def_sig ("wck(11)" ,"cke and wram and b(3) and not b(2) and b(1) and b(0)",0);
245 beg_def_sig ("wck(12)" ,"cke and wram and b(3) and b(2) and not b(1) and not b(0)",0);
246 beg_def_sig ("wck(13)" ,"cke and wram and b(3) and b(2) and not b(1) and b(0)",0);
247 beg_def_sig ("wck(14)" ,"cke and wram and b(3) and b(2) and b(1) and not b(0)",0);
248 beg_def_sig ("wck(15)" ,"cke and wram and b(3) and b(2) and b(1) and b(0)",0);
249
250 beg_def_biloop ("ram(j+4*i)" ,"not wck(i) and not wck(i)'stable","sh_ram(j)","i(15:0)","j(3:0)",33,BEG_REG);
251
252 beg_def_mux ("rb(3:0)" ,"b(3:0)" ,"0x0" ,"not ram (3:0)" ,0);
253 beg_def_mux ("rb(3:0)" ,0 ,"0x1" ,"not ram (7:4)" ,0);
254 beg_def_mux ("rb(3:0)" ,0 ,"0x2" ,"not ram(11:8)" ,0);
255 beg_def_mux ("rb(3:0)" ,0 ,"0x3" ,"not ram(15:12)",0);
256 beg_def_mux ("rb(3:0)" ,0 ,"0x4" ,"not ram(19:16)",0);
257 beg_def_mux ("rb(3:0)" ,0 ,"0x5" ,"not ram(23:20)",0);
258 beg_def_mux ("rb(3:0)" ,0 ,"0x6" ,"not ram(27:24)",0);
259 beg_def_mux ("rb(3:0)" ,0 ,"0x7" ,"not ram(31:28)",0);
260 beg_def_mux ("rb(3:0)" ,0 ,"0x8" ,"not ram(35:32)",0);
261 beg_def_mux ("rb(3:0)" ,0 ,"0x9" ,"not ram(39:36)",0);
262 beg_def_mux ("rb(3:0)" ,0 ,"0xa" ,"not ram(43:40)",0);
263 beg_def_mux ("rb(3:0)" ,0 ,"0xb" ,"not ram(47:44)",0);
264 beg_def_mux ("rb(3:0)" ,0 ,"0xc" ,"not ram(51:48)",0);
265 beg_def_mux ("rb(3:0)" ,0 ,"0xd" ,"not ram(55:52)",0);
266 beg_def_mux ("rb(3:0)" ,0 ,"0xe" ,"not ram(59:56)",0);
267 beg_def_mux ("rb(3:0)" ,0 ,"0xf" ,"not ram(63:60)",0);
268
269 beg_def_mux ("ra(3:0)" ,"a(3:0)" ,"0x0" ,"not ram (3:0)" ,0);
270 beg_def_mux ("ra(3:0)" ,0 ,"0x1" ,"not ram (7:4)" ,0);
271 beg_def_mux ("ra(3:0)" ,0 ,"0x2" ,"not ram(11:8)" ,0);
272 beg_def_mux ("ra(3:0)" ,0 ,"0x3" ,"not ram(15:12)",0);
273 beg_def_mux ("ra(3:0)" ,0 ,"0x4" ,"not ram(19:16)",0);
274 beg_def_mux ("ra(3:0)" ,0 ,"0x5" ,"not ram(23:20)",0);
275 beg_def_mux ("ra(3:0)" ,0 ,"0x6" ,"not ram(27:24)",0);
276 beg_def_mux ("ra(3:0)" ,0 ,"0x7" ,"not ram(31:28)",0);
277 beg_def_mux ("ra(3:0)" ,0 ,"0x8" ,"not ram(35:32)",0);
278 beg_def_mux ("ra(3:0)" ,0 ,"0x9" ,"not ram(39:36)",0);
279 beg_def_mux ("ra(3:0)" ,0 ,"0xa" ,"not ram(43:40)",0);
280 beg_def_mux ("ra(3:0)" ,0 ,"0xb" ,"not ram(47:44)",0);
281 beg_def_mux ("ra(3:0)" ,0 ,"0xc" ,"not ram(51:48)",0);
282 beg_def_mux ("ra(3:0)" ,0 ,"0xd" ,"not ram(55:52)",0);
283 beg_def_mux ("ra(3:0)" ,0 ,"0xe" ,"not ram(59:56)",0);
284 beg_def_mux ("ra(3:0)" ,0 ,"0xf" ,"not ram(63:60)",0);
285
286 befig = beg_get_befig (0);
287 savebefig(befig,0);
288 befig2 = beh_duplicate(befig);
289 beh_frebefig(befig);
290 befig2->NAME = namealloc("duplication");
291 savebefig(befig2,0);
292 befig2->NAME = namealloc("biterizing");
293 beh_biterize(befig2);
294 savebefig(befig2,0);
295 beh_frebefig(befig2);
296 //}}}
297 }
298
299 void conflicttest()
300 {
301 //{{{
302 #ifdef size
303 #undef size
304 #endif
305 #define size 128
306 int i;
307 char buf[3][1024];
308 befig_list *fig;
309
310
311 beg_def_befig(namealloc("testconflict"));
312
313 for (i = 0; i < 128; i ++)
314 {
315 sprintf(buf[1],"outsaen=0b1 and dat(%d)=0b1 and daf(%d)=0b0",i,i);
316 sprintf(buf[0],"dati(%d)",i);
317 beg_def_process (buf[0] ,buf[1],"0b1",0,BEG_REG);
318
319 sprintf(buf[1],"outsaen=0b1 and dat(%d)=0b0 and daf(%d)=0b1",i,i);
320 sprintf(buf[0],"dati(%d)",i);
321 beg_def_process (buf[0] ,buf[1],"0b0",0,BEG_REG|BEG_PRE);
322 }
323 beg_sort();
324 beg_compact();
325
326 befig = beg_get_befig (0);
327 //
328 beg_def_befig(namealloc("testconflict2"));
329 for (i = 0; i < 128; i ++)
330 {
331 sprintf(buf[1],
332 "(dafi(%d)=0b0 and dinla%d_net202=0b0) or "
333 "dinla%d_dinbpdw=0b1",i,
334 128,128);
335 //128-i,128-i);
336 sprintf(buf[0],"dati(%d)",i);
337 beg_def_process (buf[0] ,buf[1],"0b0",0,BEG_REG);
338
339 sprintf(buf[1],
340 "(dafi(%d)=0b1 and dinla%d_net202=0b0) or "
341 "(dinla%d_dinbpup=0b0 and dinla%d_net202=0b0) or "
342 "dinla%d_dinipup=0b0",i,
343 128,128,128,128);
344 //128-i,128-i,128-i,128-i);
345 sprintf(buf[0],"dati(%d)",i);
346 beg_def_process (buf[0] ,buf[1],"0b0",0,BEG_REG|BEG_PRE);
347 }
348 beg_sort();
349 beg_compact();
350 fig = beg_get_befig(0);
351 // savebefig(fig,0);
352
353 beg_eat_figure(befig);
354
355 fig = beg_get_befig(0);
356 savebefig(fig,0);
357 //}}}
358 }
359
360 /*{{{ */
361 /* */
362 /* */
363 /****************************************************************************/
364 void printhour(time_t tim)
365 {
366 int h, m, s;
367
368 s = tim % 60;
369 m = (tim/60) % 60;
370 h = (tim/3600);
371
372 printf(" ");
373 if (h) printf("%d:",h);
374 if (m) printf("%2d'",m);
375 printf("%2d\" - OK\n",s);
376 }
377
378 /*}}}************************************************************************/
379
380
381 int main(int argc, char **argv)
382 {
383
384 char *str;
385 chain_list *abl;
386 chain_list *abl2;
387 int test;
388 char dat[1024],sig[1024], nsig[1024], cmd[1024], fig[1024], mem[1024], *mainfig;
389 int i, j, k, l, m, n;
390 chain_list *list;
391 time_t cur, beg, bef, ela;
392
393 avtenv();
394 mbkenv();
395
396 test = (argc > 1) ? atoi(argv[1]) : 6;
397
398 time(&beg);
399 bef = beg;
400
401 switch (test)
402 {
403 case 1 : // test -1- parser d'expression
404 //{{{
405 str = namealloc("je(3 downto 1) & xab & (('1'&'0') "
406 "and test(1 downto 0) ) & (le xor premier)");
407 printf("Test de : \"%s\"\n",str);
408 abl = beg_genStr2Abl(str);
409 displayExpr(abl);
410 str = namealloc("a and b and c and d");
411 printf("Test de : \"%s\"\n",str);
412 abl = beg_genStr2Abl(str);
413 displayExpr(abl);
414 str = namealloc("not ck'stable");
415 printf("Test de : \"%s\"\n",str);
416 abl = beg_genStr2Abl(str);
417 displayExpr(abl);
418 str = namealloc("ck'event and r");
419 printf("Test de : \"%s\"\n",str);
420 abl = beg_genStr2Abl(str);
421 displayExpr(abl);
422 str = namealloc("ck'stable");
423 printf("Test de : \"%s\"\n",str);
424 abl = beg_genStr2Abl(str);
425 displayExpr(abl);
426 //}}}
427 case 2 : // test -2- inversion d'expression
428 //{{{
429 invertVectAbl(abl);
430 displayExpr(abl);
431 //}}}
432 break;
433 case 3 : // test -3- parser de bit string
434 //{{{
435 if (!strcmp("\"111101011010001001\"",beg_genBitStr("0O 7_5_3211")))
436 printf("OK\n");
437 else
438 printf("Test FAILED\n");
439 if (!strcmp("\"10101010101111010001000001111001010100010011\"",
440 beg_genBitStr("0X aAbD1079513")))
441 printf("OK\n");
442 else
443 printf("Test FAILED\n");
444 //}}}
445 break;
446 case 4 :
447 //{{{
448 abl = createBitStr(genUBitStr(10));
449 printf("abl :");
450 displayExpr(abl);
451 str = namealloc("a and b");
452 abl2 = beg_genStr2Abl(str);
453 printf("abl2 :");
454 displayExpr(abl2);
455 changeAblAtRange(abl,0,0,abl2,1);
456 printf("changeAblAtRange (abl,5,5,abl2,0) :");
457 displayExpr(abl);
458 abl = createBitStr(genHZBitStr(10));
459 printf("abl :");
460 displayExpr(abl);
461 printf("abl2 :");
462 displayExpr(abl2);
463 changeAblAtRange(abl,5,5,abl2,1);
464 printf("changeAblAtRange (abl,5,5,abl2,0) :");
465 displayExpr(abl);
466 abl = beg_genStr2Abl(namealloc("test(10:4)"));
467 printf("abl :");
468 displayExpr(abl);
469 printf("abl2 :");
470 displayExpr(abl2);
471 changeAblAtRange(abl,5,5,abl2,2);
472 printf("changeAblAtRange (abl,5,5,abl2,0) :");
473 displayExpr(abl);
474 str = namealloc("je(3 downto 1) & 0x ab & (('1'&'0') "
475 "and test(1 downto 0) ) & (le xor premier)");
476 abl = beg_genStr2Abl(str);
477 printf("abl :");
478 displayExpr(abl);
479 if (!changeAblAtRange(abl,10,10,abl2,2))
480 printf("rate\n");
481 printf("changeAblAtRange (abl,10,10,abl2,0) :");
482 displayExpr(abl);
483 str = namealloc("^4 b(3:1)");
484 abl = beg_genStr2Abl(str);
485 printf("abl :");
486 displayExpr(abl);
487 repToCatVectAbl(abl);
488 printf("abl :");
489 displayExpr(abl);
490 //}}}
491 break;
492 case 5 : // test -
493 // //{{{
494 // str = namealloc("testrigolo2, 1");
495 // str3 = beg_changeName(str,str,"i",0,1);
496 // if (str3)
497 // printf("%s#\n",str3);
498 // else
499 // printf("erreur\n");
500 //
501 // str2 = mbkstrdup("testrigolo2, 1");
502 // // str3 = beg_changeName(str,str2,"i",1,1);
503 // if (str3)
504 // printf("%s#\n",str3);
505 // else
506 // printf("erreur\n");
507 // str2 = namealloc("testrigolo2, 2");
508 // // str3 = beg_changeName(str,str2,"i",2,1);
509 // if (str3)
510 // printf("%s#\n",str3);
511 // else
512 // printf("erreur\n");
513 // str2 = namealloc("testrigolo1, 3");
514 // // str3 = beg_changeName(str,str2,"i",3,1);
515 // if (str3)
516 // printf("%s#\n",str3);
517 // else
518 // printf("erreur\n");
519 // str2 = namealloc("testrigolo2, 4");
520 // // str3 = beg_changeName(str,str2,"i",4,1);
521 // if (str3)
522 // printf("%s#\n",str3);
523 // else
524 // printf("erreur\n");
525 // str2 = namealloc("testrigolo2, 5");
526 // // str3 = beg_changeName(str,str2,"i",5,1);
527 // if (str3)
528 // printf("%s#\n",str3);
529 // else
530 // printf("erreur\n");
531 // //}}}
532 case 6 : // test -6- generation de beh + driver vectoriel
533 //{{{
534 beg_def_befig("testchip");
535 // test of por
536 beg_def_por ("tet(1)",'I');
537 beg_def_por ("s" ,'O');
538 beg_def_por ("a" ,'I');
539 beg_def_por ("b(8:0)",'O');
540 beg_def_por ("t(0:4)",'O');
541 beg_def_por ("z(5:2)",'O');
542 beg_def_por ("y(7:0)",'O');
543
544 // test of assertion
545 beg_assertion("ck and ck'event" ,"horloge stable",'W',"horloge1");
546 beg_assertion("ck and ck'stable" ,"horloge stable",'W',"horloge2");
547 beg_assertion("ck and not ck'stable(23)" ,"horloge stable",'W',"horloge3");
548 beg_assertion("ck and ck'event and a" ,"horloge stable",'W',"horloge4");
549 beg_assertion("a" ,"horloge stable",'W',"horloge5");
550
551 // test of signal
552 beg_def_sig ("b(8)" ,"r and tet(1)" ,156);
553 beg_def_sig ("b(2:0)" ,"0b 011" ,156);
554 beg_def_sig ("b(5:3)" ,"0b 101" ,156);
555 beg_def_sig ("t(3:4)" ,"c(2:1)" ,156);
556 beg_def_sig ("t(0:2)" ,"c(3:1)" ,156);
557 beg_def_sig ("e(4)" ,"c(4)" ,156);
558 beg_def_sig ("k" ,"c(4)" ,156);
559 beg_def_sig ("c(3:1)" ,"(a and r) & '0' & tet(1)" ,254);
560
561 // test of multiplexer
562 beg_def_mux ("u" ,"ab(5:4)" ,"0b 11" ,"f and e(4)" ,26);
563 beg_def_mux ("u" ,0 ,"0b 01" ,"c(3) and e(4)",27);
564 beg_def_mux ("u" ,0 ,"0b 10" ,"c(3)" ,23);
565
566 beg_def_mux ("x(5:4)" ,"ab(5:4)" ,"0b 01" ,"d(4) & e(4)" ,29);
567 beg_def_mux ("x(5:4)" ,"ab(5:4)" ,"0b 11" ,"c(3) & e(4)" ,27);
568 beg_def_mux ("x(5:4)" ,"ab(5:4)" ,"default" ,"b(4) & e(4)" ,28);
569
570 // test of process
571 beg_def_process("r" ,"not ck and ck'event and cm" ,"c(3) and e(4)",26,BEG_REG);
572
573 beg_def_process("r2" ,"cm" ,"c(3) and e(4)",26,BEG_REG);
574 beg_def_process("r2" ,"not cm" ,"c(3) and e(4)",26,BEG_REG|BEG_PRE);
575
576 beg_def_process("r3(2)" ,"cm" ,"c(3) and e(4)",26,BEG_REG);
577 beg_def_process("r3(2)" ,"not cm" ,"c(3) and e(4)",26,BEG_REG);
578
579 beg_def_process("q(2:0)" ,"ck and ck'event and cm" ,"c(3)&r&r" ,26,BEG_REG);
580 beg_def_process("q(2:0)" ,"ck and ck'event and not cm" ,"c(3)&r&r" ,26,BEG_REG);
581
582 beg_def_process("s" ,"ck" ,"c(3) and e(4)",26,BEG_BUS);
583 beg_def_process("s" ,"d(2:4)" ,"c(3) and e(4)",26,BEG_BUS|BEG_PRE);
584
585
586 beg_def_process("y(3:0)" ,"not d(2:4) & c(3)","c(3:0)" ,23,BEG_BUS);
587 beg_def_process("y(7:6)" ,"not d(2:4) & c(3)","c(4) & e(4)" ,23,BEG_BUS);
588 beg_def_process("y(5:4)" ,"not (a) & a" ,"c(3) & e(4)" ,24,BEG_BUS);
589 beg_def_process("y(5:4)" ,"a & not a" ,"b(4) & e(4)" ,25,BEG_BUS);
590 beg_def_process("y(5:4)" ,"^2 a" ,"d(4) & e(4)" ,26,BEG_BUS);
591
592 // test of preconditionned bus
593 beg_def_process("z(5:4)" ,"not (a) & a" ,"c(3) & e(4)" ,27,BEG_BUS|BEG_PRE);
594 beg_def_process("z(5:4)" ,"f & not a" ,"b(4) & e(4)" ,28,BEG_BUS|BEG_PRE);
595 beg_def_process("z(5:4)" ,"^2 a" ,"d(4) & e(4)" ,29,BEG_BUS|BEG_PRE);
596
597 // test of loop
598 beg_def_loop ("n(i)" ,"com(i)","g(i)" ,"i(0:8)" ,33,0);
599 beg_def_loop ("n(i)" ,"m(i)" ,"g(i)" ,"i(0:8)" ,33,0);
600 beg_def_loop ("n(i)" ,"g(i)" ,"m(i)" ,"i(0:8)" ,33,0);
601
602 // test of mixed loop and non loop
603 beg_def_process("nn(9)" ,"g(4)" ,"m(4)" ,33,BEG_REG);
604 beg_def_loop ("nn(9)" ,"ck and ck'event and not com(j)","d(j)","j(0:8)",33,BEG_REG);
605 beg_def_process("nn(9)" ,"g(4)" ,"m(4)" ,33,BEG_REG);
606
607 // test of mulitple loop
608 beg_def_loop ("m(i)" ,"ck and ck'event and com(i)" ,"g(i)","i(0:8)",33,BEG_REG);
609 beg_def_loop ("m(i)" ,"ck and ck'event and not com(i)","d(i)","i(0:8)",33,BEG_REG);
610 beg_def_loop ("m(j)" ,"ck and ck'event and not com(j)","d(j)","j(0:8)",33,BEG_REG);
611 beg_def_process("m(9)" ,"ck and ck'event and not com(9)","d(9)",33,BEG_REG);
612
613 // test of single conditionned by loop
614 beg_def_loop ("h" ,"ck and ck'event and not com(j)","d(j)","j(0:8)",33,BEG_REG);
615
616 // test of vector conditionned by loop
617 beg_def_loop ("nm(9:5)" ,"not com(j)","nm(9:5)" ,"j(0:8)" ,33,0);
618
619 // test of biloop
620 beg_def_biloop ("o(j+8*i)" ,"ck and ck'event and not com(j)","d(i)","i(9:6)","j(8:0)",33,BEG_REG);
621
622 // test of loop detection
623 beg_def_process("ld(2)" ,"ck and ck'event and g(3)","m(2)" ,33,BEG_REG);
624 beg_def_process("ld(3)" ,"ck and ck'event and g(4)","m(3)" ,33,BEG_REG);
625 beg_def_process("ld(4)" ,"ck and ck'event and g(5)","m(4)" ,36,BEG_REG);
626 beg_def_process("ld(5)" ,"ck and ck'event and g(6)","m(5)" ,33,BEG_REG);
627
628 beg_def_process("lv(2)" ,"ck and ck'event" ,"m(2)" ,33,BEG_REG);
629 beg_def_process("lv(3)" ,"ck and ck'event" ,"m(3)" ,33,BEG_REG);
630 beg_def_process("lv(4)" ,"ck and ck'event" ,"m(4)" ,36,BEG_REG);
631
632 beg_def_process("lv(5)" ,"toto(3) and toto(5)" ,"m(5)" ,33,BEG_REG);
633 beg_def_process("lv(5)" ,"toto(4) and toto(6)" ,"m(5)" ,33,BEG_REG);
634 beg_def_process("lv(5)" ,"toto(5) and toto(7)" ,"m(5)" ,33,BEG_REG);
635 beg_def_process("lv(5)" ,"toto(6) and toto(8)" ,"m(5)" ,33,BEG_REG);
636
637 beg_def_process("lvb(5)" ,"toto(3) and toto(5)" ,"m(5)" ,33,BEG_REG);
638 beg_def_process("lvb(5)" ,"toto(4) and toto(6)" ,"m(5)" ,33,BEG_REG);
639
640 beg_def_process("lvb(6)" ,"toto(3) and toto(5)" ,"m(6)" ,33,BEG_REG);
641 beg_def_process("lvb(6)" ,"toto(4) and toto(6)" ,"m(6)" ,33,BEG_REG);
642
643
644 befig = beg_get_befig(0);
645
646 beg_def_befig ("testeat");
647 beg_def_por ("y(7:0)",'O');
648 beg_def_por ("s" ,'O');
649 beg_def_por ("se 1" ,'O');
650 beg_def_por ("se 2" ,'O');
651
652 //obj = beg_getObjByName(befig,namealloc("lv"),str);
653 //printf("test getObjByName %s %d:%d\n",beg_getName(obj),beg_getLeft(obj),
654 // beg_getRight(obj));
655
656 beg_eat_figure (befig);
657
658 beg_sort ();
659 beg_compact ();
660
661 befig = beg_get_befig (0);
662 savebefig (befig,0);
663
664 dotest ();
665 //}}}
666 break;
667 case 7 : // perform addacu test
668 addaccutest();
669 break;
670
671 case 8 : // perform amd test
672 amdtest();
673 break;
674 case 9 : // perform addacu test
675 //{{{
676 beg_def_befig ("biloop");
677
678 //beg_def_por ("m(0:3)" ,'I');
679 //beg_def_por ("b(0:3)" ,'I');
680
681
682 //beg_def_process ("m(0)" ,"b(0)" ,"0b1" ,0,BEG_REG);
683 beg_def_loop ("m(i)" ,"c(i)" ,"0b1" ,"i(0:7)",33,BEG_REG);
684
685 //beg_def_process ("m(1)" ,"b(1)" ,"0b1" ,0,BEG_REG);
686 beg_def_loop ("m(i+8)" ,"c(i+8)" ,"0b1" ,"i(0:7)",33,BEG_REG);
687
688 //beg_def_process ("m(2)" ,"b(2)" ,"0b1" ,0,BEG_REG);
689 beg_def_loop ("m(i+16)" ,"c(i+16)" ,"0b1" ,"i(0:7)",33,BEG_REG);
690
691 //beg_def_process ("m(3)" ,"b(3)" ,"0b1" ,0,BEG_REG);
692 beg_def_loop ("m(i+24)" ,"c(i+24)" ,"0b1" ,"i(0:7)",33,BEG_REG);
693
694 beg_sort();
695 beg_compact();
696
697 befig = beg_get_befig (0);
698 savebefig (befig,0);
699
700 //}}}
701 break;
702 case 10 :
703 //{{{
704 beg_testCalcRange();
705 //}}}
706 break;
707 case 11 :
708 //{{{
709 {
710 #ifdef size
711 #undef size
712 #endif
713 #define size 128
714 int i,j,l;
715 char buf[10][1024];
716 befig_list *fig[size];
717
718 for (l = 0; l < size; l ++)
719 {
720 sprintf(buf[3],"tmp_%d",l);
721 beg_def_befig(buf[3]);
722 sprintf(buf[4],"blt(%d:%d)",3+4*l,4*l);
723 beg_def_por(buf[4],'O');
724 for (i = 0; i < 1024; i ++)
725 for (j = 0; j < 4; j ++)
726 {
727 sprintf(buf[0],"blt(%d)",j+4*l);
728 sprintf(buf[1],"lwl(%d)=0b1 and mem(%d)=0b0",-i+1023,-i+j*1024+4096*l+1023);
729 sprintf(buf[2],"lwl(%d)=0b1 and mem(%d)=0b1",-i+1023,-i+j*1024+4096*l+1023);
730
731 beg_def_process (buf[0] ,buf[1],"0b1",0,BEG_REG);
732 beg_def_process (buf[0] ,buf[2],"0b0",0,BEG_REG | BEG_PRE);
733 }
734 beg_sort();
735 beg_compact();
736 fig[l] = beg_get_befig (0);
737 savebefig(fig[l],0);
738 }
739
740 beg_def_befig("testEatBeforeCompact");
741 for (l = 0; l < size; l ++)
742 beg_eat_figure(fig[size-1 - l]);
743
744 befig = beg_get_befig (0);
745 savebefig (befig,0);
746 befig->NAME = "testCompact";
747 beg_sort();
748 beg_compact();
749 befig = beg_get_befig (0);
750 savebefig (befig,0);
751 }
752 //}}}
753 break;
754 case 12 :
755 //{{{
756 {
757 int i,j;
758 #ifdef size
759 #undef size
760 #endif
761 #define size 6
762 char buf[3][1024];
763 befig_list *fig[size];
764
765
766 beg_def_befig(namealloc("testcompactbiabl"));
767 beg_def_por("testpor(0:11)",'I');
768
769 for (j = 0; j < size; j ++)
770 {
771 sprintf(buf[2],"tmp_%d",j);
772 beg_def_befig(buf[2]);
773 for (i = 0; i < 128; i ++)
774 {
775 sprintf(buf[0],"dat(%d)=0b0",i);
776 sprintf(buf[1],
777 "multi_spl9bs_saenb(%d)=0b1"
778 " and "
779 "multi_spl9bs_blfi(%d)=0b0"
780 ,i*2+j*256 ,i+j*128);
781
782 beg_def_process (buf[0] ,buf[1],"0b0",0,BEG_REG);
783 }
784 beg_sort();
785 beg_compact();
786 fig[j] = beg_get_befig(0);
787 }
788
789 beg_def_befig(namealloc("testcompactbiabl"));
790
791 for (j = 0; j < size; j ++)
792 beg_eat_figure(fig[/*size-1 - */j]);
793
794 beg_sort();
795 beg_compact();
796 befig = beg_get_befig (0);
797 savebefig(befig,0);
798 }
799 //}}}
800 break;
801 case 13 :
802 conflicttest();
803 break;
804 case 14 :
805 beg_def_befig ("testifendif");
806 beg_def_process("z" ,"not(a)" ,"c(3)" ,0,BEG_BUS);
807 beg_def_process("z" ,"a" ,"c(4)" ,0,BEG_BUS|BEG_PRE);
808 befig = beg_get_befig (0);
809 savebefig(befig,0);
810 break;
811 case 15 :
812 beg_def_befig ("edge_pb");
813 beg_def_process("z" ,"a and a'event and i" ,"'1'",0 ,BEG_REG);
814 beg_def_process("z" ,"a and a'event and not i" ,"'0'",0,BEG_REG);
815 befig = beg_get_befig (0);
816 savebefig(befig,0);
817 break;
818 case 16 :
819 /*{{{ */
820 list = NULL;
821 for (i = 0; i < 4; i ++)
822 {
823 sprintf(fig,"por_pb_col%d",i);
824 beg_def_befig (namealloc(fig));
825
826 sprintf(sig,"lblt(%d)",i);
827 beg_def_por (sig,'B');
828 sprintf(nsig,"lblf(%d)",i);
829 beg_def_por (nsig,'B');
830 for (j = 0; j < 8; j++)
831 {
832 sprintf(cmd,"com(%d) and %s and not %s",j,sig,nsig);
833 sprintf(mem,"mem(%d)",j);
834 beg_def_process(mem,cmd,"'1'",0,BEG_REG);
835
836 sprintf(cmd,"com(%d) and %s and not %s",j,nsig,sig);
837 beg_def_process(mem,cmd,"'0'",0,BEG_REG|BEG_PRE);
838
839 sprintf(cmd,"com(%d) and %s",j,mem);
840 beg_def_process(sig,cmd,"'1'",0,BEG_REG);
841 beg_def_process(nsig,cmd,"'0'",0,BEG_REG);
842
843 sprintf(cmd,"com(%d) and not %s",j,mem);
844 beg_def_process(sig,cmd,"'0'",0,BEG_REG|BEG_PRE);
845 beg_def_process(nsig,cmd,"'1'",0,BEG_REG|BEG_PRE);
846 }
847
848 beg_sort();
849 beg_compact();
850 befig = beg_get_befig (0);
851 //savebefig(befig,0);
852 list = addchain(list,befig);
853 }
854 /* */
855 beg_def_befig ("por_pb_mux");
856 beg_def_por ("gblt",'B');
857 beg_def_por ("gblf",'B');
858 for (i = 0; i < 4; i ++)
859 {
860
861 sprintf (sig,"lblt(%d)",i);
862 sprintf (cmd,"sel(%d) and wclk",i);
863 beg_def_process (sig,"not prech","'1'",0,BEG_REG);
864 beg_def_process (sig,cmd,"gblt",0,BEG_REG);
865
866 sprintf (sig,"lblf(%d)",i);
867 beg_def_process (sig,"not prech","'1'",0,BEG_REG);
868 beg_def_process (sig,cmd,"gblf",0,BEG_REG);
869
870 sprintf (cmd,"sel(%d) and not wclk",i);
871 sprintf (dat,"lblt(%d)",i);
872 beg_def_process ("gblt",cmd,dat,0,BEG_REG);
873
874 sprintf (dat,"lblf(%d)",i);
875 beg_def_process ("gblf",cmd,dat,0,BEG_REG);
876
877 }
878 beg_sort();
879 beg_compact();
880 befig = beg_get_befig (0);
881 //savebefig(befig,0);
882
883 beg_def_befig ("por_pb_top");
884 for (; list; list = delchain(list,list))
885 beg_eat_figure(list->DATA);
886
887 beg_sort();
888 beg_compact();
889 befig2 = beg_get_befig (0);
890 //savebefig(befig2,0);
891
892 beg_eat_figure (befig);
893 befig = beg_get_befig (0);
894 savebefig(befig,0);
895
896 beg_sort();
897 beg_compact();
898 befig = beg_get_befig (0);
899 savebefig(befig,0);
900 /* */
901 break;
902 /*}}}************************************************************************/
903 case 17 :
904 beg_def_befig ("testCompact");
905 for (i = 0; i < 2; i ++)
906 for (j = 0; j < 3; j ++)
907 {
908 sprintf(sig,"s(%d)",3*i+j);
909 beg_def_process(sig ,"gnd" , "'1'", 0, BEG_REG);
910 sprintf(cmd,"mblt(%d) or blf(%d)",i,j);
911 sprintf(dat,"blf(%d)",i);
912 beg_def_process(sig , cmd , dat, 0, BEG_REG);
913 }
914 beg_sort();
915 beg_compact();
916 beg_compact();
917 befig = beg_get_befig (0);
918 savebefig(befig,0);
919 break;
920 case 18:
921 /*{{{ */
922 // bug concerning hasardous loop given by driver
923 //
924 /*-------------------------*/
925 printf("Phase 1\n");
926 printf(" Constructing the Main figure");
927 fflush(stdout);
928
929 mainfig = namealloc("testloop");
930
931 beg_def_befig (mainfig);
932 for (k = 0; k < 16; k ++)
933 for (j = 0; j < 32; j ++)
934 for (i = 0; i < 128; i ++)
935 {
936 sprintf(sig,"mblf(%d)",j+k*32);
937 sprintf(cmd,"wl(%d)",i+k*128);
938 beg_def_process(sig, cmd, "'0'", i+25 , BEG_REG);
939 sprintf(cmd,"mem(%d)",i+j*128+k*4096);
940 beg_def_process(sig, cmd, "'0'", i+25 , BEG_REG|BEG_PRE);
941 }
942 time(&cur);ela=cur-bef;bef=cur;printhour(ela);
943
944 printf(" Sort");
945 beg_sort();
946 time(&cur);ela=cur-bef;bef=cur;printhour(ela);
947
948 for (k = 0; k < 2; k ++)
949 {
950 printf(" Compact n°%d",k);
951 beg_compact();
952 time(&cur);ela=cur-bef;bef=cur;printhour(ela);
953 }
954
955 befig = beg_get_befig (0);
956
957 /*-------------------------*/
958 printf("Phase 2\n");
959
960 beg_def_befig (namealloc("int_fig"));
961
962 for (k = 0; k < 16; k ++)
963 {
964 sprintf(fig,"int_fign%d",k);
965 printf(" building %s\n",fig);
966
967 beg_def_befig (namealloc(fig));
968 for (j = 0; j < 8; j ++)
969 for (i = 0; i < 4; i ++)
970 {
971 sprintf(sig,"mblf(%d)",i+j*4+k*32);
972 sprintf(cmd,"not b(%d)",k);
973 beg_def_process(sig, cmd, "'0'", 0, BEG_REG);
974 sprintf(cmd,"b(%d)",k);
975 beg_def_process(sig, cmd, "'0'", 0, BEG_REG|BEG_PRE);
976 sprintf(cmd,"(not mblt(%d) or mblf(%d) and (not mblf(%d) or mblt(%d))) and ((iBLF(%d) and not iBLT(%d)) or (iBLT(%d) and not iBLF(%d))) and LSEL(%d) ",
977 i+j*4+k*32,i+j*4+k*32,i+j*4+k*32,i+j*4+k*32,j,j,j,j,i+k*4);
978 beg_def_process(sig, cmd, "'0'", 0, BEG_REG);
979 }
980
981 printf(" Sort");
982 beg_sort();
983 time(&cur);ela=cur-bef;bef=cur;printhour(ela);
984
985 for (j = 0; j < 3; j ++)
986 {
987 printf(" Compact %d-n°%d",k,j);
988 beg_compact();
989 time(&cur);ela=cur-bef;bef=cur;printhour(ela);
990 }
991
992 befig = beg_get_befig(0);
993 beg_def_befig (namealloc("int_fig"));
994
995 printf(" eat figure");
996 beg_eat_figure (befig);
997 time(&cur);ela=cur-bef;bef=cur;printhour(ela);
998 }
999
1000 /*-------------------------*/
1001 printf("Phase 3\n");
1002 printf(" Sort");
1003 beg_sort();
1004 time(&cur);ela=cur-bef;bef=cur;printhour(ela);
1005
1006 for (k = 0; k < 3; k ++)
1007 {
1008 printf(" Compact n°%d",k);
1009 beg_compact();
1010 time(&cur);ela=cur-bef;bef=cur;printhour(ela);
1011 }
1012
1013 befig = beg_get_befig (0);
1014
1015 /*-------------------------*/
1016 printf("Phase 4\n");
1017
1018 printf(" eating figure");
1019 beg_def_befig (mainfig);
1020 befig = beg_get_befig(0);
1021
1022 beg_def_befig(namealloc("int_fig"));
1023 beg_eat_figure(befig);
1024 time(&cur);ela=cur-bef;bef=cur;printhour(ela);
1025
1026 printf(" Sort");
1027 beg_sort();
1028 time(&cur);ela=cur-bef;bef=cur;printhour(ela);
1029
1030 for (k = 0; k < 1; k ++)
1031 {
1032 printf(" Compact n°%d",k);
1033 beg_compact();
1034 time(&cur);ela=cur-bef;bef=cur;printhour(ela);
1035 }
1036
1037 befig = beg_get_befig (0);
1038 printf(" Dump");
1039 savebefig(befig,0);
1040 time(&cur);ela=cur-bef;bef=cur;printhour(ela);
1041
1042 time(&cur);
1043 printf("total time:");
1044 printhour(cur-beg);
1045 printf("\n");
1046 }
1047 /*}}}************************************************************************/
1048
1049 return EXIT_SUCCESS;
1050 }