Subversion Repositories Vertical

Rev

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

Rev Author Line No. Line
2 mjames 1
/*
11 mjames 2
 * $Header: C:/cvsroot/Vert03/vertlib/database.h,v 1.2 2004/06/22 21:44:14 mjames Exp $
2 mjames 3
 *
4
 * $Log: database.h,v $
5
 * Revision 1.2  2004/06/22 21:44:14  mjames
6
 * Firrst build most files
7
 *
8
 * Revision 1.1.1.1  2003/11/04 23:34:56  mjames
9
 * Imported into local repositrory
10
 *
11
 * Revision 1.14  2003/01/02 21:37:15  mjames
12
 * Experiment on creating NOT_ROUTABLE_H and NOT_ROUTABLE_L
13
 * properties on the nets so that pin jumpers can be made without a problem.
14
 *
15
 * Still need to sort out pin assignments made to these not_routable nets
16
 * which will become legal in some cases so that pullups and pulldown
17
 * pins can be used on the FPGA.
18
 *
19
 * Revision 1.13  2002/09/30 13:26:01  MJAMES
20
 * Upgraded nets to include 'lhs_expression' being the range on the
21
 * left hand side of a signal connection to a port
22
 *
23
 * std_logic_vector (0) <= std_logic , on a port of a chip
24
 *
25
 * Revision 1.12  2002/09/09 10:14:14  mjames
26
 * Moved pin remapping function to pin ident editing function from
27
 * sorting pin name routine.
28
 *
29
 * Revision 1.11  2002/08/06 12:52:49  mjames
30
 * Merge in from latest version
31
 *
32
 * Revision 1.11  2002/03/21 17:12:58  mjames
33
 * Added search path to vertical file opening for read
34
 *
35
 * Revision 1.10  2002/01/16 11:22:42  mjames
36
 * database.h header file is read in first as it undefined DLL stuff irrelevant
37
 * to HPUX
38
 *
39
 * Revision 1.9  2001/12/20 13:53:09  mjames
40
 * Added a bundle width field to the chip declaration
41
 *
42
 * Revision 1.8  2001/10/31 22:20:02  mjames
43
 * Tidying up problematical comments caused by CVS
44
 * 'intelligent' comment guessing
45
 *
46
 * Revision 1.7  2001/10/23 21:12:43  mjames
47
 * Created preliminary 'disconnect_node' function
48
 *
49
 * Revision 1.6  2001/09/16 20:36:03  mjames
50
 * Second attempt to modify wire bundles to be connector rather than net
51
 * centric. Allows more than one connector to carry the same net,
52
 *
53
 * Revision 1.5  2001/09/16 19:49:54  mjames
54
 * Second attempt at bundling the pins on sockets
55
 *
56
 * Revision 1.4  2001/09/13 21:08:21  mjames
57
 * Added simple wire bundling data structures.
58
 *
59
 * Revision 1.3  2001/06/06 12:10:24  mjames
60
 * Move from HPUX
61
 *
62
 * Revision 1.2  2000/10/19 22:06:36  mjames
63
 * Removed spurious RCS log lines from new CVS stuff
64
 *
65
 * Revision 1.1.1.1  2000/10/19 21:58:35  mjames
66
 * Mike put it here
67
 *
68
 *
11 mjames 69
 *  
2 mjames 70
 */
11 mjames 71
 
72
 
73
 
74
 
75
 
2 mjames 76
#if !defined _DATABASE
77
#define _DATABASE
78
 
79
 
11 mjames 80
#if !defined _EXPRESSION 
81
#error "Need to include 'expression.h' before database.h"
82
#endif 
83
 
84
#if ! defined _GENERIC
85
#error "generic.h" must be included first
86
#endif
87
 
2 mjames 88
#define MAXIDLEN 1024
89
 
90
#define BUFPREFIX "XX_"
91
 
