Subversion Repositories Vertical

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 11
Line 1... Line 1...
1
/* $Id: equivalent.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $ */
1
/* $Id: equivalent.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $ */
2
/*
2
/*
3
 * $Log: equivalent.c,v $
3
 * $Log: equivalent.c,v $
4
 * Revision 1.1.1.1  2003/11/04 23:34:57  mjames
4
 * Revision 1.1.1.1  2003/11/04 23:34:57  mjames
5
 * Imported into local repositrory
5
 * Imported into local repositrory
6
 *
6
 *
7
 * Revision 1.9  2003/01/02 21:37:15  mjames
7
 * Revision 1.9  2003/01/02 21:37:15  mjames
Line 27... Line 27...
27
 * Revision 1.5  2001/10/31 22:20:03  mjames
27
 * Revision 1.5  2001/10/31 22:20:03  mjames
28
 * Tidying up problematical comments caused by CVS
28
 * Tidying up problematical comments caused by CVS
29
 * 'intelligent' comment guessing
29
 * 'intelligent' comment guessing
30
 *
30
 *
31
 */
31
 */
-
 
32
 
32
 
33
 
33
/* This file handles equivalent pins , being passthroughs or
34
/* This file handles equivalent pins , being passthroughs or
34
   low value resistors which can be regarded as passthrough jumpers */
35
   low value resistors which can be regarded as passthrough jumpers */
35
 
36
   
36
/* Extracted from ACFREAD syntax : pin equivalences within a chip or template
37
/* Extracted from ACFREAD syntax : pin equivalences within a chip or template
37
   declaration
38
   declaration
38
   
39
   
39
 
40
pin_equivalence : EQUIVALENT LBRK { curr_equiv_list = begin_equivalent_pins(); }
40
pin_equivalence : EQUIVALENT LBRK { curr_equiv_list = begin_equivalent_pins(); }
41
                    equivalent_pins
41
                    equivalent_pins
42
                  RBRK end_item { check_equivalent_pins(current_chip,curr_equiv_list); }
42
                  RBRK end_item { check_equivalent_pins(current_chip,curr_equiv_list); }
43
                  ;
43
                  ;
44
               
44
               
45
equivalent_pins : equivalent_pin SEMI equivalent_pins
45
 
46
                | equivalent_pin
46
equivalent_pins : equivalent_pin SEMI equivalent_pins
47
                |
47
                | equivalent_pin
48
                ;              
48
                |
49
               
49
                ;
50
equivalent_pin : astring { add_equivalent_pin( current_chip,curr_equiv_list,$1); };
50
               
51
 
51
 
52
  in2 : input_pin = a1;
52
equivalent_pin : astring { add_equivalent_pin( current_chip,curr_equiv_list,$1); };
53
  in3 : input_pin = f1;
53
 
54
 
Line 56... Line 57...
56
 
57
*/
57
e.g. EQUIVALENT ( a1;f1);
58
 
58
 
59
/* we approach the storage of nodes with caution , deferring the
59
*/
60
   adding of information until it is correct */
60
 
61
 
-
 
62
#include <stdio.h>
61
/* we approach the storage of nodes with caution , deferring the
63
#include <string.h>
-
 
64
#include <stdlib.h>
-
 
65
#include <ctype.h>
62
   adding of information until it is correct */
66
 
63
 
-
 
64
#include "equivalent.h"
-
 
65
 
67
#include "vertcl_main.h"
66
#include "cmdlog.h"
68
#include "expression.h"
67
#include "cmdparse.h"
69
#include "generic.h"
-
 
70
#include "database.h"
68
#include "database.h"
71
#include "cmdparse.h"
-
 
72
#include "cmdlog.h"
69
#include "expression.h"
73
#include "printout.h"
70
#include "generic.h"
74
#include "equivalent.h"
-
 
75
#include "jumpering.h"
71
#include "jumpering.h"
76
 
72
#include "printout.h"
-
 
73
#include "vertcl_main.h"
-
 
74
 
-
 
75
#include <ctype.h>
-
 
76
#include <stdio.h>
77
 
77
#include <stdlib.h>
-
 
78
#include <string.h>
78
#ident "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/equivalent.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $"
-
 
