Subversion Repositories Vertical

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/*
2
 * $Id: diagnostics.c,v 1.1.1.1 2003/11/04 23:34:56 mjames Exp $
3
 *
4
 * $Log: diagnostics.c,v $
5
 * Revision 1.1.1.1  2003/11/04 23:34:56  mjames
6
 * Imported into local repositrory
7
 *
8
 * Revision 1.4  2002/09/09 10:26:56  mjames
9
 * Removed set generic range and replaced it with a set generic value command
10
 * that takes both integers and ranges.
11
 *
12
 * Revision 1.3  2001/10/31 22:20:02  mjames
13
 * Tidying up problematical comments caused by CVS
14
 * 'intelligent' comment guessing
15
 *
16
 * Revision 1.2  2001/06/06 12:10:23  mjames
17
 * Move from HPUX
18
 *
19
 * Revision 1.1.1.1  2000/10/19 21:58:36  mjames
20
 * Mike put it here
21
 *
22
 *
23
 * Revision 1.20  2000/10/04  10:37:03  10:37:03  mjames (Mike James)
24
 * Modified for Vertical2 : support COMPONENTS and SIGNALS
25
 *
26
 * Revision 1.20  2000/10/04  10:37:03  10:37:03  mjames (Mike James)
27
 * Part of Release PSAVAT01
28
 *
29
 * Revision 1.19  2000/10/02  11:04:11  11:04:11  mjames (Mike James)
30
 * new_vhdl
31
 *
32
 
33
 * Revision 1.18  2000/09/27  14:42:11  14:42:11  mjames (Mike James)
34
 
35
 * Part of Release Sep_27_ST_2000
36
 
37
 *
38
 
39
 * Revision 1.17  2000/09/21  10:15:41  10:15:41  mjames (Mike James)
40
 
41
 * Part of Release Sep21Alpha
42
 
43
 *
44
 
45
 * Revision 1.16  2000/08/25  09:57:10  09:57:10  mjames (Mike James)
46
 
47
 * Part of Release Aug25_alpha
48
 
49
 *
50
 
51
 * Revision 1.15  2000/08/16  08:57:26  08:57:26  mjames (Mike James)
52
 
53
 * Part of Release CD01_Aug2000
54
 
55
 *
56
 
57
 * Revision 1.14  2000/08/14  14:45:08  14:45:08  mjames (Mike James)
58
 
59
 * Part of Release Aug_14_2000
60
 
61
 *
62
 
63
 * Revision 1.13  2000/08/11  08:30:28  08:30:28  mjames (Mike James)
64
 
65
 * Part of Release Aug_11_2000
66
 
67
 *
68
 
69
 * Revision 1.12  2000/08/09  10:31:42  10:31:42  mjames (Mike James)
70
 
71
 * Part of Release Aug__9_2000
72
 
73
 *
74
 
75
 * Revision 1.11  2000/05/31  11:42:50  11:42:50  mjames (Mike James)
76
 
77
 * Part of Release May_31_2000
78
 
79
 *
80
 
81
 * Revision 1.10  2000/05/08  17:01:33  17:01:33  mjames (Mike James)
82
 
83
 * Part of Release May__8_2000
84
 
85
 *
86
 
87
 * Revision 1.9  2000/05/08  16:59:26  16:59:26  mjames (Mike James)
88
 
89
 * Part of Release May__8_2000
90
 
91
 *
92
 
93
 * Revision 1.8  2000/05/08  16:57:03  16:57:03  mjames (Mike James)
94
 
95
 * Part of Release May__8_2000
96
 
97
 *
98
 
99
 * Revision 1.7  2000/03/08  16:18:54  16:18:54  mjames (Mike James)
100
 
101
 * New version including PC
102
 
103
 *
104
 
105
 * Revision 1.4  2000/01/20  15:58:42  15:58:42  mjames (Mike James)
106
 
107
 * Part of Release R22
108
 
109
 *
110
 
111
 * Revision 1.3  99/12/22  11:15:22  11:15:22  mjames (Mike James)
112
 
113
 * Part of Release Dec_22_1999
114
 
115
 *
116
 
117
 * Revision 1.2  99/06/25  14:34:43  14:34:43  mjames (Mike James)
118
 
119
 * Added in reference to expression.h, but no changes made
120
 
121
 * to the function of acfread yet.
122
 
123
 *
124
 
125
 * Revision 1.1  99/05/04  09:50:53  09:50:53  mjames (Mike James)
126
 
127
 * Initial revision
128
 
129
 *
130
 
131
 *
132
 
133
*/
134
 
135
#include "cmdlog.h"
136
#include "cmdparse.h"
137
#include "database.h"
138
#include "generic.h"
139
#include "printout.h"
140
#include "sorting.h"
141
 
142
#include <ctype.h>
143
#include <stdio.h>
144
#include <stdlib.h>
145
#include <string.h>
146
#include <time.h>
147
 
148
static char IDstr[] = "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/spares/diagnostics.c,v 1.1.1.1 "
149
                      "2003/11/04 23:34:56 mjames Exp $";
150
 
151
/* decoding pin direction in ACF form */
152
 
153
/* see pindir_t in database.h */
154
 
155
static char *decode_pin[] =
156
 
157
    {
158
 
159
        "NONE",
160
 
161
        "INPUT_PIN",
162
 
163
        "OUTPUT_PIN",
164
 
165
        "output_pin", /* buffer is a sort of Output pin (lower case is for info only )*/
166
 
167
        "BIDIR_PIN ",
168
 
169
        "CONFIG_PIN"};
170
 
171
/* Decoding pin direction in VHDL */
172
 
173
static char *decode_pin_VHDL[] =
174
 
175
    {
176
 
177
        "-NONE-",
178
 
179
        "IN",
180
 
181
        "OUT",
182
 
183
        "BUFFER", /* buffer is a sort of Output pin */
184
 
185
        "INOUT",
186
 
187
        "CONFIG_PIN"};
188
 
189
/* ********************************************************************** */
190
 
191
/* this prints out the contents of the working database */
192
 
193
/* prints a single net as a connection */
194
 
195
/* subnets are printed as having the how_routed field of their
196
 
197
   parent, because this is the how_routed value that is indicated
198
 
199
   by the routing */
200
 
201
void list_net_nodes (FILE *f, net_t *cnet, net_t *root_net)
202
 
