Subversion Repositories Vertical

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/*
11 mjames 2
 * $Id: template.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $ * This file ensures that for all sockets that are in
2 mjames 3
 *
4
 * $Log: template.c,v $
5
 * Revision 1.1.1.1  2003/11/04 23:34:57  mjames
6
 * Imported into local repositrory
7
 *
8
 * Revision 1.22  2003/01/02 21:37:18  mjames
9
 * Experiment on creating NOT_ROUTABLE_H and NOT_ROUTABLE_L
10
 * properties on the nets so that pin jumpers can be made without a problem.
11
 *
12
 * Still need to sort out pin assignments made to these not_routable nets
13
 * which will become legal in some cases so that pullups and pulldown
14
 * pins can be used on the FPGA.
15
 *
16
 * Revision 1.21  2002/12/09 10:31:50  mjames
17
 * Corrected 2 warnings about #ident
18
 * Added warning about "chip X1" which gets confused with component called "X1"
19
 *
20
 * Revision 1.20  2002/09/18 08:50:48  mjames
21
 * Cleared 'use before assign' warning
22
 *
23
 * Revision 1.19  2002/09/09 10:14:26  mjames
24
 * Moved pin remapping function to pin ident editing function from
25
 * sorting pin name routine.
26
 *
27
 * Revision 1.18  2002/09/09 09:51:27  mjames
28
 * Change to #ident
29
 *
30
 * Revision 1.17  2001/12/20 13:38:57  mjames
31
 * Forced net not routable if fpga pin is disconnected from it. Brutal
32
 *
33
 * Revision 1.16  2001/12/11 21:26:18  mjames
34
 * Corrected pin deletion by setting correct flags.
35
 *
36
 * Revision 1.15  2001/11/30 22:24:35  mjames
37
 * Improved diagnostic debug messages.
38
 * Used the correct sense of missing template
39
 * pins to remove unused pins of the component.
40
 *
41
 * Revision 1.14  2001/11/19 10:41:34  mjames
42
 * Merged back DTC release
43
 *
44
 * Revision 1.13.2.1  2001/11/15 22:01:53  mjames
45
 * Added counters for diagnostics
46
 *
47
 * Revision 1.13  2001/11/01 11:01:33  mjames
48
 * Template pins are created whether or not a net is routable.
49
 *
50
 * Revision 1.12  2001/10/31 22:20:18  mjames
51
 * Tidying up problematical comments caused by CVS
52
 * 'intelligent' comment guessing
53
 *
54
 * Revision 1.11  2001/10/31 16:18:04  mjames
55
 * Added a datastructure to hide regular expression information from programs.
56
 * Changed call to regexec to indicate 0 subexpressions to be matched
57
 * rather than a number dependent on strlen(string) which was wrong.
58
 *
59
 * Revision 1.10  2001/10/22 10:45:45  mjames
60
 * Added template options to create and /or disconnect pins on
61
 * sockets according to flags passed in to the template core routine
62
 *
63
 * Revision 1.9  2001/10/10 20:18:20  mjames
64
 * Added a vert_regcomp function to compile regular expressions
65
 * with '^' (match start string) and  '$' (match end string) bracketing
66
 * this => wildcard must match entire string not just a part of it.
67
 *
68
 * Revision 1.8  2001/10/10 12:49:47  mjames
69
 * Passed wrong argument to wildcard validator within template ensure . Fixed
70
 *
71
 * Revision 1.7  2001/10/07 20:50:51  mjames
72
 * Added wildcard checking (warn user about
73
 * using wildcard '*' on the end of a string in stead of wildcard '.*')
74
 *
75
 * Revision 1.6  2001/09/25 23:15:22  mjames
76
 * Converted wildcards to use proper regexp pattern match library
77
 *
78
 * Revision 1.5  2001/09/21 14:23:28  mjames
79
 * Cleared out template flags before checking pin compatibility rather than
80
 * while checking.
81
 *
82
 * Revision 1.4  2001/07/16 15:54:57  MJAMES
83
 * Conversion to correctly print port list of  extracted components.
84
 *
85
 * Revision 1.3  2001/06/22 11:08:07  mjames
86
 * Added a function to extract templates (common component types) from
87
 * ACF style netlists. This then permits Verilog printout to avoid duplication
88
 * of declaration ( problem before )
89
 *
90
 * Revision 1.2  2001/06/06 12:10:17  mjames
91
 * Move from HPUX
92
 *
93
 * Revision 1.1.1.1  2000/10/19 21:58:40  mjames
94
 * Mike put it here
95
 *
96
 *
97
 * Revision 1.32  2000/10/12  14:27:52  14:27:52  mjames (Mike James)
98
 * changed listing vhdl signals to expand expressions
11 mjames 99
 * until a constant is located
100
 *
2 mjames 101
 * Revision 1.31  2000/10/04  10:37:10  10:37:10  mjames (Mike James)
102
 * Modified for Vertical2 : support COMPONENTS and SIGNALS
11 mjames 103
 *
2 mjames 104
 * Revision 1.31  2000/10/04  10:37:10  10:37:10  mjames (Mike James)
105
 * Part of Release PSAVAT01
11 mjames 106
 *
2 mjames 107
 * Revision 1.30  2000/10/02  11:04:21  11:04:21  mjames (Mike James)
108
 * new_vhdl
11 mjames 109
 *
2 mjames 110
 * Revision 1.29  2000/09/27  14:42:22  14:42:22  mjames (Mike James)
111
 * Part of Release Sep_27_ST_2000
11 mjames 112
 *
2 mjames 113
 * Revision 1.28  2000/09/21  10:15:52  10:15:52  mjames (Mike James)
114
 * Part of Release Sep21Alpha
11 mjames 115
 *
2 mjames 116
 * Revision 1.27  2000/09/21  09:47:46  09:47:46  mjames (Mike James)
11 mjames 117
 * Added code to handle pin equivalents in templates
2 mjames 118
 * calling a function to copy over the pin equivalnets
119
 * from a template.
11 mjames 120
 *
121
 *
2 mjames 122
 * Revision 1.26  2000/08/25  09:57:17  09:57:17  mjames (Mike James)
123
 * Part of Release Aug25_alpha
11 mjames 124
 *
2 mjames 125
 * Revision 1.25  2000/08/16  08:57:33  08:57:33  mjames (Mike James)
126
 * Part of Release CD01_Aug2000
11 mjames 127
 *
2 mjames 128
 * Revision 1.24  2000/08/14  14:45:14  14:45:14  mjames (Mike James)
129
 * Part of Release Aug_14_2000
11 mjames 130
 *
2 mjames 131
 * Revision 1.23  2000/08/14  14:43:37  14:43:37  mjames (Mike James)
132
 * Added power pins
11 mjames 133
 *
2 mjames 134
 * Revision 1.22  2000/08/11  08:30:34  08:30:34  mjames (Mike James)
135
 * Part of Release Aug_11_2000
11 mjames 136
 *
2 mjames 137
 * Revision 1.21  2000/08/09  10:31:50  10:31:50  mjames (Mike James)
138
 * Part of Release Aug__9_2000
11 mjames 139
 *
2 mjames 140
 * Revision 1.20  2000/05/31  11:43:01  11:43:01  mjames (Mike James)
141
 * Part of Release May_31_2000
11 mjames 142
 *
2 mjames 143
 * Revision 1.19  2000/05/08  17:01:40  17:01:40  mjames (Mike James)
144
 * Part of Release May__8_2000
11 mjames 145
 *
2 mjames 146
 * Revision 1.18  2000/05/08  16:59:33  16:59:33  mjames (Mike James)
147
 * Part of Release May__8_2000
11 mjames 148
 *
2 mjames 149
 * Revision 1.17  2000/05/08  16:57:10  16:57:10  mjames (Mike James)
150
 * Part of Release May__8_2000
11 mjames 151
 *
2 mjames 152
 * Revision 1.16  2000/03/08  16:19:34  16:19:34  mjames (Mike James)
153
 * New version including PC
11 mjames 154
 *
2 mjames 155
 * Revision 1.13  2000/01/20  15:58:51  15:58:51  mjames (Mike James)
156
 * Part of Release R22
11 mjames 157
 *
2 mjames 158
 * Revision 1.12  99/12/22  11:15:32  11:15:32  mjames (Mike James)
159
 * Part of Release Dec_22_1999
11 mjames 160
 *
2 mjames 161
 * Revision 1.11  99/11/23  13:55:21  13:55:21  mjames (Mike James)
162
 * Added Certify support
11 mjames 163
 *
2 mjames 164
 * Revision 1.10  99/06/25  14:35:53  14:35:53  mjames (Mike James)
11 mjames 165
 * Added in reference to expression.h, but no changes made
2 mjames 166
 * to the function of acfread yet.
11 mjames 167
 *
2 mjames 168
 * Revision 1.9  99/06/18  09:26:33  09:26:33  mjames (Mike James)
169
 * Templating behaviour still incorrect. Under investigation.
11 mjames 170
 *
2 mjames 171
 * Revision 1.8  98/11/30  11:58:59  11:58:59  mjames (Mike James)
172
 * Altered behaviour for pins of type 'none' , also related
173
 * stuff in unrouted.c, to set a pin direction on chip
174
 * nodes when node references are made in the unnnamed list of
11 mjames 175
 * pins.
176
 *
2 mjames 177
 * Revision 1.7  98/11/13  15:22:23  15:22:23  mjames (Mike James)
178
 * Fixed core dump on non-existent pin identifier
11 mjames 179
 * in template application function.
2 mjames 180
 * Previously locating pins was  called with
181
 * a Create rather than Find flag. So it always retuned some pointer
11 mjames 182
 * to some object. Now I use Find and it can return NULL. I needed to
2 mjames 183
 * check for that null pointer.
11 mjames 184
 *
2 mjames 185
 * Revision 1.6  98/10/01  15:28:08  15:28:08  mjames (Mike James)
186
 * Altered behaviour to search for pins on line 204
11 mjames 187
 *
2 mjames 188
 * Revision 1.5  98/08/12  14:23:02  14:23:02  mjames (Mike James)
189
 * extending the templating algorithms
11 mjames 190
 *
2 mjames 191
 * Revision 1.4  98/07/14  13:26:39  13:26:39  mjames (Mike James)
192
 * Now hase three levels of checking templates
11 mjames 193
 *
2 mjames 194
 * Revision 1.3  98/06/15  14:20:49  14:20:49  mjames (Mike James)
195
 * Made tempaltes chip specific.
11 mjames 196
 *
2 mjames 197
 * Revision 1.2  98/02/11  11:27:29  11:27:29  mjames (Mike James)
198
 * Checked in for version 6.2a
11 mjames 199
 *
2 mjames 200
 * Revision 1.1  97/04/23  08:43:27  08:43:27  mjames (Mike James)
201
 * Initial revision
202
 *  */