79
 
79
 
80
 
80
#ident                                                                                        \
81
/********************************************************************/
81
    "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/equivalent.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $"
82
/* this function starts to create a list of equivalent pins */
82
 
83
/********************************************************************/
83
/********************************************************************/
84
equivalent_node_set_t *  begin_equivalent_pins( void) {
84
/* this function starts to create a list of equivalent pins */
-
 
85
/********************************************************************/
85
  equivalent_node_set_t * node_set;
86
equivalent_node_set_t *begin_equivalent_pins (void)
86
  node_set = calloc(1,sizeof ( equivalent_node_set_t ));
87
{
87
  return node_set;
-
 
88
  }
-
 
89
 
88
        equivalent_node_set_t *node_set;
90
 
89
        node_set = calloc (1, sizeof (equivalent_node_set_t));
91
 
90
        return node_set;
92
/********************************************************************/
91
}
93
/* add a pin to the list referred to by node_set */
92
 
94
/********************************************************************/
93
/********************************************************************/
95
void add_equivalent_pin( socket_t * current_chip,equivalent_node_set_t * node_set , char * ident) {
94
/* add a pin to the list referred to by node_set */
-
 
95
/********************************************************************/
96
  equivalent_node_t * ptr;
96
void add_equivalent_pin (socket_t *current_chip, equivalent_node_set_t *node_set, char *ident)
97
  equivalent_node_t * equiv_node;
97
{
98
  node_t * node;
98
        equivalent_node_t *ptr;
99
  if (! current_chip) {
99
        equivalent_node_t *equiv_node;
-
 
100
        node_t *node;
100
    Log(LOG_ERROR,"-- Current chip not known for equivalent pin creation\n");
101
        if (!current_chip)
101
    return;
102
        {
102
    }
103
                Log (LOG_ERROR, "-- Current chip not known for equivalent pin creation\n");
103
 
104
                return;
104
  node = find_node(current_chip,Ident,ident,Create);
105
        }
105
  /* no pin called 'ident ?? */
106
 
106
  if((level &1) && !node) {
107
        node = find_node (current_chip, Ident, ident, Create);
-
 
108
        /* no pin called 'ident ?? */
-
 
109
        if ((level & 1) && !node)
-
 
110
        {
107
    Log(LOG_ERROR,"-- Error : Pin Equivalent : cannot find pin %s(%s)\n",current_chip->name,ident);
111
                Log (
-
 
112
                    LOG_ERROR,
-
 
113
                    "-- Error : Pin Equivalent : cannot find pin %s(%s)\n",
108
    return;
114
                    current_chip->name,
109
    }
115
                    ident);
110
 
116
                return;
111
  /* pin already equivalent to another ? */
117
        }
112
  if((level &1) && node->equivalent_nodes) {
118
 
-
 
119
        /* pin already equivalent to another ? */
-
 
120
        if ((level & 1) && node->equivalent_nodes)
-
 
121
        {
113
    Log(LOG_ERROR,"-- Error : Pin Equivalent : pin %s(%s) already member of set\n",current_chip->name,ident);
122
                Log (
-
 
123
                    LOG_ERROR,
-
 
124
                    "-- Error : Pin Equivalent : pin %s(%s) already member of set\n",
114
    return;
125
                    current_chip->name,
115
    }
126
                    ident);
116
 
127
                return;
117
  /* pin is acceptable so note it */
128
        }
118
  equiv_node = calloc(1,sizeof ( equivalent_node_t ));
129
 
119
  if (!node_set->nodes) {
130
        /* pin is acceptable so note it */
-
 
131
        equiv_node = calloc (1, sizeof (equivalent_node_t));
120
    /* new node */
132
        if (!node_set->nodes)
121
    node_set->nodes = equiv_node;
133
        {
122
    }
134
                /* new node */
-
 
135
                node_set->nodes = equiv_node;
123
  else {
136
        }
124
    ptr = node_set->nodes;
137
        else
125
    while (ptr->next)
138
        {
126
      ptr=ptr->next;
139
                ptr = node_set->nodes;
127
    ptr->next = equiv_node;
140
                while (ptr->next)
128
    }
141
                        ptr = ptr->next;
129
  equiv_node->node = node;
142
                ptr->next = equiv_node;
130
  }
143
        }
131
 
144
        equiv_node->node = node;
132
/********************************************************************/
145
}
133
/* this function will verify the current list of nodes that are equivalent, and if there is more than
146
 
134
   one in the list then it will add them to the equivalent node list of the
147
/********************************************************************/
135
   chip (if only one pin is equivalent to itself then it is a waste of time .... )   */