203
{
204
        noderef_t *bnode;
205
 
206
        node_t *cnode;
207
 
208
        int wrapc;
209
 
210
        if (!cnet)
211
 
212
                return;
213
 
214
        fprintf (
215
            f,
216
            " CONNECTION \"%s\" \"%s\" %s; -- %d nodes\n ",
217
 
218
            cnet->identifier,
219
 
220
            check_null_str (root_net->name),
221
 
222
            decode_how_routed[root_net->how_routed],
223
 
224
            cnet->nodecount);
225
 
226
        fprintf (
227
            f,
228
            "-- partition port=%d in=%d need_buff=%d\n",
229
 
230
            cnet->leaves_partition,
231
 
232
            cnet->inside_partition,
233
 
234
            cnet->needs_buff_sig);
235
 
236
        bnode = cnet->nodes;
237
 
238
        wrapc = 0;
239
 
240
        while (bnode)
241
        {
242
                cnode = bnode->node;
243
 
244
                fprintf (f, " %s(%s)", cnode->socket->identifier, cnode->identifier);
245
 
246
                /* printout if any lines have fix_location flags set */
247
 
248
                if (cnode->fix_location)
249
                {
250
                        wrapc += 2; /* cant get as much on this line */
251
 
252
                        fprintf (f, " FIX_LOCATION");
253
                }
254
 
255
                if (cnode->fixed_pin)
256
                {
257
                        wrapc += 2; /* cant get as much on this line */
258
 
259
                        fprintf (f, " %s", decode_pin[cnode->pindir]);
260
                }
261
 
262
                if (cnode->pin_group)
263
                {
264
                        wrapc += 2; /* cant get as much on this line */
265
 
266
                        fprintf (f, " (%d)", cnode->pin_group);
267
                }
268
 
269
                fprintf (f, ";");
270
 
271
                wrapc++;
272
 
273
                if (wrapc >= 8)
274
 
275
                {
276
                        wrapc = 0;
277
 
278
                        fprintf (f, "\n ");
279
                }
280
 
281
                bnode = bnode->next;
282
        };
283
 
284
        if (wrapc)
285
 
286
                fprintf (f, "\n ");
287
 
288
        fprintf (f, "END_CONN;\n");
289
}
290
 
291
/* ********************************************************************** */
292
 
293
void list_net_structure (FILE *f, net_t *cnet, net_t *root_net, int alias_depth)
294
 
295
{
296
        net_t *subnet;
297
 
298
        subnet = cnet->subnets;
299
 
300
        if (cnet == root_net)
301
 
302
                fprintf (f, "--Top Level\n");
303
 
304
        if (cnet->how_joined == Jumpered && subnet)
305
        {
306
                fprintf (
307
                    f,
308
                    "-- Jumpered Connections to '%s' name '%s' found here --\n",
309
 
310
                    cnet->identifier,
311
                    cnet->name);
312
 
313
                while (subnet)
314
                {
315
                        list_net_structure (f, subnet, root_net, 0); /* depth = 0, not aliased
316
                                                                      */
317
 
318
                        subnet = subnet->joined_nets;
319
                }
320
 
321
                fprintf (f, "--\n");
322
        }
323
 
324
        else if (cnet->how_joined == Aliased && subnet)
325
        {
326
                list_net_nodes (f, subnet, root_net);
327
 
328
                fprintf (
329
                    f,
330
                    "-- %*s '%s' (name %s) created by Alias of  --\n",
331
 
332
                    alias_depth,
333
                    "",
334
                    cnet->identifier,
335
                    cnet->name);
336
 
337
                while (subnet)
338
                {
339
                        fprintf (f, "-- %*s  '%s' -- \n", alias_depth, "", subnet->identifier);
340
 
341
                        list_net_structure (f, subnet, root_net, 0 /*alias_depth+1*/);
342
 
343
                        subnet = subnet->joined_nets;
344
                }
345
 
346
                fprintf (f, "--\n");
347
        }
348
 
349
        else if (!subnet)
350
 
351
                list_net_nodes (f, cnet, root_net);
352
 
353
        else
354
 
355
                fprintf (f, "-- Id %s skip\n", cnet->identifier);
356
}
357
 
358
/* ********************************************************************** */
359
 
360
/* lists all the connections on the board */
361
 
362
void list_nets (FILE *f, net_t *cnet)
363
 
364
{
365
        while (cnet)
366
        {
367
                list_net_structure (f, cnet, cnet, 0);
368
 
369
                cnet = cnet->next;
370
        }
371
}
372
 
373
/* ********************************************************************** */
374
 
375
static void list_join (FILE *f, char *typ, net_t *cnet)
376
 
377
{
378
        int wrapc = 1;
379
 
380
        /*  printf("List join %s , cnet = %p, join_parent = %p , join_parent->id =%p\n",
381
 
382
                  typ,cnet,cnet->join_parent,cnet->join_parent->identifier); */
383
 
384
        fprintf (f, " %s %s = (", typ, cnet->join_parent->identifier);
385
 
386
        while (cnet)
387
        {
388
                if (cnet->external_node)
389
 
390
                        fprintf (
391
                            f,
392
                            "%s(%s); ",
393
 
394
                            cnet->external_node->socket->identifier,
395
 
396
                            cnet->external_node->identifier);
397
 
398
                else
399
 
400
                        fprintf (f, "%s; ", cnet->identifier);
401
 
402
                wrapc++;
403
 
404
                if (wrapc == 8)
405
                {
406
                        wrapc = 0;
407
 
408
                        fprintf (f, "\n  ");
409
                }
410
 
411
                cnet = cnet->joined_nets;
412
        }
413
 
414
        fprintf (f, ");\n");
415
}
416
 
417
/* ********************************************************************** */
418
 
419
/* we are now one level down so it must be a join of some sort
420
 
421
   therefore join_parent is now valid */
422
 
423
static void list_subnets (FILE *f, net_t *cnet, JoinMode_t join)
424
 
425
{
426
        net_t *tnet = cnet;
427
 
428
        char *nettype;
429
 
430
        net_t *topname;
431
 
432
        while (tnet)
433
        {
434
                if (tnet->subnets)
435
 
436
                        list_subnets (f, tnet->subnets, join);
437
 
438
                tnet = tnet->joined_nets;
439
        }
440
 
441
        /* if we are interested in aliases, print these */
442
 
443
        /* Or if we are interested in joins print these */
444
 
445
        /*  printf("id %s join_parent %p howjoin %d\n",
446
 
447
              cnet->identifier,cnet->join_parent,cnet->how_joined); */
448
 
449
        if (cnet->join_parent->how_joined == join)
450
        {
451
                nettype = join == Aliased ? "ALIAS" : "JUMPER";
452
 
453
                list_join (f, nettype, cnet);
454
 
455
                topname = cnet;
456
 
457
                /* ascend jumper hierarchy to get the real name */
458
 
459
                while (topname->join_parent && ISNULLSTR (topname->name))
460
 
461
                        topname = topname->join_parent;
462
 
463
                if (join != Aliased && !ISNULLSTR (topname->name))
464
 
465
                        fprintf (f, " -- signal '%s' \n", topname->name);
466
 
467
                else
468
 
469
                        fprintf (f, "\n");
470
        };
471
}
472
 