92
#if defined PC
93
#define VERTICAL_INI_PATH "vertical.ini"
11 mjames 94
#define VERTICAL_PATH     ".;c:/cygwin/usr/local/vert_files"
2 mjames 95
#else
96
#define VERTICAL_INI_PATH "vertical.ini"
11 mjames 97
#define VERTICAL_PATH     ".;$(HOME)/.caddata/vert_files"
2 mjames 98
/* DLL creation declaration mode. not used on HP */
11 mjames 99
#if ! defined __declspec
100
#define __declspec(x) 
2 mjames 101
#endif
102
#endif
103
 
11 mjames 104
 
2 mjames 105
/* incomplete declarations to placate 'c' */
106
 
107
struct connector;
108
struct net;
109
struct netref;
110
struct equivalent_node_set;
111
 
11 mjames 112
 
2 mjames 113
/* the direction list */
11 mjames 114
typedef enum { NONE,INPUT,OUTPUT,BUFFER,BIDIR,CONFIG,POWER } pindir_t;
2 mjames 115
 
11 mjames 116
 
2 mjames 117
#define Create 0
118
#define Search 1
119
 
120
 
11 mjames 121
 
122
#define ISNULLSTR(x) ((x == NULL) || (x && (x[0]==0)))
123
 
124
 
2 mjames 125
/* operations to manipulate the data structure */
126
/* from the ACF reader */
127
 
128
/* typedef enum { Ident,Type,Name,Value,Datatype,How_Routed } property_t; */
11 mjames 129
typedef enum { Ident,Type,Name,Value,How_Routed } property_t;
2 mjames 130
 
131
/* used in seting the routing_status attribute of a net */
132
 
133
typedef enum
11 mjames 134
  {
135
  Free,        /* name given may be reassigned */
136
  By_Name,     /* Routed by Name */
137
  By_Net,      /* Routed by already existing net */
138
  By_Fixed_Net,/* Routed through fixed existing net */
139
  By_Exact_Net,/* Routed using identical already existing net */
140
  By_Creating, /* Routed by creating a new net */
141
  By_Jumpering,/* Routed by connecting an existing net */
142
  By_FixPins,  /* can only go here as pins are fixed */
143
  Not_Routable, /* not allowed to participate in any routing */
144
  Not_Routable_H, /* pullup/VCC */
145
  Not_Routable_L  /* pulldown/GND */
146
  } HowRouted_t;
2 mjames 147
/* these macros are reliant on sorted ordinal values */
11 mjames 148
#define IS_NOT_ROUTABLE(x) ((x)>=Not_Routable)
149
#define IS_ROUTABLE(x)     ((x)<Not_Routable)
2 mjames 150
 
11 mjames 151
 
2 mjames 152
/* a type to hold a VHDL data type */
11 mjames 153
typedef struct vhdl {
154
  char * basetype;
155
  expression_t * decl_expr; /* the range given in its declaration */
2 mjames 156
 
11 mjames 157
  expression_t * expr; /* the expression that is used to */
158
                       /* define the values of high/low etc */
159
  expression_t * default_expr; /* default value assigned in declaration */
160
/*  char * text; */  /* this is the original declaration */
161
/*  int low;
162
  int high; */
163
  unsigned int    valid:1;     /* is the expression valid ? */
164
  unsigned int    is_vector:1;  /* is this port a vector */
165
  unsigned int    is_downto:1;  /* is the vector X TO Y or X DOWNTO Y  */
166
  } vhdl_t;
2 mjames 167
 
11 mjames 168
 
