NAPA Compiler V4.50
Author: Yves Leduc, yves.leduc.be@gmail.com
Loading...
Searching...
No Matches
C:/Simulate/Napados/Source/tp.c
Go to the documentation of this file.
1/* *** CHECK TYPES OF NODES ***************************************************************************************************** */
2
3#undef EXTERN
4#define EXTERN extern
5
6#include "./napa.h"
7#include "./proto.h"
8
9
10/* *** In this file: ************************************************************************************************************ */
11
12/* void check_types(void) */
13
14
15/* ****************************************************************************************************************************** */
16
17/* During node determination, the type was determined as fast as possible. Only one clue was used. The type of all nodes have */
18/* been determined and stored in the node structure. */
19
20/* The goal of "check_types" is to check the type consistency of the node definitions. */
21/* This process is done after the determination of the node types. */
22
23/* Types but not the values of the constants are verified during this process. */
24
25
26/* ****************************************************************************************************************************** */
27
28void check_types(void) {
29 long out;
30 long t;
31 char *tg = (char*) NULL;
32 char *nm = (char*) NULL;
33 unsigned long *ml = (unsigned long*) NULL;
34 unsigned long *mf = (unsigned long*) NULL;
35 long kd;
36 long tp;
37 char sgn[2] = {'\0'};
38 char brck[3] = {'\0'};
39 char tok1[STRLENGTH] = {'\0'};
40 char tok2[STRLENGTH] = {'\0'};
41 char tok3[STRLENGTH] = {'\0'};
42 char *str = (char*) NULL;
43
44 for (out = 0L; out < Num_Nodes; out++) {
45
46 str = Node_List[out].value;
47 kd = Node_List[out].kind;
48 tg = Node_List[out].tag;
49 ml = Node_List[out].mline;
50 mf = Node_List[out].mfile;
51 nm = Node_List[out].name1;
52 tp = Node_List[out].type;
53
54 switch (kd) {
55
56 /* ADC, UADC: digital type */
57
58 case ADC_KIND :
59 case UADC_KIND :
60 str = get_sign_and_token(str, sgn, tok1);
61 t = get_type(tok1);
62 if (DIGITAL_DATA_TYPE != t) {
63 print_error_location(tg, ml, mf);
64 (void) fprintf(STDERR, " number of levels <%s> must be digital type\n", tok1);
65 flag_node(out);
66 }
67 str = get_sign_and_token(str, sgn, tok1);
68 t = get_type(tok1);
69 if (ANALOG_DATA_TYPE != t) {
70 print_error_location(tg, ml, mf);
71 (void) fprintf(STDERR, " input <%s> of the converter must be analog type\n", tok1);
72 flag_node(out);
73 }
74 str = get_sign_and_token(str, sgn, tok1);
75 t = get_type(tok1);
76 if (ANALOG_DATA_TYPE != t) {
77 print_error_location(tg, ml, mf);
78 (void) fprintf(STDERR, " reference <%s> of the converter must be analog type\n", tok1);
79 flag_node(out);
80 }
81 break;
82
83 /* ALGEBRA: chameleonic type depending on node input (not variables!) */
84
85 case ALGEBRA_KIND :
86 for (;;) {
87 str = get_sign_and_token(str, sgn, tok1);
88 if (ISEMPTY(tok1)) {
89 break;
90 }
91 if ((0 == strcmp(tok1, "after")) || (0 == strcmp(tok1, "with"))) { /* skip next word */
92 str = get_sign_and_token(str, sgn, tok1);
93 continue;
94 }
95 t = get_type(tok1);
96 if ((tp != t) && (UNKNOWN_TYPE != t)) {
97 if (UNDEFINED != node_id(tok1)) {
98 print_error_location(tg, ml, mf);
99 (void) fprintf(STDERR, " type inconsistency between input <%s> and output node <%s>\n", tok1, nm);
100 (void) fprintf(STDERR, " input nodes must be all digital type or all analog type\n");
101 flag_node(out);
102 }
103 }
104 }
105 break;
106
107 /* ALU: chameleonic type depending on N inputs */
108
109 case ALU_KIND :
110 str = get_sign_and_token(str, sgn, tok1);
111 str = get_sign_and_token(str, sgn, tok1);
112 t = get_type(tok1);
113 if (DIGITAL_DATA_TYPE != t) {
114 print_error_location(tg, ml, mf);
115 (void) fprintf(STDERR, " opcode <%s> must be digital type\n", tok1);
116 flag_node(out);
117 }
118 for (;;) {
119 str = get_sign_and_token(str, sgn, tok1);
120 if (ISEMPTY(tok1)) {
121 break;
122 }
123 t = get_type(tok1);
124 if (tp != t) {
125 print_error_location(tg, ml, mf);
126 (void) fprintf(STDERR, " type inconsistency between input <%s> and output node <%s>\n", tok1, nm);
127 flag_node(out);
128 }
129 }
130 break;
131
132 /* AND, INV, BUF, TOGGLE, NAND, NOR, XOR, XNOR, BWINV: digital type */
133
134 case AND_KIND :
135 case INV_KIND :
136 case BUF_KIND :
137 case TOGGLE_KIND :
138 case OR_KIND :
139 case NAND_KIND :
140 case NOR_KIND :
141 case XOR_KIND :
142 case XNOR_KIND :
143 case MULLER_KIND :
144 case BWINV_KIND :
145 for (;;) {
146 str = get_sign_and_token(str, sgn, tok1);
147 if (ISEMPTY(tok1)) {
148 break;
149 }
150 t = get_type(tok1);
151 if (DIGITAL_DATA_TYPE != t) {
152 print_error_location(tg, ml, mf);
153 (void) fprintf(STDERR, " input <%s> must be digital type\n", tok1);
154 flag_node(out);
155 }
156 }
157 break;
158
159 /* AVERAGE: analog type */
160
161 case AVERAGE_KIND :
162 str = get_sign_and_token(str, sgn, tok1);
163 t = get_type(tok1);
164 if (ANALOG_DATA_TYPE != t) {
165 print_error_location(tg, ml, mf);
166 (void) fprintf(STDERR, " input <%s> must be analog type\n", tok1);
167 flag_node(out);
168 }
169 break;
170
171 /* BSHIFT, LSHIFT, RSHIFT, RSHIFT1, RSHIFT2: output type is always digital */
172
173 case BSHIFT_KIND :
174 case LSHIFT_KIND :
175 case RSHIFT_KIND :
176 case RSHIFT1_KIND :
177 case RSHIFT2_KIND :
178 str = get_sign_and_token(str, sgn, tok1);
179 t = get_type(tok1);
180 if (DIGITAL_DATA_TYPE != t) {
181 print_error_location(tg, ml, mf);
182 (void) fprintf(STDERR, " shift value <%s> must be digital type\n", tok1);
183 flag_node(out);
184 }
185 str = get_sign_and_token(str, sgn, tok1);
186 t = get_type(tok1);
187 if (DIGITAL_DATA_TYPE != t) {
188 print_error_location(tg, ml, mf);
189 (void) fprintf(STDERR, " input <%s> must be digital type\n", tok1);
190 flag_node(out);
191 }
192 break;
193
194 /* BTOI: digital type */
195
196 case BTOI_KIND :
197 for (;;) {
198 str = get_sign_and_token(str, sgn, tok1);
199 if (ISEMPTY(tok1)) {
200 break;
201 }
202 t = get_type(tok1);
203 if (DIGITAL_DATA_TYPE != t) {
204 print_error_location(tg, ml, mf);
205 (void) fprintf(STDERR, " input <%s> must be digital type\n", tok1);
206 flag_node(out);
207 }
208 }
209 break;
210
211 /* BWAND, BWNAND, BWNOR, BWXOR, BWXNOR: digital type */
212
213 case BWAND_KIND :
214 case BWOR_KIND :
215 case BWNAND_KIND :
216 case BWNOR_KIND :
217 case BWXOR_KIND :
218 case BWXNOR_KIND :
219 str = get_sign_and_token(str, sgn, tok1);
220 t = get_type(tok1);
221 if (((UNKNOWN_KIND==node_id(tok1)) && (HEX_DATA_TYPE!=t)) || ((UNKNOWN_KIND!=node_id(tok1)) && (DIGITAL_DATA_TYPE!=t))) {
222 print_error_location(tg, ml, mf);
223 (void) fprintf(STDERR, " input <%s> should be a hexadecimal constant or a digital type node\n", tok1);
224 flag_node(out);
225 break;
226 }
227 for (;;) {
228 str = get_sign_and_token(str, sgn, tok1);
229 if (ISEMPTY(tok1)) {
230 break;
231 }
232 t = get_type(tok1);
233 if (DIGITAL_DATA_TYPE != t) {
234 print_error_location(tg, ml, mf);
235 (void) fprintf(STDERR, " input <%s> must be digital type\n", tok1);
236 flag_node(out);
237 }
238 }
239 break;
240
241 /* CHG, SIGN digital type */
242
243 case CHG_KIND :
244 case SIGN_KIND :
245 break;
246
247 /* CLIP: chameleonic type depending on single input */
248
249 case CLIP_KIND :
250 str = get_sign_and_token(str, sgn, tok1);
251 t = get_type(tok1);
252 if (tp != t) {
253 print_error_location(tg, ml, mf);
254 (void) fprintf(STDERR, " type inconsistency between clip level low <%s> and output node <%s>\n", tok1, nm);
255 flag_node(out);
256 }
257 str = get_sign_and_token(str, sgn, tok1);
258 t = get_type(tok1);
259 if (tp != t) {
260 print_error_location(tg, ml, mf);
261 (void) fprintf(STDERR, " type inconsistency between clip level high <%s> and output node <%s>\n", tok1, nm);
262 flag_node(out);
263 }
264 str = get_sign_and_token(str, sgn, tok1);
265 t = get_type(tok1);
266 if (tp != t) {
267 print_error_location(tg, ml, mf);
268 (void) fprintf(STDERR, " type inconsistency between input <%s> and output node <%s>\n", tok1, nm);
269 flag_node(out);
270 }
271 break;
272
273 /* CLOCK: digital type */
274
275 case CLOCK_KIND :
276 break;
277
278 /* COMP, digital type */
279
280 case COMP_KIND :
281 str = get_sign_and_token(str, sgn, tok1);
282 str = get_sign_and_token(str, sgn, tok2);
283 tp = get_type(tok1);
284 t = get_type(tok2);
285 if (tp != t) {
286 print_error_location(tg, ml, mf);
287 (void) fprintf(STDERR, " type inconsistency between inputs <%s> and <%s>\n", tok1, tok2);
288 flag_node(out);
289 }
290 break;
291
292 /* OSC, COS, SIN, SQUARE, TRIANGLE: analog type */
293
294 case OSC_KIND :
295 case COS_KIND :
296 case SIN_KIND :
297 case SQUARE_KIND :
298 case TRIANGLE_KIND :
299 str = get_sign_and_token(str, sgn, tok1);
300 t = get_type(tok1);
301 if (ANALOG_DATA_TYPE != t) {
302 print_error_location(tg, ml, mf);
303 (void) fprintf(STDERR, " offset <%s> must be analog type\n", tok1);
304 flag_node(out);
305 }
306 str = get_sign_and_token(str, sgn, tok1);
307 t = get_type(tok1);
308 if (ANALOG_DATA_TYPE != t) {
309 print_error_location(tg, ml, mf);
310 (void) fprintf(STDERR, " amplitude <%s> must be analog type\n", tok1);
311 flag_node(out);
312 }
313 str = get_sign_and_token(str, sgn, tok1);
314 t = get_type(tok1);
315 if (ANALOG_DATA_TYPE != t) {
316 print_error_location(tg, ml, mf);
317 (void) fprintf(STDERR, " frequency <%s> must be analog type\n", tok1);
318 flag_node(out);
319 }
320 str = get_sign_and_token(str, sgn, tok1);
321 t = get_type(tok1);
322 if (ANALOG_DATA_TYPE != t) {
323 if ((SIN_KIND == kd) || (COS_KIND == kd)) {
324 print_error_location(tg, ml, mf);
325 (void) fprintf(STDERR, " phase <%s> must be analog type\n", tok1);
326 flag_node(out);
327 } else {
328 print_error_location(tg, ml, mf);
329 (void) fprintf(STDERR, " delay <%s> must be analog type\n", tok1);
330 flag_node(out);
331 }
332 }
333 if ((SQUARE_KIND == kd) ||(TRIANGLE_KIND == kd)) {
334 str = get_sign_and_token(str, sgn, tok1);
335 t = get_type(tok1);
336 if (ISNOTEMPTY(tok1) && (ANALOG_DATA_TYPE != t)) {
337 print_error_location(tg, ml, mf);
338 (void) fprintf(STDERR, " optional duty cycle <%s> must be analog type\n", tok1);
339 flag_node(out);
340 }
341 }
342 break;
343
344 /* COPY, RECT: chameleonic type depending on single input */
345 /* SUM, PROD, MIN, MAX: chameleonic type depending on N inputs */
346 /* SUB, DIV, MOD: chameleonic type depending on 2 inputs */
347 /* WSUM: chameleonic type depending on N pairs of inputs */
348 /* POLY: chameleonic type depending on N coefficients and one input */
349
350 case COPY_KIND :
351 case RECT_KIND :
352 case SUM_KIND :
353 case PROD_KIND :
354 case MIN_KIND :
355 case MAX_KIND :
356 case SUB_KIND :
357 case DIV_KIND :
358 case MOD_KIND :
359 case WSUM_KIND :
360 case POLY_KIND :
361 for (;;) {
362 str = get_sign_and_token(str, sgn, tok1);
363 if (ISEMPTY(tok1)) {
364 break;
365 }
366 t = get_type(tok1);
367 if (tp != t) {
368 print_error_location(tg, ml, mf);
369 (void) fprintf(STDERR, " type inconsistency between input <%s> and output node <%s>\n", tok1, nm);
370 flag_node(out);
371 }
372 }
373 break;
374
375 /* DAC, UDAC: analog type */
376
377 case DAC_KIND :
378 case UDAC_KIND :
379 str = get_sign_and_token(str, sgn, tok1);
380 t = get_type(tok1);
381 if (DIGITAL_DATA_TYPE != t) {
382 print_error_location(tg, ml, mf);
383 (void) fprintf(STDERR, " number of levels <%s> must be digital type\n", tok1);
384 flag_node(out);
385 }
386 str = get_sign_and_token(str, sgn, tok1);
387 t = get_type(tok1);
388 if (DIGITAL_DATA_TYPE != t) {
389 print_error_location(tg, ml, mf);
390 (void) fprintf(STDERR, " input <%s> of the converter must be digital type\n", tok1);
391 flag_node(out);
392 }
393 str = get_sign_and_token(str, sgn, tok1);
394 t = get_type(tok1);
395 if (ANALOG_DATA_TYPE != t) {
396 print_error_location(tg, ml, mf);
397 (void) fprintf(STDERR, " reference <%s> of the converter must be analog type\n", tok1);
398 flag_node(out);
399 }
400 break;
401
402 /* DALGEBRA: analog type */
403 /* IALGEBRA: digital type */
404 /* TEST: digital type */
405
406 case DALGEBRA_KIND :
407 case IALGEBRA_KIND :
408 case TEST_KIND :
409 break;
410
411 /* DC: analog type or digital type depending on qualifier */
412
413 case DC_KIND :
414 break;
415
416 /* DELAY: chameleonic type depending on single input */
417
418 case DELAY1_KIND :
419 case DELAY2_KIND :
420 case DELAY3_KIND :
421 str = get_sign_and_token(str, sgn, tok1);
422 str = get_sign_and_token(str, sgn, tok1);
423 t = get_type(tok1);
424 if (tp != t) {
425 print_error_location(tg, ml, mf);
426 (void) fprintf(STDERR, " type inconsistency between input <%s> and output node <%s>\n", tok1, nm);
427 flag_node(out);
428 }
429 break;
430
431 /* DTOI: digital type */
432
433 case DTOI_KIND :
434 str = get_sign_and_token(str, sgn, tok1);
435 t = get_type(tok1);
436 if (ANALOG_DATA_TYPE != t) {
437 print_error_location(tg, ml, mf);
438 (void) fprintf(STDERR, " input <%s> must be analog type\n", tok1);
439 flag_node(out);
440 }
441 break;
442
443 /* DUSER, DTOOL: analog type */
444 /* IUSER, ITOOL: digital type */
445
446 case DUSER_KIND :
447 case DTOOL_KIND :
448 case IUSER_KIND :
449 case ITOOL_KIND :
450 break;
451
452 /* EQUAL: digital type */
453
454 case EQUAL_KIND :
455 str = get_sign_and_token(str, sgn, tok1);
456 str = get_sign_and_token(str, sgn, tok2);
457 tp = get_type(tok1);
458 t = get_type(tok2);
459 if (tp != t) {
460 print_error_location(tg, ml, mf);
461 (void) fprintf(STDERR, " type inconsistency between inputs <%s> and <%s>\n", tok1, tok2);
462 flag_node(out);
463 }
464 if (0 != strcmp(str, "")) {
465 str = get_sign_and_token(str, sgn, tok3);
466 t = get_type(tok3);
467 if (tp != t) {
468 print_error_location(tg, ml, mf);
469 (void) fprintf(STDERR, " type inconsistency between inputs <%s>, <%s> and precision <%s>\n", tok1, tok2, tok3);
470 flag_node(out);
471 }
472 }
473 break;
474
475 /* FZINV, FZBUF, FZAND, FZOR, FZXOR, FZNAND, FZNOR, FZXNOR: analog type */
476
477 case FZINV_KIND :
478 case FZBUF_KIND :
479 case FZAND_KIND :
480 case FZOR_KIND :
481 case FZXOR_KIND :
482 case FZNAND_KIND :
483 case FZNOR_KIND :
484 case FZXNOR_KIND :
485 for (;;) {
486 str = get_sign_and_token(str, sgn, tok1);
487 if (ISEMPTY(tok1)) {
488 break;
489 }
490 t = get_type(tok1);
491 if (ANALOG_DATA_TYPE != t) {
492 print_error_location(tg, ml, mf);
493 (void) fprintf(STDERR, " input <%s> must be analog type>\n", tok1);
494 flag_node(out);
495 }
496 }
497 break;
498
499 /* GAIN, OFFSET: chameleonic type depending on single input */
500
501 case GAIN_KIND :
502 case OFFSET_KIND :
503 case QUANT_KIND :
504 str = get_sign_and_token(str, sgn, tok1);
505 t = get_type(tok1);
506 if (tp != t) {
507 print_error_location(tg, ml, mf);
508 (void) fprintf(STDERR, " type inconsistency between parameter <%s> and output node <%s>\n", tok1, nm);
509 flag_node(out);
510 }
511 str = get_sign_and_token(str, sgn, tok1);
512 t = get_type(tok1);
513 if (tp != t) {
514 print_error_location(tg, ml, mf);
515 (void) fprintf(STDERR, " type inconsistency between input <%s> and output node <%s>\n", tok1, nm);
516 flag_node(out);
517 }
518 break;
519
520 /* DIFFERENTIATOR: chameleonic type depending on single input */
521 /* INTEGRATOR: chameleonic type depending on single input */
522
524 case INTEGRATOR_KIND :
525 str = get_sign_and_token(str, sgn, tok1);
526 t = get_type(tok1);
527 if (tp != t) {
528 print_error_location(tg, ml, mf);
529 (void) fprintf(STDERR, " type inconsistency between input <%s> and output node <%s>\n", tok1, nm);
530 flag_node(out);
531 }
532 break;
533
534 /* ITOB: digital type */
535
536 case ITOB_KIND :
537 str = get_sign_and_token(str, sgn, tok1);
538 t = get_type(tok1);
539 if (DIGITAL_DATA_TYPE != t) {
540 print_error_location(tg, ml, mf);
541 (void) fprintf(STDERR, " bit number <%s> must be digital type\n", tok1);
542 flag_node(out);
543 }
544 str = get_sign_and_token(str, sgn, tok1);
545 t = get_type(tok1);
546 if (DIGITAL_DATA_TYPE != t) {
547 print_error_location(tg, ml, mf);
548 (void) fprintf(STDERR, " input node <%s> must be digital type\n", tok1);
549 flag_node(out);
550 }
551 break;
552
553 /* HOLD, TRACK: chameleonic type depending on single input */
554
555 case HOLD_KIND :
556 case TRACK_KIND :
557 str = get_sign_and_token(str, sgn, tok1);
558 t = get_type(tok1);
559 if (DIGITAL_DATA_TYPE != t) {
560 print_error_location(tg, ml, mf);
561 (void) fprintf(STDERR, " control <%s> must be digital type\n", tok1);
562 flag_node(out);
563 }
564 str = get_sign_and_token(str, sgn, tok2);
565 t = get_type(tok2);
566 if (tp != t) {
567 print_error_location(tg, ml, mf);
568 (void) fprintf(STDERR, " type inconsistency between input <%s> and output node <%s>\n", tok2, nm);
569 flag_node(out);
570 }
571 break;
572
573 /* ITOD: analog type */
574
575 case ITOD_KIND :
576 str = get_sign_and_token(str, sgn, tok1);
577 t = get_type(tok1);
578 if (DIGITAL_DATA_TYPE != t) {
579 print_error_location(tg, ml, mf);
580 (void) fprintf(STDERR, " input <%s> must be digital type\n", tok1);
581 flag_node(out);
582 }
583 break;
584
585 /* LATCH: digital type */
586
587 case LATCH_KIND :
588 str = get_sign_and_token(str, sgn, tok1);
589 t = get_type(tok1);
590 if (DIGITAL_DATA_TYPE != t) {
591 print_error_location(tg, ml, mf);
592 (void) fprintf(STDERR, " set <%s> must be digital type\n", tok1);
593 flag_node(out);
594 }
595 str = get_sign_and_token(str, sgn, tok1);
596 t = get_type(tok1);
597 if (DIGITAL_DATA_TYPE != t) {
598 print_error_location(tg, ml, mf);
599 (void) fprintf(STDERR, " reset <%s> must be digital type\n", tok1);
600 flag_node(out);
601 }
602 break;
603
604 /* MUX: chameleonic type depending on input */
605
606 case MUX_KIND :
607 str = get_sign_and_token(str, sgn, tok1);
608 t = get_type(tok1);
609 if (DIGITAL_DATA_TYPE != t) {
610 print_error_location(tg, ml, mf);
611 (void) fprintf(STDERR, " control <%s> must be digital type\n", tok1);
612 flag_node(out);
613 }
614 for (;;) {
615 str = get_sign_and_token(str, sgn, tok1);
616 if (ISEMPTY(tok1)) {
617 break;
618 }
619 if (0 == strcmp(tok1, "void")) {
620 continue;
621 }
622 t = get_type(tok1);
623 if (tp != t) {
624 print_error_location(tg, ml, mf);
625 (void) fprintf(STDERR, " type inconsistency between the input <%s> and output node <%s>\n", tok1, nm);
626 flag_node(out);
627 }
628 }
629 break;
630
631 /* MERGE: chameleonic type depending on input */
632
633 case MERGE_KIND :
634 for (;;) {
635 str = get_sign_and_token(str, sgn, tok1);
636 if (ISEMPTY(tok1)) {
637 break;
638 }
639 t = get_type(tok1);
640 if (tp != t) {
641 print_error_location(tg, ml, mf);
642 (void) fprintf(STDERR, " type inconsistency between the input <%s> and output node <%s>\n", tok1, nm);
643 flag_node(out);
644 }
645 }
646 break;
647
648 /* DELAY: chameleonic type depending on single input */
649
650 case DELAY_KIND :
651 str = get_sign_and_token(str, sgn, tok1);
652 t = get_type(tok1);
653 if (DIGITAL_DATA_TYPE != t) {
654 print_error_location(tg, ml, mf);
655 (void) fprintf(STDERR, " number of delays <%s> must be a positive digital\n", tok1);
656 flag_node(out);
657 }
658 str = get_sign_and_token(str, sgn, tok1);
659 t = get_type(tok1);
660 if (tp != t) {
661 print_error_location(tg, ml, mf);
662 (void) fprintf(STDERR, " type inconsistency between input <%s> and output node <%s>\n", tok1, nm);
663 flag_node(out);
664 }
665 break;
666
667 /* NOISE: output type is always analog type */
668
669 case NOISE_KIND :
670 str = get_sign_and_token(str, sgn, tok1);
671 t = get_type(tok1);
672 if (ANALOG_DATA_TYPE != t) {
673 print_error_location(tg, ml, mf);
674 (void) fprintf(STDERR, " DC value <%s> must be analog type\n", tok1);
675 flag_node(out);
676 }
677 str = get_sign_and_token(str, sgn, tok1);
678 t = get_type(tok1);
679 if (ANALOG_DATA_TYPE != t) {
680 print_error_location(tg, ml, mf);
681 (void) fprintf(STDERR, " RMS value <%s> must be analog type\n", tok1);
682 flag_node(out);
683 }
684 break;
685
686 /* RAM & RAM2: declared type */
687
688 case RAM_KIND :
689 case RAM2_KIND :
690 str = get_sign_and_token(str, sgn, tok1);
691 str = get_token_between_braces(str, brck, tok1);
692 t = get_type(tok1);
693 if (DIGITAL_DATA_TYPE != t) {
694 print_error_location(tg, ml, mf);
695 (void) fprintf(STDERR, " address <%s> must be digital type\n", tok1);
696 flag_node(out);
697 }
698 str = get_sign_and_token(str, sgn, tok1);
699 t = get_type(tok1);
700 if ((DIGITAL_DATA_TYPE != t) && (0 != strcmp(tok1, "true"))) {
701 print_error_location(tg, ml, mf);
702 (void) fprintf(STDERR, " chip select <%s> must be digital type\n", tok1);
703 flag_node(out);
704 }
705 str = get_sign_and_token(str, sgn, tok1);
706 t = get_type(tok1);
707 if (DIGITAL_DATA_TYPE != t) {
708 print_error_location(tg, ml, mf);
709 (void) fprintf(STDERR, " read/write <%s> must be digital type\n", tok1);
710 flag_node(out);
711 }
712 str = get_sign_and_token(str, sgn, tok1);
713 t = get_type(tok1);
714 if (tp != t) {
715 print_error_location(tg, ml, mf);
716 (void) fprintf(STDERR, " type inconsistency between write port <%s> and read port <%s>\n", tok1, nm);
717 flag_node(out);
718 }
719 break;
720
721 /* ROM & ROM2: declared type */
722
723 case ROM_KIND :
724 case ROM2_KIND :
725 str = get_sign_and_token(str, sgn, tok1);
726 str = get_token_between_braces(str, brck, tok1);
727 t = get_type(tok1);
728 if (DIGITAL_DATA_TYPE != t) {
729 print_error_location(tg, ml, mf);
730 (void) fprintf(STDERR, " address <%s> must be digital type\n", tok1);
731 flag_node(out);
732 }
733 str = get_sign_and_token(str, sgn, tok1);
734 t = get_type(tok1);
735 if ((DIGITAL_DATA_TYPE != t) && (0 != strcmp(tok1, "true"))) {
736 print_error_location(tg, ml, mf);
737 (void) fprintf(STDERR, " chip select <%s> must be digital type\n", tok1);
738 flag_node(out);
739 }
740 break;
741
742 /* RELAY: chameleonic type depending on input */
743
744 case RELAY_KIND :
745 str = get_sign_and_token(str, sgn, tok1);
746 t = get_type(tok1);
747 if (DIGITAL_DATA_TYPE != t) {
748 print_error_location(tg, ml, mf);
749 (void) fprintf(STDERR, " control <%s> must be digital type\n", tok1);
750 flag_node(out);
751 }
752 str = get_sign_and_token(str, sgn, tok1);
753 t = get_type(tok1);
754 if (tp != t) {
755 print_error_location(tg, ml, mf);
756 (void) fprintf(STDERR, " type inconsistency between the input <%s> and output node <%s>\n", tok1, nm);
757 flag_node(out);
758 }
759 if (ISEMPTY(str)) { /* setting value is optional */
760 break;
761 }
762 str = get_sign_and_token(str, sgn, tok1);
763 t = get_type(tok1);
764 if (tp != t) {
765 print_error_location(tg, ml, mf);
766 (void) fprintf(STDERR, " type inconsistency between setting value <%s> and output node <%s>\n", tok1, nm);
767 flag_node(out);
768 }
769 break;
770
771 /* RIP: digital type */
772
773 case RIP_KIND :
774 str = get_sign_and_token(str, sgn, tok1);
775 t = get_type(tok1);
776 if (HEX_DATA_TYPE != t) {
777 print_error_location(tg, ml, mf);
778 (void) fprintf(STDERR, " mask <%s> must be a hexadecimal constant\n", tok1);
779 flag_node(out);
780 }
781 for (;;) {
782 str = get_sign_and_token(str, sgn, tok1);
783 if (ISEMPTY(tok1)) {
784 break;
785 }
786 t = get_type(tok1);
787 if (DIGITAL_DATA_TYPE != t) {
788 print_error_location(tg, ml, mf);
789 (void) fprintf(STDERR, " input <%s> must be digital type\n", tok1);
790 flag_node(out);
791 }
792 }
793 break;
794
795 /* STEP: analog type */
796
797 case STEP_KIND :
798 str = get_sign_and_token(str, sgn, tok1);
799 t = get_type(tok1);
800 if (ANALOG_DATA_TYPE != t) {
801 print_error_location(tg, ml, mf);
802 (void) fprintf(STDERR, " first level <%s> must be analog type\n", tok1);
803 flag_node(out);
804 }
805 str = get_sign_and_token(str, sgn, tok1);
806 t = get_type(tok1);
807 if (ANALOG_DATA_TYPE != t) {
808 print_error_location(tg, ml, mf);
809 (void) fprintf(STDERR, " second level <%s> must be analog type>\n", tok1);
810 flag_node(out);
811 }
812 str = get_sign_and_token(str, sgn, tok1);
813 t = get_type(tok1);
814 if (ANALOG_DATA_TYPE != t) {
815 print_error_location(tg, ml, mf);
816 (void) fprintf(STDERR, " step time <%s> must be analog type\n", tok1);
817 flag_node(out);
818 }
819 if (ISNOTEMPTY(str)) {
820 str = get_sign_and_token(str, sgn, tok1);
821 t = get_type(tok1);
822 if (ANALOG_DATA_TYPE != t) {
823 print_error_location(tg, ml, mf);
824 (void) fprintf(STDERR, " step time <%s> must be analog type\n", tok1);
825 flag_node(out);
826 }
827 }
828 break;
829
830 /* TRIG: digital type */
831
832 case TRIG_KIND :
833 str = get_sign_and_token(str, sgn, tok1);
834 str = get_sign_and_token(str, sgn, tok2);
835 tp = get_type(tok1);
836 t = get_type(tok2);
837 if (tp != t) {
838 print_error_location(tg, ml, mf);
839 (void) fprintf(STDERR, " type inconsistency between trigger threshold <%s> and input node <%s>\n", tok1, tok2);
840 flag_node(out);
841 }
842 break;
843
844 /* ZERO: chameleonic type depending on input */
845
846 case ZERO_KIND :
847 str = get_sign_and_token(str, sgn, tok1);
848 t = get_type(tok1);
849 if (DIGITAL_DATA_TYPE != t) {
850 print_error_location(tg, ml, mf);
851 (void) fprintf(STDERR, " decimation factor <%s> must be digital type\n", tok1);
852 flag_node(out);
853 }
854 str = get_sign_and_token(str, sgn, tok1);
855 t = get_type(tok1);
856 if (DIGITAL_DATA_TYPE != t) {
857 print_error_location(tg, ml, mf);
858 (void) fprintf(STDERR, " decimation offset <%s> must be digital type\n", tok1);
859 flag_node(out);
860 }
861 break;
862
863 /* Unrecognized kind of node */
864
865 case UNKNOWN_KIND : /* should never occur */
866 default :
867 print_warning_location(tg, ml, mf);
868 (void) fprintf(STDERR, " unknown node kind [#%ld] detected when checking node type\n", kd);
869 break;
870 }
871 }
872 return;
873}
874
875
876/* ****************************************************************************************************************************** */
877/* end of file */
void print_warning_location(const char *type, const unsigned long *mlin, const unsigned long *mfil)
Definition fc.c:1484
void print_error_location(const char *type, const unsigned long *mlin, const unsigned long *mfil)
Definition fc.c:1476
long get_type(char *identifier)
Definition id.c:1190
void flag_node(long num)
Definition id.c:99
long node_id(const char *identifier)
Definition id.c:718
#define DELAY2_KIND
Definition napa.h:255
#define MUX_KIND
Definition napa.h:288
#define EQUAL_KIND
Definition napa.h:262
#define ITOD_KIND
Definition napa.h:278
#define MOD_KIND
Definition napa.h:286
#define RIP_KIND
Definition napa.h:302
#define MULLER_KIND
Definition napa.h:287
#define WSUM_KIND
Definition napa.h:323
#define TRACK_KIND
Definition napa.h:318
#define UNKNOWN_TYPE
Definition napa.h:332
#define UNDEFINED
Definition napa.h:331
#define RSHIFT2_KIND
Definition napa.h:307
#define AND_KIND
Definition napa.h:229
#define ROM2_KIND
Definition napa.h:304
#define TRIANGLE_KIND
Definition napa.h:319
#define STDERR
Definition napa.h:105
EXTERN NODE_TYPE Node_List[4095L]
Definition napa.h:962
#define LATCH_KIND
Definition napa.h:281
#define DIFFERENTIATOR_KIND
Definition napa.h:257
#define RSHIFT1_KIND
Definition napa.h:306
#define LSHIFT_KIND
Definition napa.h:282
#define INV_KIND
Definition napa.h:276
#define BWNAND_KIND
Definition napa.h:236
#define DTOI_KIND
Definition napa.h:259
#define FZNOR_KIND
Definition napa.h:267
#define OSC_KIND
Definition napa.h:294
#define DELAY3_KIND
Definition napa.h:256
#define CLOCK_KIND
Definition napa.h:244
#define NOR_KIND
Definition napa.h:291
#define ANALOG_DATA_TYPE
Definition napa.h:338
#define ADC_KIND
Definition napa.h:226
#define COPY_KIND
Definition napa.h:247
#define OFFSET_KIND
Definition napa.h:292
#define OR_KIND
Definition napa.h:293
#define CLIP_KIND
Definition napa.h:243
#define RELAY_KIND
Definition napa.h:301
#define SQUARE_KIND
Definition napa.h:312
#define MIN_KIND
Definition napa.h:285
#define UADC_KIND
Definition napa.h:321
#define IUSER_KIND
Definition napa.h:280
#define NAND_KIND
Definition napa.h:289
#define AVERAGE_KIND
Definition napa.h:230
#define PROD_KIND
Definition napa.h:296
#define DUSER_KIND
Definition napa.h:261
#define TEST_KIND
Definition napa.h:316
EXTERN long Num_Nodes
Definition napa.h:824
#define DELAY1_KIND
Definition napa.h:254
#define GAIN_KIND
Definition napa.h:271
#define ITOB_KIND
Definition napa.h:277
#define BUF_KIND
Definition napa.h:233
#define HOLD_KIND
Definition napa.h:273
#define XOR_KIND
Definition napa.h:325
#define RAM_KIND
Definition napa.h:298
#define SIN_KIND
Definition napa.h:310
#define TOGGLE_KIND
Definition napa.h:317
#define XNOR_KIND
Definition napa.h:324
#define BWXNOR_KIND
Definition napa.h:239
#define DALGEBRA_KIND
Definition napa.h:251
#define RECT_KIND
Definition napa.h:300
#define MERGE_KIND
Definition napa.h:284
#define ROM_KIND
Definition napa.h:303
#define FZBUF_KIND
Definition napa.h:264
#define DC_KIND
Definition napa.h:252
#define SIGN_KIND
Definition napa.h:309
#define FZXNOR_KIND
Definition napa.h:269
#define IALGEBRA_KIND
Definition napa.h:274
#define ALU_KIND
Definition napa.h:228
#define SUM_KIND
Definition napa.h:315
#define BWXOR_KIND
Definition napa.h:240
#define BTOI_KIND
Definition napa.h:232
#define FZNAND_KIND
Definition napa.h:266
#define ISNOTEMPTY(s)
Definition napa.h:395
#define ITOOL_KIND
Definition napa.h:279
#define DTOOL_KIND
Definition napa.h:260
#define RAM2_KIND
Definition napa.h:299
#define SUB_KIND
Definition napa.h:314
#define DIV_KIND
Definition napa.h:258
#define FZOR_KIND
Definition napa.h:268
#define BWOR_KIND
Definition napa.h:238
#define FZXOR_KIND
Definition napa.h:270
#define POLY_KIND
Definition napa.h:295
#define RSHIFT_KIND
Definition napa.h:305
#define UDAC_KIND
Definition napa.h:322
#define ZERO_KIND
Definition napa.h:326
#define INTEGRATOR_KIND
Definition napa.h:275
#define MAX_KIND
Definition napa.h:283
#define STRLENGTH
Definition napa.h:217
#define BWNOR_KIND
Definition napa.h:237
#define COMP_KIND
Definition napa.h:245
#define ISEMPTY(s)
Definition napa.h:394
#define BSHIFT_KIND
Definition napa.h:231
#define DELAY_KIND
Definition napa.h:253
#define FZINV_KIND
Definition napa.h:265
#define ALGEBRA_KIND
Definition napa.h:227
#define HEX_DATA_TYPE
Definition napa.h:340
#define BWINV_KIND
Definition napa.h:235
#define FZAND_KIND
Definition napa.h:263
#define QUANT_KIND
Definition napa.h:297
#define STEP_KIND
Definition napa.h:313
#define UNKNOWN_KIND
Definition napa.h:224
#define CHG_KIND
Definition napa.h:242
#define BWAND_KIND
Definition napa.h:234
#define DAC_KIND
Definition napa.h:250
#define TRIG_KIND
Definition napa.h:320
#define COS_KIND
Definition napa.h:248
#define NOISE_KIND
Definition napa.h:290
#define DIGITAL_DATA_TYPE
Definition napa.h:337
char * get_token_between_braces(char *str, char *brc, char *tok)
Definition tk.c:1110
char * get_sign_and_token(char *str, char *sgn, char *tok)
Definition tk.c:1188
void check_types(void)
Definition tp.c:28