473
/* ********************************************************************** */
474
 
475
/* this lists all joined nets. it is recursive. Any subnets will be explored
476
 
477
  before printing out the joins for this net if any are presaent */
478
 
479
static void list_joined_nets (FILE *f, net_t *cnet)
480
 
481
{
482
        if (!cnet)
483
 
484
                return;
485
 
486
        while (cnet)
487
        {
488
                /* if there are any subnets here, do the recursion on them */
489
 
490
                /*    printf("cnet = %p, subnets= %p \n",cnet,cnet->subnets); */
491
 
492
                if (cnet->subnets)
493
 
494
                        list_subnets (f, cnet->subnets, Jumpered);
495
 
496
                cnet = cnet->next;
497
        }
498
}
499
 
500
/************************************************************************/
501
 
502
static void list_routed_aliased_nets (FILE *f, net_t *cnet)
503
 
504
{
505
        if (!cnet)
506
 
507
                return;
508
 
509
        while (cnet)
510
        {
511
                net_t *unrouted = cnet->unrouted_reference;
512
 
513
                /* if there are any subnets here, do the recursion on them */
514
 
515
                /* this will find out aliases if they exist */
516
 
517
                if (unrouted && unrouted->subnets)
518
 
519
                        list_subnets (f, unrouted->subnets, Aliased);
520
 
521
                cnet = cnet->next;
522
        }
523
}
524
 
525
/************************************************************************/
526
 
527
static void list_aliased_nets (FILE *f, net_t *cnet)
528
 
529
{
530
        if (!cnet)
531
 
532
                return;
533
 
534
        while (cnet)
535
        {
536
                /* if there are any subnets here, do the recursion on them */
537
 
538
                /*    printf("cnet = %p, subnets= %p \n",cnet,cnet->subnets); */
539
 
540
                if (cnet->subnets)
541
 
542
                        list_subnets (f, cnet->subnets, Aliased);
543
 
544
                cnet = cnet->next;
545
        }
546
}
547
 
548
/************************************************************************/
549
 
550
void list_components (FILE *f)
551
 
552
{
553
        socket_t *cskt = sort_sockets (&socket_head);
554
 
555
        fprintf (f, "COMPONENTS\nBEGIN\n");
556
 
557
        while (cskt)
558
        {
559
                if (cskt->is_template)
560
 
561
                        fprintf (
562
                            f,
563
                            "-- %s : Socket Template\n",
564
 
565
                            cskt->type);
566
 
567
                else
568
 
569
                        fprintf (
570
                            f,
571
                            "  %s : \"%s\" \"%s\" \"%s\"; -- %s\n",
572
 
573
                            cskt->identifier,
574
 
575
                            check_null_str (cskt->name),
576
 
577
                            check_null_str (cskt->type),
578
 
579
                            check_null_str (cskt->value),
580
 
581
                            cskt->is_external ? "External" : "Internal");
582
 
583
                cskt = cskt->next;
584
        };
585
 
586
        fprintf (f, "END;\n\n");
587
}
588
 
589
/************************************************************************/
590
 
591
void list_database (FILE *f)
592
 
593
{
594
        list_components (f);
595
 
596
        fprintf (f, "WIRED_NETS\nBEGIN\n");
597
 
598
        fprintf (f, "-- Routed & Named nets follow   --\n");
599
 
600
        list_nets (f, named_list);
601
 
602
        fprintf (f, "-- Routed & unused nets follow   --\n");
603
 
604
        list_nets (f, routed_list);
605
 
606
        fprintf (f, "-- Unrouted nets follow --\n");
607
 
608
        list_nets (f, unrouted_list);
609
 
610
        fprintf (f, "END;\n\n");
611
}
612
 
613
/************************************************************************/
614
 
615
void list_jumper (FILE *f)
616
 
617
{
618
        fprintf (f, "-- Jumper list here --\n");
619
 
620
        fprintf (f, "JOINED_NETS\nBEGIN\n");
621
 
622
        list_joined_nets (f, named_list);
623
 
624
        list_joined_nets (f, routed_list);
625
 
626
        fprintf (f, "END;\n\n");
627
}
628
 
629
/************************************************************************/
630
 
631
void list_alias (FILE *f)
632
 
633
{
634
        fprintf (f, "-- Alias list here --\n");
635
 
636
        fprintf (f, "JOINED_NETS\nBEGIN\n");
637
 
638
        list_routed_aliased_nets (f, named_list);
639
 
640
        list_routed_aliased_nets (f, routed_list);
641
 
642
        list_aliased_nets (f, unrouted_list);
643
 
644
        fprintf (f, "END;\n\n");
645
}
646
 
647
/************************************************************************/
648
 
649
void list_joined (FILE *f)
650
 
651
{
652
        /* and now the joined nets */
653
 
654
        fprintf (f, "JOINED_NETS\nBEGIN\n");
655
 
656
        fprintf (f, "-- Jumper list here --\n");
657
 
658
        list_joined_nets (f, named_list);
659
 
660
        list_joined_nets (f, routed_list);
661
 
662
        fprintf (f, "-- Alias list here --\n");
663
 
664
        list_routed_aliased_nets (f, named_list);
665
 
666
        list_routed_aliased_nets (f, routed_list);
667
 
668
        list_aliased_nets (f, unrouted_list);
669
 
670
        fprintf (f, "END;\n\n");
671
}
672
 
673
/* ********************************************************************** */
674
 
675
/* if options & PRINT_ALL then print all known pins on the device */
676
 
677
/* if options & PRINT_TYPE then print the VHDL data type of this pin */
678
 
679
/* if options & PRINT_GENERIC then print out the device's generic map here also */
680
 
681
/* if options & PRINT_EXPAND_BUS then expand out the VHDL bus to individual wires */
682
 
683
/* if options & PRINT_GROUP      then print out the pin groups */
684
 
685
/* if options & PRINT_ROUTE_FLAGS then print out the routing flags  */
686
 
687
/* if options & PRINT_AS_UNROUTED then printout "UNROUTED" instead of any pindir info */
688
 
689
void print_device (FILE *f, socket_t *dev, int options)
690
 