2 mjames 169
/* object node : point in a circuit connected a socket and a net */
170
typedef struct node
171
{
11 mjames 172
  struct node * sktnext; /* linked to a socket */
173
  char * identifier;      /* e.g 102, A22 */
174
  char * name;            /* internal signal name (actually same as netname )  */
2 mjames 175
 
11 mjames 176
  vhdl_t * vhdltype;      /* the subset of the net that the node is connected to */
177
  vhdl_t * orig_vhdltype; /* how this node was originally declared */  
178
  expression_t * lhs_expr;/* if the net is sliced on socket pin assignment LHS */
179
  pindir_t   pindir;      /* final pin type input? output? bidir? unknown? */
180
  int        pin_group;   /* can say 'any pin in group(n) only  is interchangeable' */
181
  struct net * net;       /* refer to net this node is on (if known) */
2 mjames 182
 
11 mjames 183
  struct net * routed_net; /* which routed net connects to this node */
2 mjames 184
 
11 mjames 185
  int    refcount;        /* how many nets refer to this node */
186
  struct socket * socket; /* refer to socket this node is part of */
187
  struct equivalent_node_set * equivalent_nodes; /* member of set of equivalent nodes */
2 mjames 188
 
11 mjames 189
/* sorting data structure */
190
  char * id_numeric_chars; /* the numeric part of the identifier */
191
  int    id_numeric_cnt;   /* the number of numeric chars in this part of the identifier */
2 mjames 192
 
11 mjames 193
  char * id_alpha_chars;   /* the alphabetic part of the identifier */
194
  int    id_alpha_cnt;     /* the number of alpha chars in this part of the ident */
2 mjames 195
 
11 mjames 196
  int    pin_row;
197
  int    pin_col;
198
  int    pin_index;        /*  the ordinal pin number : which would be used in a bundle */
199
  int    bundle_index; /* if >=0 then this pin is in a bundle */
2 mjames 200
 
11 mjames 201
  unsigned int fixed_pin:1;/* if fixed_pin = 1 then this pin can only be used
202
                              to connect to the net in a particular
203
                              direction */
204
  unsigned int in_use:1;   /* if '1' the node is used by a pin
205
                              if '0' the node has had a dummy name assigned*/
206
  unsigned int template_flag:1;   /* used in template processing */
207
  unsigned int net_assigned:1; /* if '1' the node (name) has a net assigned
208
                                  to it by routing */
209
  unsigned int fix_location:1; /* if set then nets referring to this pin
210
                                  have to be connected to it and nowhere else */
211
  unsigned int reservation:1;  /* mark this as a reserved pin when it is given rsvXXXX ident */
2 mjames 212
 
11 mjames 213
 
2 mjames 214
} node_t;
215
 
11 mjames 216
 
2 mjames 217
/* different nets may refer to the same nodes
218
   but dependent on whether net is desired or already routed, different rules
219
   apply */
220
 
221
typedef struct noderef
222
{
11 mjames 223
  struct noderef * next;
224
  pindir_t   pindir;      /* proposed pin type input ? output ? bidir ? unknown ? */
225
  node_t * node;
226
  struct net * join_parent; /* Which net this node reference is joined to (used in
227
                               alias/jumpering */
228
  struct net  * net;
229
                          /* the net that owns this node reference */
230
  unsigned int r_flag:1;  /* a routing flag to indicate this node has been
231
                             found already at this phase of routing  */
232
/*  char * datatype; */       /* pointer to the data type of this node */
2 mjames 233
 
11 mjames 234
  vhdl_t *  vhdltype;                  /* what this now has been aliased to in VHDL */
235
  vhdl_t *  orig_vhdltype;                  /* what this now has been aliased to in VHDL */
236
  expression_t * lhs_expr;  /* the expression will be copied over when routing . Bus slice on LHS of pin assignment */
237
  char *   orig_name;       /* if this pointer is not null then the name of this reference will be used
238
                             in place of the net name when listing the nets  */
2 mjames 239
 
11 mjames 240
  struct noderef * base_noderef; /* used in jumpering to define original node reference that will be renamed:
241
                                    in the original node reference this pointer is to itself */
2 mjames 242
} noderef_t;
243
 
11 mjames 244
 
2 mjames 245
/* the aliased net join means that each sub_net keeps its own
246
   signal name while its identiier is common. The Jumpered
247
   net join means that the new signal is to be treated
248
   as a new net entity */
249
 
11 mjames 250
typedef enum {
251
  NotJoined=0,
252
  Aliased,  /* names are aliased onto same physical piece of wire */
253
  Jumpered, /* separate wires can be joined together */
2 mjames 254
} JoinMode_t;
255
 
