1 | /* |
---|
2 | |
---|
3 | Copyright (c) 1992, 1993 |
---|
4 | Regents of the University of California |
---|
5 | All rights reserved. |
---|
6 | |
---|
7 | Use and copying of this software and preparation of derivative works |
---|
8 | based upon this software are permitted. However, any distribution of |
---|
9 | this software or derivative works must include the above copyright |
---|
10 | notice. |
---|
11 | |
---|
12 | This software is made available AS IS, and neither the Electronics |
---|
13 | Research Laboratory or the Universify of California make any |
---|
14 | warranty about the software, its performance or its conformity to |
---|
15 | any specification. |
---|
16 | |
---|
17 | Author: Szu-Tsung Cheng, stcheng@ic.Berkeley.EDU |
---|
18 | 10/92 |
---|
19 | 10/93 |
---|
20 | |
---|
21 | $Header: /projects/development/hsv/CVSRepository/vl2mv/src/parser/vl_latch.c,v 1.2 2009/03/09 20:25:58 fabio Exp $ |
---|
22 | |
---|
23 | |
---|
24 | */ |
---|
25 | |
---|
26 | #include <stdio.h> |
---|
27 | #include <math.h> |
---|
28 | #include "util.h" |
---|
29 | #include "st.h" |
---|
30 | #include "array.h" |
---|
31 | #include "list.h" |
---|
32 | #include "set.h" |
---|
33 | #include "vl_types.h" |
---|
34 | #include "vl_defs.h" |
---|
35 | #include "vlr_int.h" |
---|
36 | #include "vl_fg_defs.h" |
---|
37 | #include "vl_create.h" |
---|
38 | #include "vl_write.h" |
---|
39 | #include "vl_write_util.h" |
---|
40 | #include "vl_vardecl.h" |
---|
41 | #include "vl_mux.h" |
---|
42 | #include "verilog.h" |
---|
43 | |
---|
44 | extern int dumpSyncCkt; |
---|
45 | extern int set_notation; |
---|
46 | extern int smartEvent; |
---|
47 | extern int implicitClocking; |
---|
48 | extern vl_desc *mod_list; |
---|
49 | |
---|
50 | extern char *sync_assign(); |
---|
51 | |
---|
52 | static void check_comb_reduction ARGS((vl_id_range *id_sym)); |
---|
53 | |
---|
54 | |
---|
55 | void instantiate_mvar_latch(FILE *file, |
---|
56 | int non_block_var, |
---|
57 | int mark_sel_var, int lo, int hi, |
---|
58 | vl_id_range *id_sym, |
---|
59 | vl_id_range *orig_id_sym, |
---|
60 | var_info *lhsvar, |
---|
61 | char *lname) |
---|
62 | { |
---|
63 | int idx, idx_lo, idx_hi; |
---|
64 | lsList domain; |
---|
65 | lsGen enum_gen; |
---|
66 | lsHandle enum_handle; |
---|
67 | vl_enumerator *enum_elt; |
---|
68 | vl_id_range *temp_id_sym; |
---|
69 | vl_term *feed_back_array; |
---|
70 | int old_id_type; |
---|
71 | st_table *sensitiveList; |
---|
72 | int dummy; |
---|
73 | |
---|
74 | old_id_type = orig_id_sym->flags; |
---|
75 | domain = id_sym->id_type->specifier->u.enum_type->domain_list; |
---|
76 | if (vl_currentModule->combVar_st) { |
---|
77 | if (st_lookup(vl_currentModule->combVar_st, orig_id_sym->name, |
---|
78 | (char**)&temp_id_sym) && |
---|
79 | !st_lookup(vl_currentModule->seqVar_st, orig_id_sym->name, |
---|
80 | (char**)&temp_id_sym)) { |
---|
81 | |
---|
82 | orig_id_sym->flags &= ~RegVar; |
---|
83 | } else { |
---|
84 | check_comb_reduction(orig_id_sym); |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | sensitiveList = NIL(st_table); |
---|
91 | if(!id_sym->range) { |
---|
92 | if (sensitiveList && (orig_id_sym->flags & RegVar)) { |
---|
93 | |
---|
94 | vl_term *feed_back; |
---|
95 | char buf[MAXSTRLEN]; |
---|
96 | |
---|
97 | sprintf(buf, "%s%s", id_sym->name, PIN_FEEDBACK); |
---|
98 | feed_back = create_rename_term(id_sym, buf, 0, -1); |
---|
99 | feed_back->term_type = id_sym->id_type; |
---|
100 | instantiate_mux(file, |
---|
101 | lhsvar->current_terminal, feed_back, |
---|
102 | sensitive_control(file, sensitiveList), |
---|
103 | create_rename_term(feed_back->name, lname, 0, -1)); |
---|
104 | fprintf(file, "%s %s %s\n", |
---|
105 | ".latch", |
---|
106 | non_block_var? |
---|
107 | sel_var(strip_char(lname,SEP_LATCH)): |
---|
108 | strip_char(lname,SEP_LATCH), |
---|
109 | feed_back->name->name); |
---|
110 | vl_free_term(feed_back); |
---|
111 | } else { |
---|
112 | |
---|
113 | |
---|
114 | |
---|
115 | if (!implicitClocking && orig_id_sym->edge_trigger) { |
---|
116 | vl_term *feed_back, *new_terminal; |
---|
117 | feed_back = vl_create_term(orig_id_sym, 0, -1); |
---|
118 | new_terminal = typed_new_term(orig_id_sym->id_type, |
---|
119 | orig_id_sym->range, 0, -1); |
---|
120 | feed_back->flag |= lhsvar->current_terminal->flag; |
---|
121 | new_terminal->flag |= lhsvar->current_terminal->flag; |
---|
122 | write_mvar_decl(file, new_terminal); |
---|
123 | instantiate_mux(file, lhsvar->current_terminal, feed_back, |
---|
124 | orig_id_sym->edge_trigger, new_terminal); |
---|
125 | lhsvar->current_terminal = new_terminal; |
---|
126 | } |
---|
127 | |
---|
128 | fprintf(file, "%s %s %s", |
---|
129 | (orig_id_sym->flags&RegVar)? |
---|
130 | ".latch":".names", |
---|
131 | lhsvar->current_terminal->name->name, |
---|
132 | non_block_var? |
---|
133 | sel_var(strip_char(lname,SEP_LATCH)): |
---|
134 | strip_char(lname,SEP_LATCH)); |
---|
135 | if (st_lookup(vl_currentModule->quasi_st,lname,(char**)&dummy)) |
---|
136 | fprintf(file, "%s%s", SEP_GATEPIN, PIN_PS); |
---|
137 | fprintf(file, "\n"); |
---|
138 | |
---|
139 | if (!(orig_id_sym->flags&RegVar)) { |
---|
140 | if (set_notation) { |
---|
141 | fprintf(file, "- %s%s\n", |
---|
142 | HSIS_EQUAL, |
---|
143 | lhsvar->current_terminal->name->name); |
---|
144 | } else { |
---|
145 | for (enum_gen=lsStart(domain); |
---|
146 | lsNext(enum_gen, |
---|
147 | (lsGeneric*)&enum_elt,&enum_handle)!= |
---|
148 | LS_NOMORE;) { |
---|
149 | fprintf(file, "%s %s\n", |
---|
150 | enum_elt->name,enum_elt->name); |
---|
151 | } |
---|
152 | lsFinish(enum_gen); |
---|
153 | } |
---|
154 | } else if (non_block_var && mark_sel_var) { |
---|
155 | fprintf(file, ".names %s \n", lname); |
---|
156 | fprintf(file, "%s\n", strip_char(lname,SEP_SEL_VAR)); |
---|
157 | for (enum_gen=lsStart(domain); |
---|
158 | lsNext(enum_gen, |
---|
159 | (lsGeneric*)&enum_elt,&enum_handle)!= |
---|
160 | LS_NOMORE;) { |
---|
161 | fprintf(file, "%s %s\n", |
---|
162 | enum_elt->name, enum_elt->name); |
---|
163 | } |
---|
164 | lsFinish(enum_gen); |
---|
165 | } |
---|
166 | } |
---|
167 | } else { |
---|
168 | char buf[MAXSTRLEN]; |
---|
169 | |
---|
170 | idx_lo = vl_eval_expr(id_sym->range->left); |
---|
171 | if (id_sym->range->right) |
---|
172 | idx_hi = vl_eval_expr(id_sym->range->right); |
---|
173 | else |
---|
174 | idx_hi = idx_lo; |
---|
175 | |
---|
176 | sprintf(buf, "%s%s", id_sym->name, PIN_FEEDBACK); |
---|
177 | feed_back_array = create_rename_term(id_sym, buf, 0, -1); |
---|
178 | for (idx=idx_lo; idx<=idx_hi; idx++) { |
---|
179 | if (sensitiveList && (orig_id_sym->flags & RegVar)) { |
---|
180 | |
---|
181 | vl_term *feed_back; |
---|
182 | |
---|
183 | sprintf(buf, "%s%s%d%s", |
---|
184 | feed_back_array->name->name, |
---|
185 | SEP_LARRAY, idx, SEP_RARRAY); |
---|
186 | feed_back = create_rename_term(feed_back_array->name, |
---|
187 | buf, 0, -1); |
---|
188 | sprintf(buf, "%s%s%d%s", lname, SEP_LARRAY, idx, SEP_RARRAY); |
---|
189 | instantiate_mux(file, |
---|
190 | lhsvar->current_terminal, feed_back, |
---|
191 | sensitive_control(file, sensitiveList), |
---|
192 | create_rename_term(feed_back_array->name, buf, |
---|
193 | 0, -1)); |
---|
194 | fprintf(file, "%s %s%s%d%s %s\n", |
---|
195 | ".latch", |
---|
196 | non_block_var? |
---|
197 | sel_var(strip_char(lname,SEP_LATCH)): |
---|
198 | strip_char(lname,SEP_LATCH), |
---|
199 | SEP_LARRAY, idx, SEP_RARRAY, |
---|
200 | feed_back->name->name); |
---|
201 | vl_free_term(feed_back); |
---|
202 | } else { |
---|
203 | |
---|
204 | |
---|
205 | |
---|
206 | if (!implicitClocking && orig_id_sym->edge_trigger) { |
---|
207 | vl_term *feed_back, *new_terminal; |
---|
208 | feed_back = vl_create_term(orig_id_sym, 0, -1); |
---|
209 | new_terminal = typed_new_term(orig_id_sym->id_type, |
---|
210 | orig_id_sym->range, 0, -1); |
---|
211 | instantiate_mux(file, lhsvar->current_terminal, feed_back, |
---|
212 | orig_id_sym->edge_trigger, new_terminal); |
---|
213 | lhsvar->current_terminal = new_terminal; |
---|
214 | } |
---|
215 | |
---|
216 | fprintf(file, "%s %s%s%d%s %s%s%d%s", |
---|
217 | (orig_id_sym->flags&RegVar)? |
---|
218 | ".latch":".names", |
---|
219 | lhsvar->current_terminal->name->name, |
---|
220 | SEP_LARRAY, idx, SEP_RARRAY, |
---|
221 | non_block_var? |
---|
222 | sel_var(strip_char(lname,SEP_LATCH)): |
---|
223 | strip_char(lname,SEP_LATCH), |
---|
224 | SEP_LARRAY, idx, SEP_RARRAY); |
---|
225 | if (st_lookup(vl_currentModule->quasi_st, |
---|
226 | lname,(char**)&dummy)) |
---|
227 | fprintf(file, "%s%s", SEP_GATEPIN, PIN_PS); |
---|
228 | fprintf(file, "\n"); |
---|
229 | if (!(orig_id_sym->flags&RegVar)) { |
---|
230 | if (set_notation) { |
---|
231 | fprintf(file, "- %s%s%s%d%s\n", |
---|
232 | HSIS_EQUAL, |
---|
233 | lhsvar->current_terminal->name->name, |
---|
234 | SEP_LARRAY, idx, SEP_RARRAY); |
---|
235 | } else { |
---|
236 | for (enum_gen=lsStart(domain); |
---|
237 | lsNext(enum_gen,(lsGeneric*)&enum_elt,&enum_handle)!= |
---|
238 | LS_NOMORE;) { |
---|
239 | fprintf(file, "%s %s\n", |
---|
240 | enum_elt->name, enum_elt->name); |
---|
241 | } |
---|
242 | lsFinish(enum_gen); |
---|
243 | } |
---|
244 | } else if (non_block_var && mark_sel_var) { |
---|
245 | fprintf(file, ".names %s%s%d%s ", |
---|
246 | lname, |
---|
247 | SEP_LARRAY, idx, SEP_RARRAY); |
---|
248 | fprintf(file, "%s%s%d%s\n", |
---|
249 | strip_char(lname,SEP_SEL_VAR), |
---|
250 | SEP_LARRAY, idx, SEP_RARRAY); |
---|
251 | for (enum_gen=lsStart(domain); |
---|
252 | lsNext(enum_gen,(lsGeneric*)&enum_elt,&enum_handle)!= |
---|
253 | LS_NOMORE;) { |
---|
254 | fprintf(file, "%s %s\n", |
---|
255 | enum_elt->name, enum_elt->name); |
---|
256 | } |
---|
257 | lsFinish(enum_gen); |
---|
258 | } |
---|
259 | } |
---|
260 | } |
---|
261 | } |
---|
262 | |
---|
263 | orig_id_sym->flags = old_id_type; |
---|
264 | |
---|
265 | |
---|
266 | lo = lo; |
---|
267 | hi = hi; |
---|
268 | } |
---|
269 | |
---|
270 | |
---|
271 | void instantiate_bin_scalar_latch(FILE *file, int non_block_var, |
---|
272 | int mark_sel_var, |
---|
273 | vl_id_range *id_sym, |
---|
274 | vl_id_range *orig_id_sym, |
---|
275 | var_info *lhsvar, char *lname) |
---|
276 | { |
---|
277 | int i; |
---|
278 | int modify_id_flag = 0; |
---|
279 | int idx, idx_lo, idx_hi; |
---|
280 | vl_id_range *temp_id_sym; |
---|
281 | int old_id_type=0; |
---|
282 | vl_term *feed_back_array; |
---|
283 | st_table *sensitiveList; |
---|
284 | int dummy; |
---|
285 | |
---|
286 | if (vl_currentModule->combVar_st) { |
---|
287 | if (st_lookup(vl_currentModule->combVar_st, orig_id_sym->name, |
---|
288 | (char**)&temp_id_sym) && |
---|
289 | !st_lookup(vl_currentModule->seqVar_st, orig_id_sym->name, |
---|
290 | (char**)&temp_id_sym)) { |
---|
291 | modify_id_flag = 1; |
---|
292 | old_id_type = orig_id_sym->flags; |
---|
293 | orig_id_sym->flags &= ~RegVar; |
---|
294 | } else { |
---|
295 | check_comb_reduction(orig_id_sym); |
---|
296 | } |
---|
297 | } |
---|
298 | |
---|
299 | |
---|
300 | |
---|
301 | sensitiveList = NIL(st_table); |
---|
302 | if (!id_sym->range) { |
---|
303 | if (sensitiveList && (orig_id_sym->flags & RegVar)) { |
---|
304 | |
---|
305 | vl_term *feed_back; |
---|
306 | char buf[MAXSTRLEN]; |
---|
307 | |
---|
308 | sprintf(buf, "%s", id_sym->name); |
---|
309 | feed_back = create_rename_term(id_sym, buf, 0, -1); |
---|
310 | instantiate_mux(file, |
---|
311 | lhsvar->current_terminal, feed_back, |
---|
312 | sensitive_control(file, sensitiveList), |
---|
313 | create_rename_term(feed_back->name, lname, 0, -1)); |
---|
314 | fprintf(file, "%s %s %s\n", |
---|
315 | ".latch", |
---|
316 | non_block_var? |
---|
317 | sel_var(strip_char(lname,SEP_LATCH)): |
---|
318 | strip_char(lname,SEP_LATCH), |
---|
319 | feed_back->name->name); |
---|
320 | vl_free_term(feed_back); |
---|
321 | } else { |
---|
322 | |
---|
323 | |
---|
324 | |
---|
325 | if (!implicitClocking && orig_id_sym->edge_trigger) { |
---|
326 | vl_term *feed_back, *new_terminal; |
---|
327 | feed_back = vl_create_term(orig_id_sym, 0, -1); |
---|
328 | new_terminal = typed_new_term(orig_id_sym->id_type, |
---|
329 | orig_id_sym->range, 0, -1); |
---|
330 | instantiate_mux(file, lhsvar->current_terminal, feed_back, |
---|
331 | orig_id_sym->edge_trigger, new_terminal); |
---|
332 | lhsvar->current_terminal = new_terminal; |
---|
333 | } |
---|
334 | |
---|
335 | if (id_sym->flags & EventVar) { |
---|
336 | vl_write_bit_connect(file, |
---|
337 | lhsvar->current_terminal->name->name, |
---|
338 | lname, 0); |
---|
339 | if (!smartEvent) |
---|
340 | fprintf(file, ".latch %s %s%s%s\n", |
---|
341 | lname, lname, SEP_GATEPIN, PIN_EVENT); |
---|
342 | } else { |
---|
343 | fprintf(file, "%s %s %s", |
---|
344 | (orig_id_sym->flags&RegVar)? |
---|
345 | ".latch":".names", |
---|
346 | lhsvar->current_terminal->name->name, |
---|
347 | non_block_var? |
---|
348 | sel_var(strip_char(lname,SEP_LATCH)): |
---|
349 | strip_char(lname,SEP_LATCH)); |
---|
350 | if (st_lookup(vl_currentModule->quasi_st, |
---|
351 | lname, (char**)&dummy)) |
---|
352 | fprintf(file, "%s%s", SEP_GATEPIN, PIN_PS); |
---|
353 | fprintf(file, "\n"); |
---|
354 | } |
---|
355 | |
---|
356 | if (!(orig_id_sym->flags&RegVar)) { |
---|
357 | fprintf(file, "1 1\n0 0\n"); |
---|
358 | } else if (non_block_var && mark_sel_var) { |
---|
359 | fprintf(file, ".names %s ", lname); |
---|
360 | fprintf(file, "%s\n", strip_char(lname,SEP_SEL_VAR)); |
---|
361 | for (i=0; i<=1; i++) { |
---|
362 | fprintf(file, "%d %d\n", i, i); |
---|
363 | } |
---|
364 | } |
---|
365 | } |
---|
366 | } else { |
---|
367 | char buf[MAXSTRLEN]; |
---|
368 | |
---|
369 | idx_lo = vl_eval_expr(id_sym->range->left); |
---|
370 | if (id_sym->range->right) |
---|
371 | idx_hi = vl_eval_expr(id_sym->range->right); |
---|
372 | else |
---|
373 | idx_hi = idx_lo; |
---|
374 | |
---|
375 | sprintf(buf, "%s%s", id_sym->name, PIN_FEEDBACK); |
---|
376 | feed_back_array = create_rename_term(id_sym, buf, 0, -1); |
---|
377 | for (idx=idx_lo; idx<=idx_hi; idx++) { |
---|
378 | if (sensitiveList && (orig_id_sym->flags & RegVar)) { |
---|
379 | |
---|
380 | vl_term *feed_back; |
---|
381 | |
---|
382 | sprintf(buf, "%s%s%s%d%s", |
---|
383 | feed_back_array->name->name, PIN_FEEDBACK, |
---|
384 | SEP_LARRAY, idx, SEP_RARRAY); |
---|
385 | feed_back = create_rename_term(feed_back_array->name, |
---|
386 | buf, 0, -1); |
---|
387 | sprintf(buf, "%s%s%d%s", lname, SEP_LARRAY, idx, SEP_RARRAY); |
---|
388 | instantiate_mux(file, |
---|
389 | lhsvar->current_terminal, feed_back, |
---|
390 | sensitive_control(file, sensitiveList), |
---|
391 | create_rename_term(feed_back_array->name, buf, |
---|
392 | 0, -1)); |
---|
393 | fprintf(file, "%s %s%s%d%s %s\n", |
---|
394 | ".latch", |
---|
395 | non_block_var? |
---|
396 | sel_var(strip_char(lname,SEP_LATCH)): |
---|
397 | strip_char(lname,SEP_LATCH), |
---|
398 | SEP_LARRAY, idx, SEP_RARRAY, |
---|
399 | feed_back->name->name); |
---|
400 | vl_free_term(feed_back); |
---|
401 | } else { |
---|
402 | |
---|
403 | |
---|
404 | |
---|
405 | if (!implicitClocking && orig_id_sym->edge_trigger) { |
---|
406 | vl_term *feed_back, *new_terminal; |
---|
407 | feed_back = vl_create_term(orig_id_sym, 0, -1); |
---|
408 | new_terminal = typed_new_term(orig_id_sym->id_type, |
---|
409 | orig_id_sym->range, 0, -1); |
---|
410 | instantiate_mux(file, lhsvar->current_terminal, feed_back, |
---|
411 | orig_id_sym->edge_trigger, new_terminal); |
---|
412 | lhsvar->current_terminal = new_terminal; |
---|
413 | } |
---|
414 | |
---|
415 | fprintf(file, "%s %s%s%d%s %s%s%d%s", |
---|
416 | (orig_id_sym->flags&RegVar)? |
---|
417 | ".latch":".names", |
---|
418 | lhsvar->current_terminal->name->name, |
---|
419 | SEP_LARRAY, idx, SEP_RARRAY, |
---|
420 | non_block_var? |
---|
421 | sel_var(strip_char(lname,SEP_LATCH)): |
---|
422 | strip_char(lname,SEP_LATCH), |
---|
423 | SEP_LARRAY, idx, SEP_RARRAY); |
---|
424 | if (st_lookup(vl_currentModule->quasi_st, |
---|
425 | lname,(char**)&dummy)) |
---|
426 | fprintf(file, "%s%s", SEP_GATEPIN, PIN_PS); |
---|
427 | fprintf(file, "\n"); |
---|
428 | if (!(orig_id_sym->flags&RegVar)) { |
---|
429 | fprintf(file, "1 1\n0 0\n"); |
---|
430 | } else if (non_block_var && mark_sel_var) { |
---|
431 | fprintf(file, ".names %s%s%d%s ", |
---|
432 | lname, |
---|
433 | SEP_LARRAY, idx, SEP_RARRAY); |
---|
434 | fprintf(file, "%s%s%d%s\n", |
---|
435 | strip_char(lname,SEP_SEL_VAR), |
---|
436 | SEP_LARRAY, idx, SEP_RARRAY); |
---|
437 | for (i=0; i<=1; i++) { |
---|
438 | fprintf(file, "%d %d\n", i, i); |
---|
439 | } |
---|
440 | } |
---|
441 | } |
---|
442 | } |
---|
443 | } |
---|
444 | |
---|
445 | if (modify_id_flag) |
---|
446 | orig_id_sym->flags = old_id_type; |
---|
447 | } |
---|
448 | |
---|
449 | |
---|
450 | void instantiate_bin_vector_latch(FILE *file, |
---|
451 | int non_block_var, |
---|
452 | int mark_sel_var, |
---|
453 | int lo, int hi, |
---|
454 | vl_id_range *id_sym, |
---|
455 | vl_id_range *orig_id_sym, |
---|
456 | var_info *lhsvar, |
---|
457 | char *lname) |
---|
458 | { |
---|
459 | int i; |
---|
460 | int idx, idx_lo, idx_hi; |
---|
461 | int old_id_type=0; |
---|
462 | vl_id_range *temp_id_sym; |
---|
463 | vl_term *feed_back_array; |
---|
464 | st_table *sensitiveList; |
---|
465 | int need_recover_id_sym=0; |
---|
466 | int dummy; |
---|
467 | extern int combinationalReduction; |
---|
468 | |
---|
469 | if (vl_currentModule->combVar_st) { |
---|
470 | if (st_lookup(vl_currentModule->combVar_st, orig_id_sym->name, |
---|
471 | (char**)&temp_id_sym) && |
---|
472 | !st_lookup(vl_currentModule->seqVar_st, orig_id_sym->name, |
---|
473 | (char**)&temp_id_sym)) { |
---|
474 | old_id_type = orig_id_sym->flags; |
---|
475 | need_recover_id_sym = 1; |
---|
476 | orig_id_sym->flags &= ~RegVar; |
---|
477 | } else { |
---|
478 | check_comb_reduction(orig_id_sym); |
---|
479 | } |
---|
480 | } |
---|
481 | |
---|
482 | if (id_sym->syndrome_expr_list) |
---|
483 | if (lsLength(id_sym->syndrome_expr_list) == 0) |
---|
484 | if (id_sym->rst_syndrome_expr_list) |
---|
485 | if (lsLength(id_sym->rst_syndrome_expr_list) == 0) |
---|
486 | if (combinationalReduction) |
---|
487 | return; |
---|
488 | |
---|
489 | sensitiveList = NIL(st_table); |
---|
490 | |
---|
491 | if (orig_id_sym->flags & RegVar) { |
---|
492 | if (!sensitiveList) { |
---|
493 | |
---|
494 | if (!implicitClocking && orig_id_sym->edge_trigger) { |
---|
495 | vl_term *feed_back, *new_terminal; |
---|
496 | feed_back = vl_create_term(orig_id_sym, lo, hi); |
---|
497 | new_terminal = typed_new_term(orig_id_sym->id_type, |
---|
498 | orig_id_sym->range, lo, hi); |
---|
499 | instantiate_mux(file, lhsvar->current_terminal, |
---|
500 | feed_back, |
---|
501 | orig_id_sym->edge_trigger, |
---|
502 | new_terminal); |
---|
503 | lhsvar->current_terminal = new_terminal; |
---|
504 | } |
---|
505 | } |
---|
506 | } |
---|
507 | for (i=lo; i<=hi; i++) { |
---|
508 | if (!id_sym->range) { |
---|
509 | if (sensitiveList && (orig_id_sym->flags & RegVar)) { |
---|
510 | |
---|
511 | vl_term *feed_back; |
---|
512 | char buf[MAXSTRLEN]; |
---|
513 | |
---|
514 | sprintf(buf, "%s%s", id_sym->name, PIN_FEEDBACK); |
---|
515 | feed_back = create_rename_term(id_sym, buf, lo, hi); |
---|
516 | instantiate_mux(file, |
---|
517 | lhsvar->current_terminal, feed_back, |
---|
518 | sensitive_control(file, sensitiveList), |
---|
519 | create_rename_term(feed_back->name,lname, |
---|
520 | 0,-1)); |
---|
521 | fprintf(file, "%s %s %s\n", |
---|
522 | ".latch", |
---|
523 | non_block_var? |
---|
524 | sel_var(strip_char(lname,SEP_LATCH)): |
---|
525 | strip_char(lname,SEP_LATCH), |
---|
526 | feed_back->name->name); |
---|
527 | vl_free_term(feed_back); |
---|
528 | } else { |
---|
529 | |
---|
530 | fprintf(file, "%s %s%s%d%s %s%s%d%s", |
---|
531 | (orig_id_sym->flags&RegVar)? |
---|
532 | ".latch":".names", |
---|
533 | lhsvar->current_terminal->name->name, |
---|
534 | SEP_LBITSELECT, i, SEP_RBITSELECT, |
---|
535 | non_block_var? |
---|
536 | sel_var(strip_char(lname,SEP_LATCH)): |
---|
537 | strip_char(lname,SEP_LATCH), |
---|
538 | SEP_LBITSELECT, i, SEP_RBITSELECT); |
---|
539 | if (st_lookup(vl_currentModule->quasi_st, |
---|
540 | lname,(char**)&dummy)) |
---|
541 | fprintf(file, "%s%s", SEP_GATEPIN, PIN_PS); |
---|
542 | fprintf(file, "\n"); |
---|
543 | if (!(orig_id_sym->flags&RegVar)) { |
---|
544 | fprintf(file, "1 1\n0 0\n"); |
---|
545 | } else if (non_block_var && mark_sel_var) { |
---|
546 | fprintf(file, ".names %s%s%d%s %s%s%d%s", |
---|
547 | lname, |
---|
548 | SEP_LBITSELECT, i, SEP_RBITSELECT, |
---|
549 | strip_char(lname, SEP_SEL_VAR), |
---|
550 | SEP_LBITSELECT, i, SEP_RBITSELECT); |
---|
551 | fprintf(file, "1 1\n0 0\n"); |
---|
552 | } |
---|
553 | } |
---|
554 | } else { |
---|
555 | char buf[MAXSTRLEN]; |
---|
556 | |
---|
557 | idx_lo = vl_eval_expr(id_sym->range->left); |
---|
558 | if (id_sym->range->right) |
---|
559 | idx_hi = vl_eval_expr(id_sym->range->right); |
---|
560 | else |
---|
561 | idx_hi = idx_lo; |
---|
562 | |
---|
563 | sprintf(buf, "%s%s", id_sym->name, PIN_FEEDBACK); |
---|
564 | feed_back_array = create_rename_term(id_sym, buf, lo, hi); |
---|
565 | for (idx=idx_lo; idx<=idx_hi; idx++) { |
---|
566 | if (sensitiveList && (orig_id_sym->flags & RegVar)) { |
---|
567 | |
---|
568 | vl_term *feed_back; |
---|
569 | char buf[MAXSTRLEN]; |
---|
570 | |
---|
571 | sprintf(buf, "%s%s%d%s", feed_back_array->name->name, |
---|
572 | SEP_LARRAY, idx, SEP_RARRAY); |
---|
573 | feed_back = create_rename_term(feed_back_array->name, |
---|
574 | buf, lo, hi); |
---|
575 | sprintf(buf, "%s%s%d%s", lname, |
---|
576 | SEP_LARRAY, idx, SEP_RARRAY); |
---|
577 | instantiate_mux(file, |
---|
578 | lhsvar->current_terminal, feed_back, |
---|
579 | sensitive_control(file, sensitiveList), |
---|
580 | create_rename_term(feed_back_array->name,buf, |
---|
581 | lo, hi)); |
---|
582 | fprintf(file, "%s %s%s%d%s %s\n", |
---|
583 | ".latch", |
---|
584 | non_block_var? |
---|
585 | sel_var(strip_char(lname,SEP_LATCH)): |
---|
586 | strip_char(lname,SEP_LATCH), |
---|
587 | SEP_LARRAY, idx, SEP_RARRAY, |
---|
588 | feed_back->name->name); |
---|
589 | vl_free_term(feed_back); |
---|
590 | } else { |
---|
591 | |
---|
592 | fprintf(file, |
---|
593 | "%s %s%s%d%s%s%d%s %s%s%d%s%s%d%s", |
---|
594 | (orig_id_sym->flags&RegVar)? |
---|
595 | ".latch":".names", |
---|
596 | lhsvar->current_terminal->name->name, |
---|
597 | SEP_LARRAY, idx, SEP_RARRAY, |
---|
598 | SEP_LBITSELECT, i, SEP_RBITSELECT, |
---|
599 | non_block_var? |
---|
600 | sel_var(strip_char(lname,SEP_LATCH)): |
---|
601 | strip_char(lname,SEP_LATCH), |
---|
602 | SEP_LARRAY, idx, SEP_RARRAY, |
---|
603 | SEP_LBITSELECT, i, SEP_RBITSELECT); |
---|
604 | if (st_lookup(vl_currentModule->quasi_st, |
---|
605 | lname,(char**)&dummy)) |
---|
606 | fprintf(file, "%s%s", SEP_GATEPIN, PIN_PS); |
---|
607 | fprintf(file, "\n"); |
---|
608 | if (!(orig_id_sym->flags&RegVar)) { |
---|
609 | fprintf(file, "1 1\n0 0\n"); |
---|
610 | } else if(non_block_var && mark_sel_var) { |
---|
611 | fprintf(file, |
---|
612 | ".names %s%s%d%s%s%d%s %s%s%d%s%s%d%s\n", |
---|
613 | lname, |
---|
614 | SEP_LARRAY, idx, SEP_RARRAY, |
---|
615 | SEP_LBITSELECT, i, SEP_RBITSELECT, |
---|
616 | strip_char(lname,SEP_SEL_VAR), |
---|
617 | SEP_LARRAY, idx, SEP_RARRAY, |
---|
618 | SEP_LBITSELECT, i, SEP_RBITSELECT); |
---|
619 | fprintf(file, "1 1\n0 0\n"); |
---|
620 | } |
---|
621 | } |
---|
622 | } |
---|
623 | } |
---|
624 | } |
---|
625 | |
---|
626 | if (need_recover_id_sym) |
---|
627 | orig_id_sym->flags = old_id_type; |
---|
628 | } |
---|
629 | |
---|
630 | |
---|
631 | static void check_comb_reduction(vl_id_range *id_sym) |
---|
632 | { |
---|
633 | char *dummy; |
---|
634 | char buf[MAXSTRLEN]; |
---|
635 | |
---|
636 | if (vl_currentModule->combVar_st) { |
---|
637 | if (st_lookup(vl_currentModule->combVar_st, id_sym->name, &dummy) && |
---|
638 | st_lookup(vl_currentModule->seqVar_st, id_sym->name, &dummy)) { |
---|
639 | sprintf(buf, "%s%s", id_sym->name, SEP_QUASI); |
---|
640 | if (!st_lookup(vl_currentModule->sig_st, buf, &dummy)) { |
---|
641 | sprintf(buf, |
---|
642 | "%s:'%s' is touched by both sequential/combinational ", |
---|
643 | vl_currentModule->name->name, |
---|
644 | id_sym->name); |
---|
645 | strcat(buf, "procedurarl blocks,\nhowever, combinational "); |
---|
646 | strcat(buf, "block is not assigning to that variable\n"); |
---|
647 | strcat(buf, "through quasi-assignment. Compilation abort"); |
---|
648 | yylineno = -1; |
---|
649 | compile_error(buf); |
---|
650 | } |
---|
651 | } |
---|
652 | } |
---|
653 | } |
---|
654 | |
---|
655 | |
---|
656 | char *sync_assign() |
---|
657 | { |
---|
658 | static char retval[MAXSTRLEN]; |
---|
659 | |
---|
660 | if (implicitClocking && vl_currentModule->clk && dumpSyncCkt) { |
---|
661 | if (vl_currentModule->clk->type == NegedgeEventExpr) |
---|
662 | sprintf(retval, "%s ( %s )", SMV_IF, |
---|
663 | vl_currentModule->clk->expr->u.name->name); |
---|
664 | else |
---|
665 | sprintf(retval, "%s ( %s%s )", SMV_IF, SMV_NOT, |
---|
666 | vl_currentModule->clk->expr->u.name->name); |
---|
667 | } else { |
---|
668 | sprintf(retval, "%s", SMV_ASSIGN); |
---|
669 | } |
---|
670 | return retval; |
---|
671 | } |
---|