691
{
692
        node_t *n;
693
 
694
        char *vhdl_bus_format = "_%d_";
695
 
696
        generic_info_t gen[1];
697
 
698
        /* sort all the nodes into alphabetical order */
699
 
700
        sort_nodes (dev);
701
 
702
        /* if we are using VHDL then look at the VHDL bus formatting tail*/
703
 
704
        if ((options & PRINT_EXPAND_BUS) &&
705
 
706
            get_generic_value (&global_generics, "vhdl_bus_format", gen) == IS_STRING)
707
 
708
                vhdl_bus_format = gen->valuename;
709
 
710
        /* if it hasnt got a name, use its identifier */
711
 
712
        if (!dev->is_template)
713
        {
714
                if (dev->name != NULL && dev->name[0])
715
 
716
                        fprintf (f, "CHIP %s\n", check_null_str (dev->name));
717
 
718
                else
719
 
720
                        fprintf (f, "CHIP %s\n", dev->identifier);
721
 
722
                fprintf (f, "BEGIN\n    DEVICE = \"%s\";\n", check_null_str (dev->type));
723
 
724
                fprintf (f, "--  DEV_IDENT \"%s\"\n", dev->identifier);
725
 
726
                if (options & PRINT_ROUTE_FLAGS && dev->route_flags)
727
 
728
                        fprintf (f, "    ROUTE_FLAGS = %d;\n", dev->route_flags);
729
 
730
                if (dev->is_external)
731
 
732
                        fprintf (f, "--  External Connection\n\n");
733
 
734
                else
735
 
736
                        fprintf (f, "--  Internal Socket\n\n");
737
 
738
                if (options & PRINT_GENERIC && dev->generics)
739
 
740
                        list_generic_values (f, &dev->generics, 2);
741
        }
742
 
743
        else
744
        {
745
                fprintf (f, "TEMPLATE \"%s\"\n", check_null_str (dev->name));
746
 
747
                fprintf (f, "BEGIN\n");
748
        };
749
 
750
        if (dev->is_template && dev->parent_template_ref)
751
        {
752
                fprintf (f, "  ALIAS \"%s\"\n", check_null_str (dev->name));
753
 
754
                n = NULL; /* alias templates have no nodes of their own */
755
        }
756
 
757
        else
758
 
759
                n = dev->nodes;
760
 
761
        while (n)
762
        {
763
                char tmp_name[MAXIDLEN], typ[MAXIDLEN], vhdltail[MAXIDLEN],
764
                    group_tail[MAXIDLEN];
765
 
766
                int iter, iter_hi, iter_low;
767
 
768
                vhdl_t *vhdl;
769
 
770
                if (n->net_assigned || (options & PRINT_ALL))
771
                {
772
                        /* there is a possibility here of printing
773
 
774
                           out a bus as separate signals */
775
 
776
                        if (n->orig_vhdltype) /* if a pin rename has taken place, use the
777
                                                 original name !! */
778
 
779
                                vhdl = n->orig_vhdltype;
780
 
781
                        else
782
 
783
                                vhdl = n->vhdltype;
784
 
785
                        if ((options & PRINT_EXPAND_BUS) && vhdl && vhdl->is_vector)
786
                        {
787
                                fprintf (
788
                                    f,
789
                                    "-- Bus expansion follows '%s'\n",
790
 
791
                                    decode_vhdl_bus (vhdltail, vhdl));
792
 
793
                                iter_hi = vhdl->high;
794
 
795
                                iter_low = vhdl->low;
796
 
797
                                if (iter_hi < iter_low)
798
                                {
799
                                        fprintf (f, "-- VHDL Range is backwards !! \n");
800
 
801
                                        iter_hi = vhdl->low;
802
 
803
                                        iter_low = vhdl->high;
804
                                };
805
                        }
806
 
807
                        else
808
                        {
809
                                iter_hi = 0;
810
 
811
                                iter_low = 0;
812
                        }
813
 
814
                        for (iter = iter_low; iter <= iter_hi; iter++)
815
                        {
816
                                /* create a tail on the signal name */
817
 
818
                                vhdltail[0] = '\0';
819
 
820
                                if (vhdl && vhdl->is_vector)
821
 
822
                                        sprintf (
823
                                            vhdltail,
824
                                            vhdl_bus_format,
825
                                            iter); /* this should be a template : setup in
826
                                                      symbol table */
827
 
828
                                if (options & PRINT_USABLE)
829
                                {
830
                                        if (n->routed_net)
831
 
832
                                                sprintf (
833
                                                    tmp_name,
834
                                                    "\"%s%s\"",
835
                                                    check_null_str (n->net->identifier),
836
                                                    vhdltail);
837
 
838
                                        else
839
 
840
                                                sprintf (tmp_name, "\"unknown_net\"");
841
                                }
842
 
843
                                else
844
 
845
                                        sprintf (
846
                                            tmp_name,
847
                                            "\"%s%s\"",
848
                                            check_null_str (n->name),
849
                                            vhdltail);
850
 
851
                                group_tail[0] = '\0';
852
 
853
                                if ((options & PRINT_GROUP) && n->pin_group)
854
 
855
                                        sprintf (group_tail, "(%d)", n->pin_group);
856
 
857
                                fprintf (
858
                                    f,
859
                                    "    %-32s : ",
860
 
861
                                    tmp_name);
862
 
863
                                if (options & PRINT_AS_UNROUTED)
864
 
865
                                        fprintf (f, "UNROUTED ");
866
 
867
                                else
868
 
869
                                        fprintf (
870
                                            f,
871
                                            "%s%s = %4s%s ",
872
 
873
                                            decode_pin[(int) n->pindir],
874
 
875
                                            group_tail,
876
 
877
                                            n->identifier,
878
 
879
                                            vhdltail);
880
 
881
                                if (options & PRINT_TYPE)
882
                                {
883
                                        if (!vhdl) /* VHDL base types only are printed here as
884
 
885
                                                             vectors are expanded */
886
 
887
                                                fprintf (
888
                                                    f,
889
                                                    " : %s",
890
                                                    default_vhdl_datatype->basetype);
891
 
892
                                        else
893
 
894
                                                fprintf (f, " : %s", vhdl->basetype);
895
                                }
896
 
897
                                fprintf (
898
                                    f,
899
                                    "; -- refs=%d %s %s %n\n",
900
 
901
                                    n->refcount,
902
 
903
                                    n->fixed_pin ? "fixed" : "",
904
 
905
                                    n->in_use ? "in use" : "unused",
906
 
907
                                    n->net_assigned ? "net assigned" : "");
908
                        };
909
                }
910
 
911
                n = n->sktnext; /* traverse to next pin on socket */
912
        };
913
 
914
        fprintf (f, "END;\n\n");
915
}
916
 
917
/************************************************************************/
918
 
919
/* this function prints the 'entity' of a top level of a partition as an
920
 
921
   ACFP file */
922
 
923
void print_ACF_entity (FILE *f, char *entityname)
924
 