11 mjames 256
 
2 mjames 257
/* object net : a piece of wire connected to a set of nodes */
258
 
11 mjames 259
 
260
 
2 mjames 261
typedef struct net
262
{
11 mjames 263
  struct net * next;
264
  struct net * prev;      /* demand that previous net be referred to */
265
  struct net ** list_ref; /* the membership of which list:
266
                             routed_list unrouted_list named_list*/
267
  char * identifier;      /* e.g N1, N2 */
268
  char * name;            /* signal names */
269
  HowRouted_t how_routed; /* in fact this indicates how it was routed */
270
  int      nodecount;     /* how many nodes does this net have ? */
271
  noderef_t * nodes;      /* and all the other nodes on this net */
272
  struct net * join_parent; /* Which net this net is joined to (used in
273
                               alias/jumpering */
274
  struct net * subnets;     /* if this net has subnets , refer to them */
275
  struct net * joined_nets; /* other nets at this level of join */
276
  struct net * unrouted_fix_net; /* is there an unrouted net fixed to this one ? */
277
  struct net * vhdl_connect_net; /* pointer to a net connected by VHDL connection */
278
  JoinMode_t how_joined;  /* if subnets, is this an alias join or a
279
                             jumpered join */
280
  struct net * unrouted_reference; /* points at the net that is the unrouted
281
                                      original , if this is a routed net. */
282
  node_t * external_node    ; /* if not null and there is a jumper then print
283
                                 the external node name rather than the net name*/
284
  unsigned int nodes_reserved : 1; /* This net has been processed by the ensure_reservation function in routing.c */
285
  unsigned int has_external : 1 ; /* one of the net nodes (at least)
286
                                     is an external connection */
287
  unsigned int has_fix_location : 1 ; /* one of the net nodes (at least)
288
                                         is a FIX_LOCATION pin */
289
/* expanded information for partitioning */
290
  unsigned int leaves_partition : 1; /* '1' : crosses boundary of partition*/
291
  unsigned int inside_partition : 1; /* '1' : in use as internal signal
292
                                        in partition */
293
  unsigned int needs_buff_sig: 1;  /* if '1' then the external connection needs a local signal */
294
  unsigned int force_port: 1;  /* if '1' then the net will be forced to be a port on partition  */
295
  unsigned int type_defined: 1;  /* the signal type has been defined so does not need to be
296
                                    patched up by guesswork in the partition calculation Oct 2000*/
297
 /* bundle structures : cause signal renaming when sockets
298
    are converted to a wire bundle leaving the
299
    partition */
300
  unsigned int  bundle_member;  /* set if the net is a bundle member */
301
  int          bundle_index;       /* the ordinal number of the pin of the bundle */
2 mjames 302
 
11 mjames 303
  pindir_t ext_dir;                  /* basic boundary crossing direction*/
304
/*  char *   datatype;  */                 /* the string description of the data type */
305
  vhdl_t * vhdltype;                  /* what this looks like in VHDL */
2 mjames 306
} net_t;
307
 
308
/* net reference list, attched to a node */
309
typedef struct netref
310
{
11 mjames 311
  struct netref * next;
312
  net_t * net;
2 mjames 313
} netref_t;
314
 
11 mjames 315
 
2 mjames 316
/* unrouted node reference, which permits node by node pin  renaming */
317
 
318
typedef struct unrouted_ref
319
{
11 mjames 320
  struct unrouted_ref * next;
321
  net_t ** listref;       /* the root pointer of which list this unrouted reference has been added to */
322
  char * identifier;  /* used to point to the pin identifier before creating unrouted net */
323
  char * name;        /* this is the name by which this pin shall be known */
324
  char * orig_name;       /* if this pointer is not null then the name of this reference will be used
325
                             in place of the net name when creating the nets !! */
326
  pindir_t   pindir;      /* proposed pin type input ? output ? bidir ? unknown ? */
327
  int        pin_group;
328
  vhdl_t *  vhdltype;                  /* what this looks like in VHDL */
329
  vhdl_t *  orig_vhdltype;  /* place holder for the signal type as originally declared */
330
  expression_t * lhs_expr; /* expression is sliced on the LHS */
2 mjames 331
} unrouted_ref_t;
332
 
