Subversion Repositories Vertical

Rev

Rev 9 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * $Header: C:/cvsroot/Vert03/vertlib/database.h,v 1.2 2004/06/22 21:44:14 mjames Exp $
  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.  *
  69.  *
  70.  */
  71.  #pragma once
  72. #include "expression.h"
  73. #include "generic.h"
  74.  
  75. #if !defined _DATABASE
  76. #define _DATABASE
  77.  
  78.  
  79. #define MAXIDLEN 1024
  80.  
  81. #define BUFPREFIX "XX_"
  82.  
  83. #if defined PC
  84. #define VERTICAL_INI_PATH "vertical.ini"
  85. #define VERTICAL_PATH ".;c:/cygwin/usr/local/vert_files"
  86. #else
  87. #define VERTICAL_INI_PATH "vertical.ini"
  88. #define VERTICAL_PATH ".;$(HOME)/.caddata/vert_files"
  89. /* DLL creation declaration mode. not used on HP */
  90. #if !defined __declspec
  91. #define __declspec(x)
  92. #endif
  93. #endif
  94.  
  95. /* incomplete declarations to placate 'c' */
  96.  
  97. struct connector;
  98. struct net;
  99. struct netref;
  100. struct equivalent_node_set;
  101.  
  102. /* the direction list */
  103. typedef enum
  104. {
  105.         NONE,
  106.         INPUT,
  107.         OUTPUT,
  108.         BUFFER,
  109.         BIDIR,
  110.         CONFIG,
  111.         POWER
  112. } pindir_t;
  113.  
  114. #define Create 0
  115. #define Search 1
  116.  
  117. #define ISNULLSTR(x) ((x == NULL) || (x && (x[0] == 0)))
  118.  
  119. /* operations to manipulate the data structure */
  120. /* from the ACF reader */
  121.  
  122. /* typedef enum { Ident,Type,Name,Value,Datatype,How_Routed } property_t; */
  123. typedef enum
  124. {
  125.         Ident,
  126.         Type,
  127.         Name,
  128.         Value,
  129.         How_Routed
  130. } property_t;
  131.  
  132. /* used in seting the routing_status attribute of a net */
  133.  
  134. typedef enum
  135. {
  136.         Free,           /* name given may be reassigned */
  137.         By_Name,        /* Routed by Name */
  138.         By_Net,         /* Routed by already existing net */
  139.         By_Fixed_Net,   /* Routed through fixed existing net */
  140.         By_Exact_Net,   /* Routed using identical already existing net */
  141.         By_Creating,    /* Routed by creating a new net */
  142.         By_Jumpering,   /* Routed by connecting an existing net */
  143.         By_FixPins,     /* can only go here as pins are fixed */
  144.         Not_Routable,   /* not allowed to participate in any routing */
  145.         Not_Routable_H, /* pullup/VCC */
  146.         Not_Routable_L  /* pulldown/GND */
  147. } HowRouted_t;
  148. /* these macros are reliant on sorted ordinal values */
  149. #define IS_NOT_ROUTABLE(x) ((x) >= Not_Routable)
  150. #define IS_ROUTABLE(x) ((x) < Not_Routable)
  151.  
  152. /* a type to hold a VHDL data type */
  153. typedef struct vhdl
  154. {
  155.         char *basetype;
  156.         expression_t *decl_expr; /* the range given in its declaration */
  157.  
  158.         expression_t *expr;         /* the expression that is used to */
  159.                                     /* define the values of high/low etc */
  160.         expression_t *default_expr; /* default value assigned in declaration */
  161.         /*  char * text; */         /* this is the original declaration */
  162.                                     /*  int low;
  163.                                       int high; */
  164.         unsigned int valid : 1;     /* is the expression valid ? */
  165.         unsigned int is_vector : 1; /* is this port a vector */
  166.         unsigned int is_downto : 1; /* is the vector X TO Y or X DOWNTO Y  */
  167. } vhdl_t;
  168.  
  169. /* object node : point in a circuit connected a socket and a net */
  170. typedef struct node
  171. {
  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 )  */
  175.  
  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) */
  182.  
  183.         struct net *routed_net; /* which routed net connects to this node */
  184.  
  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 */
  188.  
  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 */
  192.  
  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 */
  195.  
  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 */
  200.  
  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
  212.                                            ident */
  213.  
  214. } node_t;
  215.  
  216. /* different nets may refer to the same nodes
  217.    but dependent on whether net is desired or already routed, different rules
  218.    apply */
  219.  
  220. typedef struct noderef
  221. {
  222.         struct noderef *next;
  223.         pindir_t pindir; /* proposed pin type input ? output ? bidir ? unknown ? */
  224.         node_t *node;
  225.         struct net *join_parent; /* Which net this node reference is joined to (used in
  226.                                     alias/jumpering */
  227.         struct net *net;
  228.         /* the net that owns this node reference */
  229.         unsigned int r_flag : 1; /* a routing flag to indicate this node has been
  230.                                     found already at this phase of routing  */
  231.         /*  char * datatype; */  /* pointer to the data type of this node */
  232.  
  233.         vhdl_t *vhdltype;       /* what this now has been aliased to in VHDL */
  234.         vhdl_t *orig_vhdltype;  /* what this now has been aliased to in VHDL */
  235.         expression_t *lhs_expr; /* the expression will be copied over when routing . Bus slice
  236.                                    on LHS of pin assignment */
  237.         char *orig_name; /* if this pointer is not null then the name of this reference will be
  238.                           used in place of the net name when listing the nets  */
  239.  
  240.         struct noderef *base_noderef; /* used in jumpering to define original node reference
  241.                                          that will be renamed: in the original node reference
  242.                                          this pointer is to itself */
  243. } noderef_t;
  244.  
  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.  
  250. typedef enum
  251. {
  252.         NotJoined = 0,
  253.         Aliased,  /* names are aliased onto same physical piece of wire */
  254.         Jumpered, /* separate wires can be joined together */
  255. } JoinMode_t;
  256.  
  257. /* object net : a piece of wire connected to a set of nodes */
  258.  
  259. typedef struct net
  260. {
  261.         struct net *next;
  262.         struct net *prev;                  /* demand that previous net be referred to */
  263.         struct net **list_ref;             /* the membership of which list:
  264.                                               routed_list unrouted_list named_list*/
  265.         char *identifier;                  /* e.g N1, N2 */
  266.         char *name;                        /* signal names */
  267.         HowRouted_t how_routed;            /* in fact this indicates how it was routed */
  268.         int nodecount;                     /* how many nodes does this net have ? */
  269.         noderef_t *nodes;                  /* and all the other nodes on this net */
  270.         struct net *join_parent;           /* Which net this net is joined to (used in
  271.                                               alias/jumpering */
  272.         struct net *subnets;               /* if this net has subnets , refer to them */
  273.         struct net *joined_nets;           /* other nets at this level of join */
  274.         struct net *unrouted_fix_net;      /* is there an unrouted net fixed to this one ? */
  275.         struct net *vhdl_connect_net;      /* pointer to a net connected by VHDL connection */
  276.         JoinMode_t how_joined;             /* if subnets, is this an alias join or a
  277.                                               jumpered join */
  278.         struct net *unrouted_reference;    /* points at the net that is the unrouted
  279.                                               original , if this is a routed net. */
  280.         node_t *external_node;             /* if not null and there is a jumper then print
  281.                                               the external node name rather than the net name*/
  282.         unsigned int nodes_reserved : 1;   /* This net has been processed by the
  283.                                               ensure_reservation function in routing.c */
  284.         unsigned int has_external : 1;     /* one of the net nodes (at least)
  285.                                               is an external connection */
  286.         unsigned int has_fix_location : 1; /* one of the net nodes (at least)
  287.                                               is a FIX_LOCATION pin */
  288.                                            /* expanded information for partitioning */
  289.         unsigned int leaves_partition : 1; /* '1' : crosses boundary of partition*/
  290.         unsigned int inside_partition : 1; /* '1' : in use as internal signal
  291.                                               in partition */
  292.         unsigned int needs_buff_sig : 1;   /* if '1' then the external connection needs a local
  293.                                               signal */
  294.         unsigned int force_port : 1;   /* if '1' then the net will be forced to be a port on
  295.                                           partition  */
  296.         unsigned int type_defined : 1; /* the signal type has been defined so does not need to
  297.                                           be patched up by guesswork in the partition
  298.                                           calculation Oct 2000*/
  299.         /* bundle structures : cause signal renaming when sockets
  300.            are converted to a wire bundle leaving the
  301.            partition */
  302.         unsigned int bundle_member; /* set if the net is a bundle member */
  303.         int bundle_index;           /* the ordinal number of the pin of the bundle */
  304.  
  305.         pindir_t ext_dir;          /* basic boundary crossing direction*/
  306.         /*  char *   datatype;  */ /* the string description of the data type */
  307.         vhdl_t *vhdltype;          /* what this looks like in VHDL */
  308. } net_t;
  309.  
  310. /* net reference list, attched to a node */
  311. typedef struct netref
  312. {
  313.         struct netref *next;
  314.         net_t *net;
  315. } netref_t;
  316.  
  317. /* unrouted node reference, which permits node by node pin  renaming */
  318.  
  319. typedef struct unrouted_ref
  320. {
  321.         struct unrouted_ref *next;
  322.         net_t **listref;  /* the root pointer of which list this unrouted reference has been
  323.                              added to */
  324.         char *identifier; /* used to point to the pin identifier before creating unrouted net
  325.                            */
  326.         char *name;       /* this is the name by which this pin shall be known */
  327.         char *orig_name; /* if this pointer is not null then the name of this reference will be
  328.                             used in place of the net name when creating the nets !! */
  329.         pindir_t pindir; /* proposed pin type input ? output ? bidir ? unknown ? */
  330.         int pin_group;
  331.         vhdl_t *vhdltype;       /* what this looks like in VHDL */
  332.         vhdl_t *orig_vhdltype;  /* place holder for the signal type as originally declared */
  333.         expression_t *lhs_expr; /* expression is sliced on the LHS */
  334. } unrouted_ref_t;
  335.  
  336. /* member of list of pins  that carry the same signal on a device */
  337. typedef struct equivalent_node
  338. {
  339.         struct equivalent_node *next;
  340.         node_t *node;
  341. } equivalent_node_t;
  342.  
  343. /* pointer to list of lists of pins  that carry the same signal on a device */
  344. typedef struct equivalent_node_set
  345. {
  346.         struct equivalent_node_set *next;
  347.         equivalent_node_t *nodes;
  348. } equivalent_node_set_t;
  349.  
  350. /* a chip socket is a socket, as are all the board connectors */
  351. /* A lastnode pointer is provided so that new nodes can be added to the     */
  352. /* end rather than the beginning of the list */
  353. /* reason: so that priority of assigning nodes is kept */
  354. /* this will be altered by the sorting of the nodes by identifier */
  355. typedef struct socket
  356. {
  357.         struct socket *next;
  358.         struct socket *template_socket; /* the VHDL component for this entity if present */
  359.         char *identifier;               /* e.g U1, U2 */
  360.         char *type;
  361.         char *name;
  362.         char *value;
  363.         node_t *nodes; /* the nodes attached to this chip */
  364.         node_t *lastnode;
  365.         unrouted_ref_t *unrouted_refs; /* when an unrouted node is read in the node is added
  366.                                           here */
  367.         generic_info_t *generics;      /* look in generic.c for more info */
  368.         generic_info_t *unrouted_generics;          /* before elaboration */
  369.         equivalent_node_set_t *equivalent_node_set; /* these pins carry equivalent signals
  370.                                          FPGA context : represent inner through signals
  371.                                          component context : represent external jumpers
  372.                                          around pins of component. */
  373.  
  374.         int max_pin_col; /* determine pin identifier limits for later (see sorting.c, */
  375.         int min_pin_col; /* sorting device pin IDs for more info.)                    */
  376.         int max_pin_row;
  377.         int min_pin_row;
  378.  
  379.         unsigned int is_FPGA : 1; /*  alters interpretation of equivalent nodes */
  380.  
  381.         unsigned int selected : 1;    /* a '1' here is used in the VHDL printout */
  382.         unsigned int is_external : 1; /* a '1' here changes the rules about external ports*/
  383.                                       /* If it is external then all nets attached give their
  384.                                          names to the pins of the socket rather than calling
  385.                                          them 'rsvXXXXXz' */
  386.         unsigned int is_template : 1; /*   this chip is a template if it is '1' */
  387.         unsigned int socket_type_seen : 1;  /* used in verilog printout to force
  388.                                              * printout of only one instance
  389.                                              * of a particular type */
  390.         struct socket *parent_template_ref; /*   this chip is an alias template if this pointer
  391.                                                is non-null  */
  392.         int route_flags;      /* any device can have its fasttrack flags set independently */
  393.         int named_in_use_cnt; /* counters used by the statistics module */
  394.         int named_cnt;
  395.         int routed_cnt;
  396.         int unrouted_cnt;
  397.         int lowest_bundle; /* base for bundle indices */
  398.  
  399.         int highest_bundle; /* non-zero will create an external net declaration using a bus
  400.                                with highest_bundle -1 pins on it in the top level of a
  401.                                partition */
  402.         int bundle_width;   /* number of valid pins in the bundle */
  403. } socket_t;
  404.  
  405. /* case insensitive strcmp */
  406. extern int strcmp2 (char *s, char *t);
  407.  
  408. /* this is equvalent to 'strdup' but checks null pointer */
  409. /* extern char *  allocstr(char * s); */
  410. #define allocstr(s) ((s) == NULL ? NULL : strdup (s))
  411.  
  412. extern vhdl_t *get_vhdl_buswidth (noderef_t *ref);
  413.  
  414. extern void define_pin (
  415.     net_t **listref,
  416.     socket_t *chip,
  417.     char *name,
  418.     int pin_type,
  419.     int pin_group,
  420.     char *identifier,
  421.     vhdl_t *vhdl,
  422.     expression_t *lhs_expr);
  423.  
  424. /* this is a check on a socket ident : if it doesnt have one */
  425.  
  426. extern void ensure_socket_ident (socket_t *chip);
  427.  
  428. /* a string that is suffixed to names and identifiers
  429.    when read in from the database */
  430.  
  431. extern void set_board_suffix (char *s);
  432.  
  433. /* set the socket type for further information */
  434. extern void set_socket (socket_t *socket, property_t prop, char *str);
  435.  
  436. /* Tell the system about a new socket */
  437. /* locate a socket by a property */
  438. extern socket_t *find_socket (property_t prop, char *str, int srchonly, socket_t **head_ref);
  439.  
  440. extern void set_net (net_t *net, property_t prop, char *str);
  441.  
  442. extern net_t *find_net (net_t **listref, property_t prop, char *str, int srchonly);
  443.  
  444. /* set a node property */
  445. extern void set_node (node_t *node, property_t prop, char *str);
  446.  
  447. /* locate a node on a chip by a property */
  448. extern node_t *find_node (socket_t *socket, property_t prop, char *str, int srchonly);
  449.  
  450. /* joins a node to a net */
  451. extern void connect_node_net (
  452.     char *orig_name, /* added to allow name aliasing (this will be the OLD name ) */
  453.     node_t *cnode,
  454.     net_t *cnet,
  455.     pindir_t pindir,
  456.     vhdl_t *vhdl,
  457.     vhdl_t *orig_vhdl,
  458.     expression_t *lhs_expr);
  459.  
  460. /* remove net name attributes from the routed list */
  461. extern void del_net_names (char *template);
  462.  
  463. /* disconnect a node from the netlist */
  464. extern void disconnect_node (socket_t *chip, node_t *node);
  465.  
  466. /* global variables */
  467. /* used in setting the routing status attribute of a net */
  468. /* these are constant strings  */
  469. /*extern char   Routed[]  ;     */ /* "Routed"    */
  470. /*extern char   AssignedName[] ;*/ /* "Named"     */
  471. /*extern char   Unrouted[] ;    */ /* "Unrouted"  */
  472.  
  473. extern socket_t *socket_head;
  474. extern socket_t *template_head;
  475. extern net_t *routed_list;
  476. extern net_t *named_list;
  477. extern net_t *named_tail;
  478. extern net_t *unrouted_list;
  479.  
  480. extern char nullstr[];
  481.  
  482. extern char *decode_how_routed[];
  483.  
  484. extern char *decode_which_list (net_t **list_head);
  485.  
  486. /* this points at std_logic, std_ulogic etc */
  487. extern vhdl_t *default_vhdl_datatype;
  488. extern vhdl_t *default_vhdl_bustype;
  489.  
  490. extern void InitialiseData (void);
  491.  
  492. #endif
  493.