11 mjames 203
#include <stdio.h>
204
#include <string.h>
205
#include <stdlib.h>
206
#include <ctype.h>
207
#include <sys/types.h>
208
#include <regex.h>
2 mjames 209
 
11 mjames 210
#include "vertcl_main.h"
2 mjames 211
#include "expression.h"
212
#include "generic.h"
11 mjames 213
#include "database.h"
214
#include "cmdparse.h"
215
#include "cmdlog.h"
216
#include "printout.h"
2 mjames 217
#include "print_vlog.h"
11 mjames 218
#include "chck_names.h"
219
#include "template.h"
2 mjames 220
#include "sorting.h"
221
#include "unrouted.h"
11 mjames 222
#include "routing.h"
223
#include "equivalent.h"
2 mjames 224
 
225
 
11 mjames 226
#ident "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/template.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $"
2 mjames 227
 
11 mjames 228
 
229
 
230
 
2 mjames 231
/* We have to check all sockets to see if there is a template for them.
11 mjames 232
   If there is then we ensure that all of the template pins exist on the main
2 mjames 233
   chip socket */
234
 
11 mjames 235
 
2 mjames 236
/* the following pin table indicates if a device pin is compatible with a template pin */
237
 
238
/* compat_pins[device][template] : relies on the declaration of pindir_t */
11 mjames 239
/* The array is looked up by chip pin in the y direction and
240
   template pin in the x direction */