11 mjames 333
 
2 mjames 334
/* member of list of pins  that carry the same signal on a device */
11 mjames 335
typedef struct equivalent_node {
336
  struct equivalent_node * next;
337
  node_t * node;
338
  } equivalent_node_t;
2 mjames 339
 
340
/* pointer to list of lists of pins  that carry the same signal on a device */
11 mjames 341
typedef struct equivalent_node_set {
342
  struct equivalent_node_set * next;
343
  equivalent_node_t * nodes;
344
  } equivalent_node_set_t;
2 mjames 345
 
346
/* a chip socket is a socket, as are all the board connectors */
347
/* A lastnode pointer is provided so that new nodes can be added to the     */
348
/* end rather than the beginning of the list */
349
/* reason: so that priority of assigning nodes is kept */
350
/* this will be altered by the sorting of the nodes by identifier */
351
typedef struct socket
352
{
11 mjames 353
  struct socket * next;
354
  struct socket * template_socket; /* the VHDL component for this entity if present */
355
  char * identifier; /* e.g U1, U2 */
356
  char * type;
357
  char * name;
358
  char * value;
359
  node_t * nodes; /* the nodes attached to this chip */
360
  node_t * lastnode;
361
  unrouted_ref_t * unrouted_refs; /* when an unrouted node is read in the node is added here */
362
  generic_info_t * generics; /* look in generic.c for more info */
363
  generic_info_t * unrouted_generics;/* before elaboration */
364
  equivalent_node_set_t *  equivalent_node_set; /* these pins carry equivalent signals
365
                                     FPGA context : represent inner through signals
366
                                     component context : represent external jumpers
367
                                     around pins of component. */
2 mjames 368
 
11 mjames 369
  int max_pin_col;     /* determine pin identifier limits for later (see sorting.c, */
370
  int min_pin_col;     /* sorting device pin IDs for more info.)                    */
371
  int max_pin_row;
372
  int min_pin_row;
373
 
374
  unsigned int is_FPGA:1;     /*  alters interpretation of equivalent nodes */
2 mjames 375
 
11 mjames 376
  unsigned int selected:1;   /* a '1' here is used in the VHDL printout */
377
  unsigned int is_external:1; /* a '1' here changes the rules about external ports*/
378
                              /* If it is external then all nets attached give their
379
                                 names to the pins of the socket rather than calling
380
                                 them 'rsvXXXXXz' */
381
  unsigned int is_template:1; /*   this chip is a template if it is '1' */
382
  unsigned int socket_type_seen:1;   /* used in verilog printout to force
383
                                    * printout of only one instance
384
                                    * of a particular type */
385
  struct socket * parent_template_ref; /*   this chip is an alias template if this pointer is non-null  */
386
  int    route_flags;         /* any device can have its fasttrack flags set independently */
387
  int    named_in_use_cnt;    /* counters used by the statistics module */
388
  int    named_cnt;
389
  int    routed_cnt;
390
  int    unrouted_cnt;
391
  int    lowest_bundle; /* base for bundle indices */
2 mjames 392
 
11 mjames 393
  int highest_bundle ; /* non-zero will create an external net declaration using a bus with highest_bundle -1 pins on it in the top
394
                          level of a partition */
395
  int bundle_width   ; /* number of valid pins in the bundle */
2 mjames 396
} socket_t;
397
 
398
/* case insensitive strcmp */
11 mjames 399
extern int strcmp2(char * s, char * t);
2 mjames 400
 
11 mjames 401
 
402
 
2 mjames 403
/* this is equvalent to 'strdup' but checks null pointer */
404
/* extern char *  allocstr(char * s); */
11 mjames 405
#define allocstr(s) ((s)==NULL ? NULL : strdup(s))
2 mjames 406
 