925
{
926
        net_t *net = named_list;
927
 
928
        int pin_num = 1;
929
 
930
        fprintf (f, "CHIP %s\n", entityname);
931
 
932
        fprintf (f, "BEGIN\n    DEVICE = \"VHDL-TOP\";\n");
933
 
934
        while (net)
935
        {
936
                if (net->leaves_partition)
937
                {
938
                        char nam[MAXIDLEN], typ[MAXIDLEN];
939
 
940
                        sprintf (nam, "\"%s\"", check_null_str (net->name));
941
 
942
                        fprintf (
943
                            f,
944
                            "    %-32s : %5s = \"%d\" ",
945
 
946
                            nam,
947
 
948
                            decode_pin[(int) net->ext_dir],
949
 
950
                            pin_num++);
951
 
952
                        fprintf (
953
                            f,
954
                            " : \"%s\";\n",
955
 
956
                            decode_vhdl_type (typ, net->vhdltype));
957
                }
958
 
959
                net = net->next;
960
        }
961
 
962
        fprintf (f, "END; -- %s\n\n", entityname);
963
}
964
 
965
/************************************************************************/
966
 
967
/* devices are always listed in acfp files with VHDL data types */
968
 
969
void list_devices (FILE *f)
970
 
971
{
972
        socket_t *dev;
973
 
974
        dev = socket_head;
975
 
976
        while (dev)
977
 
978
        {
979
                /* only print named devices !!! */
980
 
981
                if (dev->name[0] != 0 && dev->name != nullstr)
982
 
983
                        print_device (
984
                            f,
985
                            dev,
986
 
987
                            PRINT_TYPE | PRINT_EXPAND_BUS |
988
 
989
                                PRINT_GENERIC | PRINT_GROUP |
990
 
991
                                PRINT_ROUTE_FLAGS);
992
 
993
                dev = dev->next;
994
        };
995
}
996
 
997
/************************************************************************/
998
 
999
/* devices are always listed in acfp files with VHDL data types */
1000
 
1001
/* only those with their is_external flags set */
1002
 
1003
void list_extern_devices (FILE *f)
1004
 
1005
{
1006
        socket_t *dev;
1007
 
1008
        dev = socket_head;
1009
 
1010
        while (dev)
1011
 
1012
        {
1013
                /* only print external devices !!! */
1014
 
1015
                if (dev->is_external)
1016
 
1017
                        print_device (f, dev, PRINT_TYPE);
1018
 
1019
                dev = dev->next;
1020
        };
1021
}
1022
 
1023
/************************************************************************/
1024
 
1025
static int list_pin_renames (net_t *list, FILE *f, int any_renames_seen)
1026
{
1027
        noderef_t *nodes, *ref;
1028
 
1029
        int ref_renames_seen;
1030
 
1031
        char vhdltext[MAXIDLEN];
1032
 
1033
        if (!list)
1034
                return any_renames_seen;
1035
 
1036
        while (list)
1037
        {
1038
                nodes = list->nodes;
1039
 
1040
                while (nodes)
1041
                {
1042
                        ref = nodes->base_noderef;
1043
 
1044
                        if (ref->orig_name)
1045
                        {
1046
                                if (!any_renames_seen)
1047
                                { /* overall, start the list if there is a rename */
1048
 
1049
                                        fprintf (f, "RENAME_PINS\n BEGIN\n");
1050
 
1051
                                        any_renames_seen = 1;
1052
                                }
1053
 
1054
                                if (ref->orig_vhdltype)
1055
 
1056
                                        fprintf (
1057
                                            f,
1058
                                            "  %s%s = ( ",
1059
                                            list->identifier,
1060
                                            decode_vhdl_bus (vhdltext, ref->vhdltype));
1061
 
1062
                                else
1063
 
1064
                                        fprintf (f, "  %s = ( ", list->identifier);
1065
 
1066
                                fprintf (
1067
                                    f, "%s.%s;);\n", ref->node->socket->name, ref->orig_name);
1068
                        }
1069
 
1070
                        nodes = nodes->next;
1071
                }
1072
 
1073
                list = list->next;
1074
        }
1075
 
1076
        return (any_renames_seen);
1077
}
1078
 
1079
/************************************************************************/
1080
 
1081
void print_pin_renames (FILE *f)
1082
{
1083
        int any_renames_seen = 0;
1084
 
1085
        fprintf (f, "-- pin renames on unrouted list follow --\n");
1086
 
1087
        list_pin_renames (unrouted_list, f, any_renames_seen);
1088
 
1089
        fprintf (f, "-- pin renames on routed list follow   --\n");
1090
 
1091
        any_renames_seen = list_pin_renames (routed_list, f, any_renames_seen);
1092
 
1093
        fprintf (f, "-- pin renames on named list follow    --\n");
1094
 
1095
        any_renames_seen = list_pin_renames (named_list, f, any_renames_seen);
1096
 
1097
        if (any_renames_seen)
1098
 
1099
                fprintf (f, "END;\n");
1100
}
1101
 
1102
/************************************************************************/
1103
 
1104
/************************************************************************/
1105
 
1106
/* and now for the FRB formatted stuff                                  */
1107
 
1108
/* prints a frb formatted net   */
1109
 
1110
void frb_list_net (FILE *f, net_t *cnet)
1111
 
1112
{
1113
        noderef_t *bnode;
1114
 
1115
        node_t *cnode;
1116
 
1117
        bnode = cnet->nodes;
1118
 
1119
        if (bnode)
1120
        { /* only print out a net that has at leat one node on it */
1121
 
1122
                cnode = bnode->node;
1123
 
1124
                fprintf (
1125
                    f,
1126
                    ".ADD_TER %s %s %s\n",
1127
 
1128
                    cnode->socket->identifier,
1129
 
1130
                    cnode->identifier,
1131
 
1132
                    cnet->identifier);
1133
 
1134
                bnode = bnode->next;
1135
 
1136
                if (bnode)
1137
 
1138
                        fprintf (f, ".TER\n");
1139
 
1140
                while (bnode)
1141
                {
1142
                        cnode = bnode->node;
1143
 
1144
                        fprintf (f, "%s %s\n", cnode->socket->identifier, cnode->identifier);
1145
 
1146
                        bnode = bnode->next;
1147
                };
1148
 
1149
                fprintf (f, "\n");
1150
        };
1151
}
1152
 
1153
/* ********************************************************************** */
1154
 
1155
/* only jumpered nets are permitted to be listed as separate physical nets*/
1156
 
1157
/* aliased nets cannot, as they are asingle physical net */
1158
 
1159
void frb_list_net_connections (FILE *f, net_t *cnet)
1160
 
1161
{
1162
        while (cnet)
1163
        {
1164
                net_t *subnet = cnet->subnets;
1165
 
1166
                if (subnet && cnet->how_joined == Jumpered)
1167
                {
1168
                        while (subnet)
1169
                        {
1170
                                frb_list_net (f, subnet);
1171
 
1172
                                subnet = subnet->subnets;
1173
                        }
1174
                }
1175
 
1176
                else
1177
 
1178
                        frb_list_net (f, cnet);
1179
 
1180
                cnet = cnet->next;
1181
        };
1182
}
1183
 
1184
/* ********************************************************************** */
1185
 
1186
void produce_frb (FILE *f)
1187
 