241
char * compat_pins[] = {
242
  "1111110", /* NONE  : is it best to claim it is compatible with all pins : routing later will sort out mistakes here !*/
243
  "0100100", /* INPUT */  
244
  "0011100", /* OUTPUT */
245
  "0011100", /* BUFFER */
246
  "0000100", /* BIDIR */
247
  "0000010", /* CONFIG */
248
  "0000001"};/* POWER  */
2 mjames 249
 
11 mjames 250
static char * decode_pin_dir[]=
251
{
252
  "UNKNOWN",
253
  "INPUT",
254
  "OUTPUT",
255
  "BUFFER", /* buffer is a sort of Output pin */
256
  "BIDIR",
257
  "CONFIG",
258
  "POWER"}; /* added Aug 2000 */
259
 
260
/* The function here checks pin identifiers
2 mjames 261
 *   a) to see if the pin IDs on the chip match those on the template.
262
 *   b) to reassign any invalid  pin IDs on the chip to valid
263
 *      compatible ones on the template.
11 mjames 264
 *   c) If options & TEMPLATE_CREATE_MISSING_PINS
2 mjames 265
 *         to create any remaining pin IDs on the chip that
11 mjames 266
 *         still are available on the template
267
 *   d) to make sure all fixed pin directions are OK  
268
 *   e) If options & TEMPLATE_DISCONNECT_PINS to disconnect any pins
2 mjames 269
        on the chip that are not present on the template
270
        Any net that loses an FPGA pin is set not routable.
271
 */