407
 
408
 
11 mjames 409
 
410
extern vhdl_t * get_vhdl_buswidth( noderef_t * ref );
411
 
412
extern void define_pin(net_t ** listref,
413
                       socket_t * chip,
414
                       char * name,
415
                       int pin_type,
416
                       int pin_group,
417
                       char * identifier,
418
                       vhdl_t * vhdl,
419
                       expression_t * lhs_expr);
420
 
2 mjames 421
/* this is a check on a socket ident : if it doesnt have one */
422
 
11 mjames 423
extern void ensure_socket_ident(socket_t * chip);
2 mjames 424
 
425
/* a string that is suffixed to names and identifiers
426
   when read in from the database */
427
 
11 mjames 428
extern void set_board_suffix(char * s);
2 mjames 429
 
11 mjames 430
 
2 mjames 431
/* set the socket type for further information */
11 mjames 432
extern void set_socket(socket_t * socket,
433
                       property_t prop,
434
                       char * str);
2 mjames 435
 
436
/* Tell the system about a new socket */
437
/* locate a socket by a property */
11 mjames 438
extern socket_t * find_socket(property_t prop,
439
                              char * str,
440
                              int srchonly,
441
                              socket_t ** head_ref);
2 mjames 442
 
443
 
11 mjames 444
extern void set_net(net_t * net,property_t prop,char * str);
2 mjames 445
 
11 mjames 446
extern net_t * find_net(net_t ** listref,
447
                        property_t prop,
448
                        char * str,
449
                        int srchonly);
450
 
2 mjames 451
/* set a node property */
11 mjames 452
extern void set_node(node_t * node,
453
                     property_t prop,
454
                     char * str);
2 mjames 455
 
456
/* locate a node on a chip by a property */
11 mjames 457
extern node_t * find_node(socket_t * socket,
458
                          property_t prop,
459
                          char * str,
460
                          int srchonly);
2 mjames 461
 
462
/* joins a node to a net */
11 mjames 463
extern void connect_node_net(char * orig_name, /* added to allow name aliasing (this will be the OLD name ) */
464
                             node_t * cnode,
465
                             net_t * cnet,
466
                             pindir_t pindir,
467
                             vhdl_t * vhdl,
468
                             vhdl_t * orig_vhdl,
469
                             expression_t * lhs_expr);
2 mjames 470
 
11 mjames 471
 
2 mjames 472
/* remove net name attributes from the routed list */
11 mjames 473
extern void del_net_names(char * template);
2 mjames 474
 
11 mjames 475
 
2 mjames 476
/* disconnect a node from the netlist */
11 mjames 477
extern void disconnect_node(socket_t * chip, node_t * node);
2 mjames 478
 
11 mjames 479
 
2 mjames 480
/* global variables */
481
/* used in setting the routing status attribute of a net */
482
/* these are constant strings  */
483
/*extern char   Routed[]  ;     */ /* "Routed"    */
484
/*extern char   AssignedName[] ;*/ /* "Named"     */
485
/*extern char   Unrouted[] ;    */ /* "Unrouted"  */
486
 
487
 
11 mjames 488
extern socket_t * socket_head;
489
extern socket_t * template_head;
490
extern net_t    * routed_list;
491
extern net_t    * named_list;
492
extern net_t    * named_tail;
493
extern net_t    * unrouted_list;
2 mjames 494
 
495
 
11 mjames 496
extern char  nullstr[];
2 mjames 497
 
11 mjames 498
extern char * decode_how_routed[];
499
 
500
 
501
extern char * decode_which_list(net_t ** list_head);
502
 
503
 
2 mjames 504
/* this points at std_logic, std_ulogic etc */
11 mjames 505
extern vhdl_t * default_vhdl_datatype;
506
extern vhdl_t * default_vhdl_bustype;
2 mjames 507
 
11 mjames 508
extern void InitialiseData(void);
2 mjames 509
 
11 mjames 510
 
511
 
2 mjames 512
#endif