1188
{
1189
        time_t now;
1190
 
1191
        struct tm *tim;
1192
 
1193
        socket_t *dev;
1194
 
1195
        time (&now);
1196
 
1197
        tim = localtime (&now);
1198
 
1199
        fprintf (
1200
            f,
1201
            ".HEA\n.TIM         %4d %02d %02d %02d %02d %02d\n",
1202
 
1203
            tim->tm_year + 1900,
1204
 
1205
            tim->tm_mon + 1, /* tm_mon has range 0..11 (jan=0) */
1206
 
1207
            tim->tm_mday, /* but tm_mday has range 1..31 !! */
1208
 
1209
            tim->tm_hour,
1210
 
1211
            tim->tm_min,
1212
 
1213
            tim->tm_sec);
1214
 
1215
        fprintf (f, ".JOB               J_%d\n", now);
1216
 
1217
        fprintf (f, ".TYP               FULL\n");
1218
 
1219
        fprintf (f, ".APP               \"Neutral Architecture File\"\n\n");
1220
 
1221
        dev = socket_head;
1222
 
1223
        while (dev)
1224
        {
1225
                /* only print named devices !!! */
1226
 
1227
                fprintf (
1228
                    f,
1229
                    ".ADD_COM %s %s %s\n",
1230
 
1231
                    dev->identifier,
1232
 
1233
                    dev->type,
1234
 
1235
                    dev->value);
1236
 
1237
                dev = dev->next;
1238
        }
1239
 
1240
        fprintf (f, "\n\n");
1241
 
1242
        frb_list_net_connections (f, named_list);
1243
 
1244
        frb_list_net_connections (f, routed_list);
1245
 
1246
        fprintf (f, ".END\n");
1247
}
1248
 
1249
/* ********************************************************************** */
1250
 
1251
/* puts a comment on the head of the file */
1252
 
1253
void print_header (FILE *f, char *tool)
1254
 
1255
{
1256
        time_t now;
1257
 
1258
        struct tm *tim;
1259
 
1260
        time (&now);
1261
 
1262
        tim = localtime (&now);
1263
 
1264
        fprintf (f, "--       Altera EPLD / PCB / VHDL tools        --\n");
1265
 
1266
        fprintf (f, "-- (c) Philips Semiconductors Southampton 1996-1999 --\n\n");
1267
 
1268
        fprintf (f, "-- by: Mike James (Mike.James@soton.sc.philips.com)\n\n");
1269
 
1270
        fprintf (
1271
            f,
1272
            "-- Produced by %s\n-- at %02d:%02d:%02d    on %02d/%02d/%4d \n\n",
1273
 
1274
            tool,
1275
 
1276
            tim->tm_hour,
1277
 
1278
            tim->tm_min,
1279
 
1280
            tim->tm_sec,
1281
 
1282
            tim->tm_mday,
1283
 
1284
            tim->tm_mon + 1,
1285
 
1286
            tim->tm_year + 1900);
1287
}
1288
 
1289
/* ********************************************************************** */
1290
 
1291
/* VHDL output of the entities                                            */
1292
 
1293
/* ********************************************************************** */
1294
 
1295
char *make_vhdl_name (char *buffer, char *str)
1296
 
1297
{
1298
        int i, l;
1299
 
1300
        strcpy (buffer, str); /* should be a call to strncpy !! */
1301
 
1302
        l = strlen (buffer);
1303
 
1304
        /* edit out illegal strings from the net name */
1305
 
1306
        for (i = 0; i < l; i++)
1307
        {
1308
                if (buffer[i] == ':' || buffer[i] == '|')
1309
 
1310
                        buffer[i] = 'X';
1311
        }
1312
 
1313
        i = l - 1;
1314
 
1315
        /* convert pin indices back from Altera form if we are looking at FIT files */
1316
 
1317
        if (l)
1318
        {
1319
                /* name ends in underscore, this forces mapping name_nn_ --> name(nn) */
1320
 
1321
                if (buffer[i] == '_')
1322
                {
1323
                        buffer[i--] = ')';
1324
 
1325
                        while (i >= 0 && buffer[i] != '_')
1326
 
1327
                                i--;
1328
 
1329
                        if (i >= 0)
1330
 
1331
                                buffer[i] = '(';
1332
                }
1333
        }
1334
 
1335
        return buffer;
1336
}
1337
 
1338
/* ********************************************************************** */
1339
 
1340
/* print out a VHDL component declaration */
1341
 
1342
void print_VHDL_component (FILE *f, socket_t *dev, int All)
1343
 
1344
{
1345
        node_t *n;
1346
 
1347
        /* sort the identifiers of the nodes */
1348
 
1349
        sort_nodes (dev);
1350
 
1351
        fprintf (f, "COMPONENT  %s\n", check_null_str (dev->name));
1352
 
1353
        fprintf (f, "--  DEV_IDENT \"%s\"\n\n", check_null_str (dev->identifier));
1354
 
1355
        fprintf (f, "  PORT ( \n");
1356
 
1357
        /* sort the identifiers of the nodes */
1358
 
1359
        sort_nodes (dev);
1360
 
1361
        n = dev->nodes;
1362
 
1363
        while (n)
1364
 
1365
        {
1366
                vhdl_t *pin_datatype = default_vhdl_datatype;
1367
 
1368
                char nam[MAXIDLEN], typ[MAXIDLEN];
1369
 
1370
                if (n->orig_vhdltype)
1371
 
1372
                        pin_datatype = n->orig_vhdltype;
1373
 
1374
                else if (n->vhdltype)
1375
 
1376
                        pin_datatype = n->vhdltype;
1377
 
1378
                if (n->net_assigned && n->in_use || All)
1379
                {
1380
                        fprintf (
1381
                            f,
1382
                            "  %-16s : %6s %10s ",
1383
 
1384
                            make_vhdl_name (nam, check_null_str (n->name)),
1385
 
1386
                            decode_pin_VHDL[(int) n->pindir],
1387
 
1388
                            decode_vhdl_type (typ, pin_datatype));
1389
 
1390
                        if (n->sktnext)
1391
 
1392
                                fprintf (f, ";");
1393
 
1394
                        fprintf (
1395
                            f,
1396
                            " -- i=%s r=%d --\n",
1397
 
1398
                            n->identifier,
1399
 
1400
                            n->refcount);
1401
                }
1402
 
1403
                n = n->sktnext; /* traverse to next pin on socket */
1404
        };
1405
 
1406
        fprintf (f, ");\nEND COMPONENT;\n\n");
1407
}
1408
 
1409
/* ********************************************************************** */
1410
 
1411
/* Printout an instance of a component */
1412
 
1413
/* ********************************************************************** */
1414
 
1415
void print_VHDL_instance (FILE *f, socket_t *dev, int All)
1416
 