11 mjames 272
 
273
void template_ensure(char * chip_id_template, int options)
274
  {
275
  socket_t * skt = socket_head,* template = NULL;
276
  int found = 0,rc;
277
  int pins_used,pins_count;
2 mjames 278
 
11 mjames 279
  int chip_count, processed_count;
2 mjames 280
 
11 mjames 281
  node_t * chip_node , * template_node;
2 mjames 282
 
11 mjames 283
  char * pattern;
284
  /* compile regular expression */
285
  vert_regex_t * preg;
2 mjames 286
 
11 mjames 287
  chip_count = 0;
288
  processed_count = 0;
2 mjames 289
 
11 mjames 290
  create_unrouted_list();
291
 
292
/* pick out a wildcard if any ID given, else wildcard anyway */
293
  if(!chip_id_template) {
294
    pattern = ".*";
295
    Log(LOG_GENERAL,"-- Beginning setting pin template on all chips\n");
296
    }
297
  else {
298
    pattern = chip_id_template;  
299
    Log(LOG_GENERAL,"-- Beginning setting pin template: prefix '%s' --\n",chip_id_template );
300
    }
2 mjames 301
 
11 mjames 302
  rc = vert_regcomp(&preg,pattern);
2 mjames 303
 
11 mjames 304
  if (rc != 0 )
305
    {
306
    char errbuff[100];
307
    regerror(rc,preg->preg,errbuff,100);
308
    Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",rc,errbuff,pattern);
309
 
310
/*    return TCL_ERROR;
311
*/
312
    return;
313
    }
314
  else
315
    {
316
    Log(LOG_GENERAL,"-- Using '%s' as match pattern\n",pattern);
317
    }
2 mjames 318
 
319
 
320
 
321
 
11 mjames 322
  while(skt) {
323
    chip_count++;
324
    skt->template_socket = NULL;
2 mjames 325
 
11 mjames 326
    found  = regexec(preg->preg,skt->identifier,0,preg->regpatt,0);
2 mjames 327
 
328
 
11 mjames 329
    if(!found) {
330
      char * chiptype = skt->type;
331
      if(!ISNULLSTR(chiptype)) {
332
        template = find_socket(Type,chiptype,Search,&template_head);
333
        if(level & 1)
334
          {
335
          Log(LOG_GENERAL,"-- **** Processing chip '%s' : type='%s' ****\n",
336
          skt->identifier,chiptype);
337
          }
338
       /* assign_declaration_directives(skt,global_generics);  
339
*/
340
        if(template) { /* we have located a template for this chip */
341
 
342
          processed_count++;
2 mjames 343
 
11 mjames 344
          skt->template_socket = template;
345
          if(level &1)
346
           {
347
           Log(LOG_GENERAL,"-- Which has a template\n");
348
           }
2 mjames 349
 
11 mjames 350
         /* examine all of the template entries and add in any
351
            IS_DECLARATION_DIRECTIVE ones */
352
        assign_declaration_directives(skt,template->generics);  
2 mjames 353
 
11 mjames 354
/*
355
         copy_declaration_generics(skt,template);
356
*/
357
         /* clear template flags on chip nodes */
358
         chip_node = skt->nodes;
359
         while(chip_node) {
360
           chip_node -> template_flag = 0;
361
           chip_node = chip_node->sktnext;
362
           }
363
         template_node = template->nodes;
364
         while(template_node)
365
           {
366
           template_node -> template_flag = 0;
367
           template_node = template_node->sktnext;
368
           }          
369
         /* search for nodes that already have valid identifiers
370
            according to the chip templates, and mark these as being OK  */
371
 
372
         template_node = template->nodes;
373
         if (level &1)
374
           {
375
           Log(LOG_GENERAL,"-- Matching template node identifiers\n");
376
           }
377
         while(template_node) {
378
           chip_node = find_node(skt,Ident,
379
                                 template_node->identifier,
380
                                 Search);
381
           if (chip_node) {
382
             /* need also to confirm that this pin connection is of
383
                a compatible type -- added checking code here */
384
             if (level & 2)              
385
               Log(LOG_GENERAL,"-- node '%s' chip=%d template=%d compat %c\n",
386
                 chip_node->identifier,
387
                 chip_node->pindir,template_node->pindir,
388
                 compat_pins[chip_node->pindir][template_node->pindir]);  
389
 
390
             if(compat_pins[chip_node->pindir][template_node->pindir] == '1') {
391
               chip_node->vhdltype = copy_vhdl(template_node->vhdltype,skt);
392
 
393
               template_node->template_flag = 1;
394
               chip_node->template_flag     = 1;
395
               if(level & 2)
396
                  Log(LOG_GENERAL,"-- pin '%s' compatible\n",
397
               template_node->identifier);
398
               }
399
 
400
             };
401
           /*  
402
           else
403
               Log(LOG_GENERAL,"-- node '%s' not matched\n",template_node->identifier);
404
           */
405
            template_node = template_node->sktnext;
406
           }
2 mjames 407
 
408
 
11 mjames 409
          /* now look through chip for all identifiers that havent been
410
             found on the template.
411
             These are incorrect and need to be replaced  by an unused
412
             template pin*/
413
         if(level & 1)
414
           {
415
           Log(LOG_GENERAL,"-- Altering node identifiers\n");
416
           }
417
         /* clear template flags on chip nodes */
418
         chip_node = skt->nodes;
419
 
420
         /* search each chip node to see if validated OK */
421
         while(chip_node) {        
422
 
423
           /* if it does not have a correct template pin , go and find one */
424
           if (! chip_node->template_flag ) {
425
             template_node = template->nodes;
426
             while(template_node) {
427
               if (template_node->template_flag == 0) {
428
               /* possible pin unused candidate : look at the pin direction */
429
                 if(compat_pins[chip_node->pindir][template_node->pindir] == '1') {
430
                   template_node->template_flag = 1;
431
                   chip_node->template_flag     = 1;
432
                   if(level & 2)
433
                     Log(LOG_GENERAL,"-- changing pin ID '%s' to new ID = %s\n",
434
                        chip_node->identifier,
435
                        template_node->identifier);
436
                   chip_node->identifier = template_node->identifier;
437
                   chip_node->vhdltype   = copy_vhdl(template_node->vhdltype,skt);      
438
                   break; /* from while template_node */
439
                   }
440
                 /*
441
                 else
442
                   Log(LOG_GENERAL,"-- ?? node ID '%s' new ID = %s .. %d\n",
443
                         chip_node->identifier,
444
                        template_node->identifier,template_node->pindir); */
445
 
446
                 }
447
               template_node = template_node->sktnext;
448
               }
449
             /* if we havent found a valid possible template node ID for
450
                the chip pin then template_node == NULL at this point (run out
451
                of possibilities) Except if we are deleting missing pins then its
452
                worth  */
453
             if(!(options & TEMPLATE_DISCONNECT_PINS) && !template_node)
454
             Log(LOG_ERROR,
455
                 "-- ERROR (perhaps): Cannot find a valid ID to replace %s pin '%s'\n",
456
                  decode_pin_dir[chip_node->pindir],chip_node->identifier);
457
             }
458
             chip_node = chip_node->sktnext;
459
           }
460
         if(level & 1)
461
           {
462
           Log(LOG_GENERAL,"-- Creating additional pins , correcting fixed pin directions\n");
463
           }
464
           /* to apply template :
465
           Find/create the chip pin . If the
466
           matching template pin directional is BIDIR_PIN,
467
           do not touch the current pin direction.
468
           Otherwise override the physical pin direction */
2 mjames 469
 
11 mjames 470
         template_node = template->nodes;
471
         pins_used = 0;
472
         pins_count = 0;
2 mjames 473
 
11 mjames 474
         while(template_node) {
475
           /* find the chip pin (node)  */
476
           node_t * chip_node;
477
 
478
           chip_node = find_node(skt,Ident,
479
                                         template_node->identifier,
480
                                         options & TEMPLATE_CREATE_MISSING_PINS);
481
           if (level & 2)
482
             {
483
             Log(LOG_GENERAL,"-- template '%s' template flag %d exists %d\n",
484
                         template_node->identifier,template_node->template_flag,
485
                         chip_node ?1:0);  
486
             }
487
           pins_count++;
488
           if (chip_node != NULL)
489
               {
490
              pins_used ++;                        
491
           /* fix the pin direction down !! */
492
 
493
 
494
            if (template_node->template_flag == 0) {
495
               /* next line had chip_node  in it */
496
               if((template_node->pindir != BIDIR)  && (template_node->pindir != NONE)) {
497
                 chip_node->fixed_pin = 1;   /* routes must use the appropriate pin direction  */
498
                 chip_node->pindir = template_node->pindir;
499
                 if (level & 2)
500
                   Log(LOG_GENERAL,"-- pin '%s' fixing pindir as %d\n",
501
                         chip_node->identifier,chip_node->pindir);  
502
                 }
503
 
504
               }  
505
             chip_node->template_flag = 1; /* templating applied OK */    
506
             chip_node->pin_group = template_node->pin_group;
507
             }
508
           template_node = template_node->sktnext;
509
           }
510
          if (level & 1)
511
            {
512
            Log(LOG_GENERAL,"-- %d pins out of %d in use\n",pins_used,pins_count);
513
            }
514
         }
2 mjames 515
 
516
 
517
 
11 mjames 518
      /* new stuff October 2001 : If any chip pins do not have their template flag set now then
519
         they _may_ be deleted as they are not on the template in any case */
520
       if(template && (options & TEMPLATE_DISCONNECT_PINS))
521
         {
522
         pins_count = 0;
523
         if (level & 1)
524
           {
525
           Log(LOG_GENERAL,"-- Disconnecting pins missing on template\n");
526
           }
527
         chip_node = skt->nodes;
528
         while(chip_node) {
529
           if(! chip_node -> template_flag)
530
             {
531
             if (level & 2)
532
               {
533
               Log(LOG_GENERAL,"--  pin '%s' being disconnected\n",chip_node->identifier);
534
               }
2 mjames 535
 
11 mjames 536
             pins_count++;
537
             /* questionable approach to problem */
538
             if(chip_node->net)
539
               {
540
               chip_node->net->how_routed = Not_Routable; /* checked */
541
 
542
               }
543
             disconnect_node(skt,chip_node);
544
             }
545
           chip_node = chip_node->sktnext;
546
           }
547
         if (level & 1)
548
           {
549
           Log(LOG_GENERAL,"-- Disconnected %d pins missing on template\n",pins_count);
550
           }
551
         }
552
       if(level & 1)
553
         {
554
         Log(LOG_GENERAL,"-- Finished chip\n");
555
         }
556
       }
2 mjames 557
 
11 mjames 558
       copy_equivalent_pins(template,skt); /* any pin connections that are equivalent
559
                                              by default will be copied from the template */
2 mjames 560
 
11 mjames 561
 
562
    }
563
  skt = skt->next;
564
  }
565
  Log(LOG_GENERAL,"-- checked %d objects, applied template to %d of them\n",chip_count,processed_count);
566
  vert_regfree(&preg);
567
}
2 mjames 568
 