148
/* this function will verify the current list of nodes that are equivalent, and if there is
136
/********************************************************************/
149
   more than one in the list then it will add them to the equivalent node list of the
137
void check_equivalent_pins(socket_t * current_chip, equivalent_node_set_t * node_set ) {
150
   chip (if only one pin is equivalent to itself then it is a waste of time .... )   */
-
 
151
/********************************************************************/
-
 
152
void check_equivalent_pins (socket_t *current_chip, equivalent_node_set_t *node_set)
-
 
153
{
-
 
154
        equivalent_node_t *curr_node, *prev;
-
 
155
 
-
 
156
        int equiv_count;
-
 
157
 
-
 
158
        if (!node_set)
-
 
159
                return;
-
 
160
 
-
 
161
        /* count equivalent nodes */
-
 
162
        curr_node = node_set->nodes;
-
 
163
        equiv_count = 0;
-
 
164
        while (curr_node)
-
 
165
        {
-
 
166
                equiv_count++;
-
 
167
                curr_node = curr_node->next;
-
 
168
        };
-
 
169
 
-
 
170
        /* delete info if not sufficent equivalent nodes */
-
 
171
        if (equiv_count < 2)
-
 
172
        {
-
 
173
                curr_node = node_set->nodes;
-
 
174
                while (curr_node)
-
 
175
                {
-
 
176
                        prev = curr_node;
-
 
177
                        curr_node = curr_node->next;
-
 
178
                        free (prev);
-
 
179
                };
-
 
180
                free (node_set);
-
 
181
                Log (LOG_ERROR, "-- Warning : insufficient equivalent pins in list\n");
-
 
182
                return;
-
 
183
        }
-
 
184
 
-
 
185
        /* join the list to the socket as it is now validated */
-
 
186
        curr_node = node_set->nodes;
-
 
187
        while (curr_node)
-
 
188
        {
-
 
189
                /* flag each node as being a member of an equivalent set */
-
 
190
                curr_node->node->equivalent_nodes = node_set;
138
 
-
 
139
  equivalent_node_t * curr_node, * prev;
-
 
140
 
-
 
141
  int equiv_count;
-
 
142
 
-
 
143
  if(!node_set)
-
 
144
    return;
-
 
145
 
-
 
146
  /* count equivalent nodes */
-
 
147
  curr_node = node_set->nodes;
-
 
148
  equiv_count = 0;
-
 
149
  while(curr_node) {
-
 
150
    equiv_count ++;
-
 
151
    curr_node = curr_node->next;
-
 
152
    };
-
 
153
 
-
 
154
  /* delete info if not sufficent equivalent nodes */
-
 
155
  if(equiv_count < 2) {
-
 
156
    curr_node = node_set->nodes;
-
 
157
    while(curr_node) {
-
 
158
      prev = curr_node;
-
 
159
      curr_node = curr_node->next;
-
 
160
      free(prev);
-
 
161
      };
-
 
162
    free(node_set);
-
 
163
    Log(LOG_ERROR,"-- Warning : insufficient equivalent pins in list\n");
-
 
164
    return;
-
 
165
    }
-
 
166
 
-
 
167
  /* join the list to the socket as it is now validated */
-
 
168
  curr_node = node_set->nodes;
-
 
169
  while(curr_node) {
-
 
170
  /* flag each node as being a member of an equivalent set */
-
 
171
    curr_node->node->equivalent_nodes = node_set;
-
 
172
    curr_node = curr_node->next;
-
 
173
    }
-
 
174
 
-
 
175
 
191
                curr_node = curr_node->next;
176
  /* add an additional equivalent node set */
192
        }
177
  node_set->next = current_chip->equivalent_node_set;
193
 
178
  current_chip->equivalent_node_set = node_set;
194
        /* add an additional equivalent node set */
179
 
195
        node_set->next = current_chip->equivalent_node_set;
180
  return ;
196
        current_chip->equivalent_node_set = node_set;
181
  }
197
 
182
 
198
        return;
183
/********************************************************************/
199
}
184
 