1417
{
1418
        node_t *n;
1419
 
1420
        int need_term = 0;
1421
 
1422
        fprintf (
1423
            f,
1424
            "%s_inst :  %s \n",
1425
 
1426
            check_null_str (dev->name),
1427
 
1428
            check_null_str (dev->name));
1429
 
1430
        fprintf (f, "--  DEV_IDENT \"%s\"\n\n", check_null_str (dev->identifier));
1431
 
1432
        fprintf (f, "  PORT MAP ( \n");
1433
 
1434
        /* sort the identifiers of the nodes */
1435
 
1436
        sort_nodes (dev);
1437
 
1438
        n = dev->nodes;
1439
 
1440
        while (n)
1441
 
1442
        {
1443
                vhdl_t *pin_datatype = default_vhdl_datatype;
1444
 
1445
                char nam1[MAXIDLEN], nam2[MAXIDLEN], vhdlname[MAXIDLEN];
1446
 
1447
                if (n->vhdltype)
1448
 
1449
                        pin_datatype = n->vhdltype;
1450
 
1451
                if (n->net_assigned && n->in_use || All)
1452
                {
1453
                        char *sig_prefix;
1454
 
1455
                        if (need_term)
1456
 
1457
                                fprintf (f, ",\n");
1458
 
1459
                        else
1460
 
1461
                                fprintf (f, "\n");
1462
 
1463
                        need_term = 1;
1464
 
1465
                        /* is there a slice in the output */
1466
 
1467
                        if (n->net->needs_buff_sig)
1468
 
1469
                                sig_prefix = BUFPREFIX;
1470
 
1471
                        else
1472
 
1473
                                sig_prefix = "";
1474
 
1475
                        fprintf (
1476
                            f,
1477
                            "  %-20s => %s%s %s ",
1478
 
1479
                            make_vhdl_name (nam1, check_null_str (n->name)),
1480
 
1481
                            sig_prefix,
1482
 
1483
                            make_vhdl_name (nam2, check_null_str (n->net->name)),
1484
 
1485
                            decode_vhdl_bus (vhdlname, n->vhdltype));
1486
                }
1487
 
1488
                n = n->sktnext; /* traverse to next pin on socket */
1489
        };
1490
 
1491
        fprintf (f, "\n   );\n\n");
1492
}
1493
 
1494
/* ********************************************************************** */
1495
 
1496
void print_VHDL_sigs (FILE *f)
1497
 
1498
{
1499
        net_t *net = named_list;
1500
 
1501
        char nam[MAXIDLEN], typ[MAXIDLEN], *sig_prefix;
1502
 
1503
        while (net)
1504
        {
1505
                if (net->needs_buff_sig)
1506
 
1507
                        sig_prefix = BUFPREFIX;
1508
 
1509
                else
1510
 
1511
                        sig_prefix = "";
1512
 
1513
                if (net->inside_partition)
1514
                {
1515
                        fprintf (
1516
                            f,
1517
                            " SIGNAL %s%s : %s;",
1518
 
1519
                            sig_prefix,
1520
 
1521
                            make_vhdl_name (nam, net->name),
1522
 
1523
                            decode_vhdl_type (typ, net->vhdltype));
1524
                }
1525
 
1526
                else
1527
 
1528
                        fprintf (
1529
                            f,
1530
                            "  -- net '%s%s : %sl",
1531
 
1532
                            sig_prefix,
1533
 
1534
                            make_vhdl_name (nam, net->name),
1535
 
1536
                            decode_vhdl_type (typ, net->vhdltype));
1537
 
1538
                fprintf (
1539
                    f,
1540
                    " -- partition : %s, %s, %s --\n",
1541
 
1542
                    net->inside_partition ? "used in" : "unused in",
1543
 
1544
                    net->leaves_partition ? "leaves" : "buried ",
1545
 
1546
                    net->needs_buff_sig ? ", buffered" : "");
1547
 
1548
                net = net->next;
1549
        }
1550
}
1551
 
1552
/* ********************************************************************** */
1553
 
1554
void print_VHDL_assignments (FILE *f)
1555
 
1556
{
1557
        net_t *net = named_list;
1558
 
1559
        fprintf (f, "-- Buffered signals\n\n");
1560
 
1561
        while (net)
1562
        {
1563
                if (net->inside_partition && net->needs_buff_sig)
1564
                {
1565
                        char nam[MAXIDLEN];
1566
 
1567
                        make_vhdl_name (nam, net->name),
1568
 
1569
                            fprintf (
1570
                                f,
1571
                                " %s <= " BUFPREFIX "%s;\n",
1572
 
1573
                                nam,
1574
                                nam);
1575
                }
1576
 
1577
                net = net->next;
1578
        }
1579
 
1580
        fprintf (f, "-- \n\n");
1581
}
1582
 
1583
/* ********************************************************************** */
1584
 
1585
void print_VHDL_entity (FILE *f, char *entityname)
1586
 
1587
{
1588
        net_t *net = named_list;
1589
 
1590
        int need_term = 0;
1591
 
1592
        fprintf (f, "ENTITY %s IS\n  PORT (\n", entityname);
1593
 
1594
        while (net)
1595
        {
1596
                char nam[MAXIDLEN], typ[MAXIDLEN];
1597
 
1598
                if (net->leaves_partition)
1599
                {
1600
                        if (need_term)
1601
 
1602
                                fprintf (f, ";\n");
1603
 
1604
                        else
1605
 
1606
                                fprintf (f, "\n");
1607
 
1608
                        fprintf (
1609
                            f,
1610
                            "  %-15s : %6s %10s",
1611
 
1612
                            make_vhdl_name (nam, net->name),
1613
 
1614
                            decode_pin_VHDL[net->ext_dir],
1615
 
1616
                            decode_vhdl_type (typ, net->vhdltype));
1617
 
1618
                        need_term = 1;
1619
                }
1620
 
1621
                net = net->next;
1622
        }
1623
 
1624
        fprintf (f, "\n     );\n");
1625
 
1626
        fprintf (f, "END %s;\n\n", entityname);
1627
}
1628
 
1629
/* ********************************************************************** */
1630
 
1631
/* generate default VHDL Libraries */
1632
 
1633
/* ********************************************************************** */
1634
 
1635
void print_VHDL_libs (FILE *f)
1636
 
1637
{
1638
        fprintf (f, "LIBRARY IEEE,WORK;\nUSE IEEE.std_logic_1164.ALL;\n\n");
1639
}
1640
 
1641
/* ********************************************************************** */
1642
 
1643
/* generate a VHDL architecture forselected sockets */
1644
 
1645
/* ********************************************************************** */
1646
 