569
 
570
 
11 mjames 571
 
2 mjames 572
/* list what we have as a template */
11 mjames 573
void template_list(void)
574
  {
575
    socket_t * templates = template_head;
576
    /* for now list out the templates */
577
      Log(LOG_GENERAL,"-- List of socket templates\n");
578
  while(templates) {
579
     Log(LOG_GENERAL,"-- Template '%s' ",templates->type);
580
     if(templates->parent_template_ref)
581
       Log(LOG_GENERAL,"alias '%s'\n",templates->parent_template_ref->type);
582
     else
583
       Log(LOG_GENERAL,"\n");
584
 
585
     templates=templates->next;
586
   }
587
  }
2 mjames 588
 
589
/* list what we have as a template */
11 mjames 590
void template_list_pins(FILE * f)
591
  {
592
    socket_t * templates = template_head;
593
    /* for now list out the templates */
594
   while(templates) {
595
     fprintf(f,"-- Template '%s'\n",templates->type);
596
     print_device(f,templates,PRINT_ALL | PRINT_GROUP | PRINT_GENERIC | PRINT_EQUIVALENT_PINS | PRINT_EXPAND_BUS);
597
     templates=templates->next;
598
   }
2 mjames 599
 
11 mjames 600
 
601
  }
602
 
603
 