200
 
185
void  list_equivalent_pins(FILE * f, socket_t * dev) {
201
/********************************************************************/
-
 
202
 
186
  int itemcnt;
203
void list_equivalent_pins (FILE *f, socket_t *dev)
187
  equivalent_node_t     * curr_node;
204
{
188
  equivalent_node_set_t * curr_set;
205
        int itemcnt;
189
 
206
        equivalent_node_t *curr_node;
190
  curr_set = dev->equivalent_node_set;
207
        equivalent_node_set_t *curr_set;
191
 
208
 
192
  while (curr_set) {
209
        curr_set = dev->equivalent_node_set;
-
 
210
 
193
    if (curr_set->nodes) {
211
        while (curr_set)
-
 
212
        {
194
      curr_node=curr_set->nodes;
213
                if (curr_set->nodes)
195
      fprintf(f,"  EQUIVALENT ( ");
214
                {
196
      itemcnt = 2;
215
                        curr_node = curr_set->nodes;
197
      while (curr_node) {
216
                        fprintf (f, "  EQUIVALENT ( ");
-
 
217
                        itemcnt = 2;
198
        if (curr_node->next) {
218
                        while (curr_node)
-
 
219
                        {
199
          fprintf(f,"%s; ",curr_node->node->identifier);
220
                                if (curr_node->next)
200
          itemcnt++;
221
                                {
201
          if (itemcnt > 6) {
222
                                        fprintf (f, "%s; ", curr_node->node->identifier);
202
            fprintf(f,"\n     ");
223
                                        itemcnt++;
-
 
224
                                        if (itemcnt > 6)
203
            itemcnt = 0;
225
                                        {
204
            }
226
                                                fprintf (f, "\n     ");
205
          }  
227
                                                itemcnt = 0;
206
        else
228
                                        }
207
          fprintf(f,"%s);\n",curr_node->node->identifier);
229
                                }
-
 
230
                                else
-
 
231
                                        fprintf (f, "%s);\n", curr_node->node->identifier);
-
 
232
                                curr_node = curr_node->next;
208
        curr_node= curr_node->next;
233
                        }
209
        }
-
 
210
      }
-
 
211
    curr_set = curr_set->next;
-
 
212
    }
234
                }
213
  }
-
 
214
       
235
                curr_set = curr_set->next;
215
 
236
        }
216
/********************************************************************
237
}
217
 * copies the equivalent pins list from template to device instance *
238
 
218
 * uses the functions above to ensure validation is consistently    *
239
/********************************************************************
219
 * performed                                            
240
 * copies the equivalent pins list from template to device instance *
220
 ********************************************************************/
241
 * uses the functions above to ensure validation is consistently    *
221
void copy_equivalent_pins(socket_t * template,socket_t * dev ) {
242
 * performed
-
 
243
 ********************************************************************/
222
  equivalent_node_t     * curr_node ;
244
void copy_equivalent_pins (socket_t *template, socket_t *dev)
223
  equivalent_node_set_t * curr_set  ,* new_set;
245
{
224
 
246
        equivalent_node_t *curr_node;
225
  /* trap use of template when none is actually given */
247
        equivalent_node_set_t *curr_set, *new_set;
226
  if (!template || !dev)
248
 
227
    return;
249
        /* trap use of template when none is actually given */
228
  if(level &1)
250
        if (!template || !dev)
229
    {
-
 
230
    Log(LOG_GENERAL,"copying equivalent pins from template %s to socket %s\n",
-
 
231
       template->type,dev->identifier);
-
 
232
    }
-
 
233
  curr_set = template->equivalent_node_set;
-
 
234
 
251
                return;
235
  while (curr_set) {
252
        if (level & 1)
236
    new_set = begin_equivalent_pins();
253
        {
237
    /* create a set of equivalent pins to copy into */
-
 
238
 
254
                Log (
239
    curr_node = curr_set->nodes;
-
 
240
   
-
 
241
    while (curr_node) {
-
 
242
      add_equivalent_pin( dev,new_set , curr_node->node->identifier);
-
 
243
      /* traverse list */
255
                    LOG_GENERAL,
244
      curr_node= curr_node->next;
256
                    "copying equivalent pins from template %s to socket %s\n",
245
      }
-
 
246
 
-
 
247
    check_equivalent_pins(dev, new_set );
257
                    template->type,
248
    curr_set = curr_set->next;
-
 
249
    }
258
                    dev->identifier);
250
 
259
        }
-
 
260
        curr_set = template->equivalent_node_set;
251
  }
261
 
-
 
262
        while (curr_set)
-
 
263
        {
-
 
264
                new_set = begin_equivalent_pins ();
-
 
265
                /* create a set of equivalent pins to copy into */
-
 
266
 
-
 
267
                curr_node = curr_set->nodes;
-
 
268
 
-
 
269
                while (curr_node)
-
 
270
                {
-
 
271
                        add_equivalent_pin (dev, new_set, curr_node->node->identifier);
-
 
272
                        /* traverse list */
252
 
273
                        curr_node = curr_node->next;
-
 
274
                }
-
 
275
 
-
 
276
                check_equivalent_pins (dev, new_set);
-
 
277
                curr_set = curr_set->next;
253
 
278
        }
254
/* function to jumper together all equivalent pins on a device :
279
}
255
  at the moment it does not distinguish between EPLD and non -epld devices */  
280
 
256
/* the endpoint is a socket that may be used */
281
/* function to jumper together all equivalent pins on a device :
257
void jumper_equivalent_pins(void)
282
  at the moment it does not distinguish between EPLD and non -epld devices */
258
  {
283
/* the endpoint is a socket that may be used */
259
  char equiv_buff [MAXIDLEN];
284
void jumper_equivalent_pins (void)
260
  equivalent_node_t     * curr_ref;
285
{
261
  equivalent_node_set_t * node_set ;
286
        char equiv_buff[MAXIDLEN];
262
 
287
        equivalent_node_t *curr_ref;
263
  socket_t * dev;
288
        equivalent_node_set_t *node_set;
264
 
289
 
265
  net_t * top_net, * current_net;
290
        socket_t *dev;
266
 
291
 
267
  dev = socket_head;
-
 
268
 
292
        net_t *top_net, *current_net;
269
 
293
 
270
  while(dev) {
294
        dev = socket_head;
-
 
295
 
271
    /* any equivalent pins */
296
        while (dev)
272
    if (dev->equivalent_node_set) {
297
        {
-
 
298
                /* any equivalent pins */
273
#if defined DEBUG_EQUIV
299
                if (dev->equivalent_node_set)
-
 
300
                {
-
 
301
#if defined DEBUG_EQUIV
274
        Log(LOG_GENERAL,"-- Device %s has equivalent pins\n",dev->identifier);
302
                        Log (
-
 
303
                            LOG_GENERAL,
275
#endif
304
                            "-- Device %s has equivalent pins\n",
276
      node_set = dev->equivalent_node_set;
305
                            dev->identifier);
277
      while(node_set) {
306
#endif
-
 
307
                        node_set = dev->equivalent_node_set;
278
        /* create a top level jumper name made out device ID concatenated with
308
                        while (node_set)
279
         current pin IDs */
309
                        {
280
        sprintf(equiv_buff,"E_%s",dev->identifier);
310
                                /* create a top level jumper name made out device ID
281
        curr_ref = node_set->nodes;
311
                                 concatenated with current pin IDs */
282
        while(curr_ref) {
312
                                sprintf (equiv_buff, "E_%s", dev->identifier);
-
 
313
                                curr_ref = node_set->nodes;
283
          current_net = curr_ref->node->net;
314
                                while (curr_ref)
284
/* if there is a net attached to the pin it is a routed net.
315
                                {
-
 
316
                                        current_net = curr_ref->node->net;
-
 
317
                                        /* if there is a net attached to the pin it is a routed
285
   only make the jumper if it is actually a usable net for routing. */
318
                                           net.
-
 
319
                                           only make the jumper if it is actually a usable net
286
          if (current_net && IS_ROUTABLE(current_net->how_routed)) {
320
                                           for routing. */
-
 
321
                                        if (current_net &&
287
               strcat(equiv_buff,"_");
322
                                            IS_ROUTABLE (current_net->how_routed))
-
 
323
                                        {
288
               strcat(equiv_buff,curr_ref->node->identifier);
324
                                                strcat (equiv_buff, "_");
289
               }
325
                                                strcat (
290
            curr_ref=curr_ref->next;
326
                                                    equiv_buff, curr_ref->node->identifier);
291
            }
-
 
292
           
327
                                        }
293
           
328
                                        curr_ref = curr_ref->next;
294
/*      printf("Making %s\n",equiv_buff); */
329
                                }
295
        top_net = find_net(&routed_list,Ident,equiv_buff,Create);
330
 
296
        top_net->how_joined = Jumpered;
331
                                /*      printf("Making %s\n",equiv_buff); */
297
#if defined DEBUG_EQUIV
332
                                top_net = find_net (&routed_list, Ident, equiv_buff, Create);
298
        Log(LOG_GENERAL,"--  making jumper %s\n",equiv_buff);
333
                                top_net->how_joined = Jumpered;
299
#endif
334
#if defined DEBUG_EQUIV
300
        curr_ref = node_set->nodes;
335
                                Log (LOG_GENERAL, "--  making jumper %s\n", equiv_buff);
301
        while(curr_ref) {
336
#endif
-
 
337
                                curr_ref = node_set->nodes;
302
          current_net = curr_ref->node->net;
338
                                while (curr_ref)
303
/* if there is a net attached to the pin it is a routed net.
339
                                {
-
 
340
                                        current_net = curr_ref->node->net;
-
 
341
                                        /* if there is a net attached to the pin it is a routed
304
   only make the jumper if it is actually a usable net for routing. */
342
                                           net.
-
 
343
                                           only make the jumper if it is actually a usable net
305
          if (current_net && IS_ROUTABLE(current_net->how_routed)) {
344
                                           for routing. */
-
 
345
                                        if (current_net &&
306
#if defined DEBUG_EQUIV
346
                                            IS_ROUTABLE (current_net->how_routed))
-
 
347
                                        {
-
 
348
#if defined DEBUG_EQUIV
307
            Log(LOG_GENERAL,"--   connecting net %s ( pin %s(%s))\n",
349
                                                Log (
308
                           curr_ref->node->net->identifier,
350
                                                    LOG_GENERAL,
309
                           dev->identifier,
351
                                                    "--   connecting net %s ( pin %s(%s))\n",
310
                           curr_ref->node->identifier);
352
                                                    curr_ref->node->net->identifier,
311
#endif
353
                                                    dev->identifier,
-
 
354
                                                    curr_ref->node->identifier);
312
            current_net->external_node = NULL; /* jumpered by net name */
355
#endif
313
            transfer_net_to_subnet(&routed_list,
356
                                                current_net->external_node =
314
                                   top_net, current_net);
-
 
315
           
357
                                                    NULL; /* jumpered by net name */
316
            }
-
 
317
           
358
                                                transfer_net_to_subnet (
318
       
359
                                                    &routed_list, top_net, current_net);
319
          curr_ref = curr_ref->next;
360
                                        }
320
          }
361
 
321
/* no child nets or jumper joins only one subnet : delete jumper */
362
                                        curr_ref = curr_ref->next;
-
 
363
                                }
322
        if(!top_net->subnets || !top_net->subnets->joined_nets)
364
                                /* no child nets or jumper joins only one subnet : delete
323
           disconnect_jumper( &routed_list,top_net);
-
 
324
 
365
                                 * jumper */
325
 
366
                                if (!top_net->subnets || !top_net->subnets->joined_nets)
326
        node_set = node_set->next;
367
                                        disconnect_jumper (&routed_list, top_net);
327
        }
-
 
328
      }
-
 
329
     
368
 
330
    dev = dev->next;
-
 
331
 
-
 
332
    }
-
 
333
  }
-
 
334
   
369
                                node_set = node_set->next;
335
 
370
                        }
-
 
371
                }
-
 
372
 
-