1647
void print_VHDL_architecture (FILE *f, char *entityname)
1648
{
1649
        socket_t *skt;
1650
 
1651
        fprintf (f, "\n\nARCHITECTURE top OF  %s IS\n\n", entityname);
1652
 
1653
        skt = socket_head;
1654
 
1655
        while (skt)
1656
        {
1657
                if (skt->selected)
1658
 
1659
                        print_VHDL_component (f, skt, 0);
1660
 
1661
                skt = skt->next;
1662
        }
1663
 
1664
        print_VHDL_sigs (f);
1665
 
1666
        fprintf (f, "\n\nBEGIN\n\n");
1667
 
1668
        skt = socket_head;
1669
 
1670
        while (skt)
1671
        {
1672
                if (skt->selected)
1673
 
1674
                        print_VHDL_instance (f, skt, 0);
1675
 
1676
                skt = skt->next;
1677
        }
1678
 
1679
        print_VHDL_assignments (f);
1680
 
1681
        fprintf (f, "END top;\n\n");
1682
}
1683
 
1684
/* ********************************************************************** */
1685
 
1686
/* generate a VHDL file */
1687
 
1688
/* ********************************************************************** */
1689
 
1690
void produce_VHDL (FILE *f, char *entityname, char *template)
1691
{
1692
        char linebuff[256];
1693
 
1694
        int done_entity = 0, done_architecture = 0;
1695
 
1696
        if (!template || !template[0])
1697
        { /* check null pointer or empty string */
1698
 
1699
                print_header (f, "WRITE VHDL");
1700
 
1701
                print_VHDL_libs (f);
1702
 
1703
                print_VHDL_entity (f, entityname);
1704
 
1705
                print_VHDL_libs (f);
1706
 
1707
                print_VHDL_architecture (f, entityname);
1708
        }
1709
 
1710
        else
1711
        { /* there is a template file */
1712
 
1713
                FILE *tp;
1714
 
1715
                tp = fopen (template, "r");
1716
 
1717
                if (tp)
1718
                {
1719
                        print_header (f, "WRITE VHDL");
1720
 
1721
                        fprintf (f, "-- Using template '%s'\n", template);
1722
 
1723
                        while (!feof (tp))
1724
                        {
1725
                                if (fgets (linebuff, 256, tp))
1726
                                {
1727
                                        if (strstr (linebuff, "$ENT"))
1728
                                        {
1729
                                                print_VHDL_entity (f, entityname);
1730
 
1731
                                                done_entity++;
1732
                                        }
1733
 
1734
                                        else if (strstr (linebuff, "$ARCH"))
1735
                                        {
1736
                                                print_VHDL_architecture (f, entityname);
1737
 
1738
                                                done_architecture++;
1739
                                        }
1740
 
1741
                                        else
1742
 
1743
                                                fprintf (f, "%s", linebuff); /* it already has
1744
                                                                                a '\n' on the
1745
                                                                                end */
1746
                                }
1747
                        }
1748
 
1749
                        fclose (tp);
1750
 
1751
                        if (done_entity != 1)
1752
 
1753
                                Log (
1754
                                    LOG_ERROR,
1755
                                    "-- Error: %d  $ENT$ tags counted in template '%s'\n",
1756
                                    template);
1757
 
1758
                        if (done_architecture != 1)
1759
 
1760
                                Log (
1761
                                    LOG_ERROR,
1762
                                    "-- Error: %d  $ARCH$ tags counted in template '%s'\n",
1763
                                    template);
1764
                }
1765
 
1766
                else
1767
 
1768
                        Log (
1769
                            LOG_ERROR,
1770
                            "-- Error: Cannot open VHDL  template '%s'\n",
1771
                            template);
1772
        }
1773
}
1774
 
1775
/**********************************************************/
1776
 
1777
/* Database diagnostics                                   */
1778
 
1779
/**********************************************************/
1780
 
1781
void deb_print_node (FILE *f, node_t *n)
1782
 
1783
{
1784
        fprintf (f, "--Node--\n");
1785
 
1786
        /*  struct node * sktnext; linked to a socket */
1787
 
1788
        fprintf (f, "next->%p\n", n->sktnext);
1789
 
1790
        /* char * identifier;   e.g 102, A22 */
1791
 
1792
        fprintf (f, "identifier %s\n", n->identifier);
1793
 
1794
        /* char * name;        signal name (actually same as netname )  */
1795
 
1796
        fprintf (f, "name      %s\n", check_null_str (n->name));
1797
 
1798
        /* vhdl_t * vhdltype; */
1799
 
1800
        fprintf (f, "vhdltype  %p\n", decode_vhdl_type (n->vhdltype));
1801
 
1802
        /* vhdl_t * orig_vhdltype; */
1803
 
1804
        fprintf (f, "orig_vhdltype  %p\n", decode_vhdl_type (n->orig_vhdltype));
1805
 
1806
        /* pindir_t   pindir;       final pin type input? output? bidir? unknown? */
1807
 
1808
        fprintf (f, "pindir    %s\n", decode_pin[n->pindir]);
1809
 
1810
        /* struct net * net;     refer to net this node is on (if known) */
1811
 
1812
        fprintf (f, "net       %p\n", n->net);
1813
 
1814
        if (n->net)
1815
 
1816
                fprintf (f, "  (id '%s')\n", check_null_str (n->net->identifier));
1817
 
1818
        /* struct net * net;     refer to net this node is on (if known) */
1819
 
1820
        fprintf (f, "routed net       %p\n", n->net);
1821
 
1822
        if (n->net)
1823
 
1824
                fprintf (f, "  (id '%s')\n", check_null_str (n->net->identifier));
1825
 
1826
        /*  int    refcount;     how many nets refer to this node */
1827
 
1828
        fprintf (f, "refcount  %d\n", n->refcount);
1829
 
1830
        /* struct socket * socket;   refer to socket this node is part of   */
1831
 
1832
        fprintf (f, "socket    %p\n", n->socket);
1833
 
1834
        if (n->socket)
1835
 
1836
                fprintf (f, "  socket (id '%s')\n", check_null_str (n->socket->identifier));
1837
 
1838
        /* unsigned int fixed_pin:1; if fixed_pin = 1 then this pin can only be used
1839
 
1840
                                    to connect to the net in a particular
1841
 
1842
                                    direction */
1843
 
1844
        fprintf (f, "fixed_pin:  %s\n", n->fixed_pin ? "yes" : "no");
1845
 
1846
        /* unsigned int in_use:1;    if '1' the node is used by a pin
1847
 
1848
                                    if '0' the node has had a dummy name assigned*/
1849
 
1850
        fprintf (f, "in_use:     %s\n", n->in_use ? "yes" : "no");
1851
 
1852
        /* unsigned int net_assigned:1;  if '1' the node (name) has a net assigned
1853
 
1854
                                        to it by routing */
1855
 
1856
        fprintf (f, "net_assigned:  %s\n", n->net_assigned ? "yes" : "no");
1857
 
1858
        fprintf (f, "-- End Node--\n");
1859
}