604
 
2 mjames 605
/******************************************************************************************/
606
/* Extracting component templates from the list of components in the circuit design       */
607
/******************************************************************************************/
608
 
11 mjames 609
void extract_templates(void)
610
  {
611
  socket_t * skt = socket_head,* template;
612
  node_t * chip_node , * template_node;
613
  Log(LOG_GENERAL,"-- Extracting device templates (verilog modules or VHDL components)\n");
2 mjames 614
 
11 mjames 615
/* is this needed ? */
616
  create_unrouted_list();
2 mjames 617
 
11 mjames 618
  while(skt ) {
619
    char * chiptype = skt->type;
620
    /* locate or create the template for this socket */
621
    if(!ISNULLSTR(chiptype)) {
622
      template = find_socket(Type,chiptype,Search,&template_head);
623
      skt->template_socket = template;
624
 
625
      if(!template) /* act only if no template */
2 mjames 626
        {
11 mjames 627
        if (level & 4)              
628
          Log(LOG_GENERAL,"-- Creating template from chip '%s' : type='%s'\n",
629
            skt->identifier,chiptype);
630
        template = find_socket(Type,chiptype,Create,&template_head);
631
        template->is_template = 1; /* flag for later use */
632
        }
633
      assign_declaration_directives(template,skt->generics);  
2 mjames 634
 
635
 
11 mjames 636
      skt->template_socket = template;
2 mjames 637
 
11 mjames 638
      copy_equivalent_pins(skt,template); /* any pin connections that are equivalent
639
                                              by default will be copied to the template */
2 mjames 640
 
641
 
11 mjames 642
      /* assign_declaration_directives(skt,template->generics);   */
2 mjames 643
 
11 mjames 644
/*
645
         copy_declaration_generics(skt,template);
646
*/
647
 
648
       chip_node = skt->nodes;
649
       if (level & 4)              
650
         Log(LOG_GENERAL,"-- Copying/checking node identifiers\n");
651
       while(chip_node) {
652
         if (level & 4)              
653
           Log(LOG_GENERAL,"-- Node %s\n",chip_node->identifier);
654
         template_node = find_node(template,Ident,
655
                               chip_node->identifier,
656
                               Search);
657
         /* add pins to template if there is a net connected to this pin and it is routable */
658
 
659
         if (!template_node && chip_node->net /*&& chip_node->net->how_routed != Not_Routable */ )
660
           {
661
           template_node = find_node(template,Ident,
662
                                 chip_node->identifier,
663
                                 Create);
2 mjames 664
 
11 mjames 665
           template_node->pindir = chip_node->pindir;
666
           template_node->vhdltype = copy_vhdl(chip_node->vhdltype,skt);
2 mjames 667
 
11 mjames 668
           if (level & 4)              
669
             Log(LOG_GENERAL,"-- node '%s' dircode=%d\n",
670
                 template_node->identifier,
671
                 template_node->pindir);
672
 
2 mjames 673
 
11 mjames 674
           }            
675
         chip_node = chip_node->sktnext;
676
         }
2 mjames 677
 
11 mjames 678
       if(level & 4)
679
         {
680
         Log(LOG_GENERAL,"-- Finished chip\n");
681
         }
682
       }
683
 
684
    skt = skt->next;
685
    }
686
  Log(LOG_GENERAL,"-- Finished extracting device templates\n");
687
  }
2 mjames 688
 
11 mjames 689
 
690
 
691
 
692