Subversion Repositories Vertical

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * $Id: print_ports.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $
  3.  *
  4.  * $Log: print_ports.c,v $
  5.  * Revision 1.1.1.1  2003/11/04 23:34:57  mjames
  6.  * Imported into local repositrory
  7.  *
  8.  * Revision 1.11  2002/09/09 10:12:13  mjames
  9.  * Moved pin remapping function to pin ident editing function from
  10.  * sorting pin name routine.
  11.  *
  12.  * Revision 1.10  2002/01/03 16:36:10  mjames
  13.  * Method of accessing Vertical version changed to avoid
  14.  * global variable
  15.  *
  16.  * Revision 1.9  2001/12/13 22:16:51  mjames
  17.  * Using #ident with header to identify file
  18.  *
  19.  * fixed missing return code on function
  20.  *
  21.  * Revision 1.8  2001/10/31 22:20:11  mjames
  22.  * Tidying up problematical comments caused by CVS
  23.  * 'intelligent' comment guessing
  24.  *
  25.  * Revision 1.7  2001/10/31 16:20:39  mjames
  26.  * Added a datastructure to hide regular expression information from programs.
  27.  * Changed call to regexec to indicate 0 subexpressions to be matched
  28.  * rather than a number dependent on strlen(string) which was wrong.
  29.  *
  30.  * Revision 1.6  2001/10/23 21:11:08  mjames
  31.  * Refined the printout to make the generated HTML indicate
  32.  * bundle information in the cross reference list.
  33.  *
  34.  * Revision 1.5  2001/10/10 20:18:23  mjames
  35.  * Added a vert_regcomp function to compile regular expressions
  36.  * with '^' (match start string) and  '$' (match end string) bracketing
  37.  * this => wildcard must match entire string not just a part of it.
  38.  *
  39.  * Revision 1.4  2001/10/07 20:50:52  mjames
  40.  * Added wildcard checking (warn user about
  41.  * using wildcard '*' on the end of a string in stead of wildcard '.*')
  42.  *
  43.  * Revision 1.3  2001/09/28 10:17:14  mjames
  44.  * Removed coredump caused by trying to free() an auto variable in the
  45.  * regular expression handler
  46.  *
  47.  * Revision 1.2  2001/09/25 23:15:23  mjames
  48.  * Converted wildcards to use proper regexp pattern match library
  49.  *
  50.  * Revision 1.1  2001/09/21 14:19:52  mjames
  51.  * Implemented Write Pin command : fixed up HTML output
  52.  *
  53.  */
  54. #include "print_ports.h"
  55.  
  56. #include "chck_names.h"
  57. #include "cmdlog.h"
  58. #include "cmdparse.h"
  59. #include "database.h"
  60. #include "equivalent.h"
  61. #include "expression.h"
  62. #include "generic.h"
  63. #include "print_vhdl.h"
  64. #include "print_vlog.h"
  65. #include "printout.h"
  66. #include "sorting.h"
  67. #include "version.h"
  68. #include "vertcl_main.h"
  69.  
  70. #include <ctype.h>
  71. #include <regex.h>
  72. #include <stdio.h>
  73. #include <stdlib.h>
  74. #include <string.h>
  75. #include <sys/types.h>
  76. #include <time.h>
  77.  
  78. #ident                                                                                        \
  79.     "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/print_ports.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $"
  80.  
  81. /* for each pin on the connector, list out all of the information */
  82. int list_intersection (FILE *f, char *con_id, char *fpga_id)
  83. {
  84.         socket_t *connector = socket_head;
  85.         int found = 0;
  86.  
  87.         int rc;
  88.  
  89.         socket_t *fpga;
  90.         noderef_t *bnode;
  91.         node_t *node;
  92.         unsigned int sockets = 0;
  93.         unsigned int printed = 0;
  94.         /* compile regular expression */
  95.         vert_regex_t *preg;
  96.  
  97.         fpga = find_socket (Ident, fpga_id, Search, &socket_head);
  98.  
  99.         if (!fpga)
  100.         {
  101.                 Log (LOG_ERROR, "-- write pin cannot find fpga '%s'\n", fpga_id);
  102.                 return TCL_ERROR;
  103.         }
  104.  
  105.         rc = vert_regcomp (&preg, con_id);
  106.  
  107.         if (rc != 0)
  108.         {
  109.                 char errbuff[100];
  110.                 regerror (rc, preg->preg, errbuff, 100);
  111.                 Log (
  112.                     LOG_ERROR,
  113.                     "-- Problem (rc=%d) %s with '%s' as regular expression\n",
  114.                     rc,
  115.                     errbuff,
  116.                     con_id);
  117.  
  118.                 return TCL_ERROR;
  119.         }
  120.         else
  121.         {
  122.                 Log (LOG_GENERAL, "-- Using '%s' as match pattern\n", con_id);
  123.         }
  124.  
  125.         fprintf (f, "<html>\n");
  126.         fprintf (
  127.             f,
  128.             "<title>Cross ref for socket(s) '%s' and (FPGA) socket '%s'</title>\n",
  129.             con_id,
  130.             fpga_id);
  131.         fprintf (
  132.             f,
  133.             "<h2>Column names:</h2>\n"
  134.             "<dl>\n"
  135.             "<dt><b>socket pin</b><dd>The pin of the relevant socket.\n"
  136.             "<dt><b>index</b><dd>The Certify pin bundle index(if assigned)\n"
  137.             "<dt><b>net ident.</b><dd>The PCB netlist name (or jumper name)\n"
  138.             "<dt><b>sig. name</b><dd>The name of any signal routed through this net\n"
  139.             "</dl>\n"
  140.             "Please note only one fpga pin is given out of many if a multiple connection "
  141.             "exists\n");
  142.  
  143.         while (connector)
  144.         {
  145.                 found = regexec (preg->preg, connector->identifier, 0, preg->regpatt, 0);
  146.  
  147.                 if (!found)
  148.                 {
  149.                         int first_print = 1; /* suppress tables until needed */
  150.                         sockets++;
  151.                         sort_nodes (connector, NO_EXTRACT_XY); /* sort the pins on the
  152.                                                                   connector */
  153.                         node = connector->nodes;
  154.                         /*
  155.                               printf("completed sort\n");
  156.                         */
  157.                         while (node)
  158.                         {
  159.                                 if (node->net)
  160.                                 {
  161.                                         int found_node = 0;
  162.  
  163.                                         bnode = node->net->nodes;
  164.                                         while (bnode && !found_node)
  165.                                         {
  166.                                                 char *msg;
  167.                                                 char bundle_msg[20];
  168.                                                 if (bnode->node && bnode->node->socket == fpga)
  169.                                                 {
  170.                                                         if (first_print)
  171.                                                         {
  172.                                                                 fprintf (
  173.                                                                     f,
  174.                                                                     "<h2>crossref</h2>\n"
  175.                                                                     "<h3>connector id=%s "
  176.                                                                     "name=%s and fpga id=%s "
  177.                                                                     "name=%s</h3>\n",
  178.                                                                     connector->identifier,
  179.                                                                     connector->name
  180.                                                                         ? connector->name
  181.                                                                         : "",
  182.                                                                     fpga->identifier,
  183.                                                                     fpga->name ? fpga->name
  184.                                                                                : "");
  185.                                                                 fprintf (
  186.                                                                     f, "<table border=1>\n");
  187.                                                                 fprintf (
  188.                                                                     f,
  189.                                                                     "<tr><td> socket pin</td> "
  190.                                                                     "<td>index</td> <td>fpga "
  191.                                                                     "pin</td> <td>net "
  192.                                                                     "ident.</td><td>sig. "
  193.                                                                     "name</td></tr>\n");
  194.                                                                 first_print = 0;
  195.                                                         }
  196.                                                         if (node->bundle_index == 0)
  197.                                                         {
  198.                                                                 msg = "-";
  199.                                                         }
  200.                                                         else if (node->bundle_index < 0)
  201.                                                         {
  202.                                                                 msg = "NC";
  203.                                                         }
  204.                                                         else
  205.                                                         {
  206.                                                                 sprintf (
  207.                                                                     bundle_msg,
  208.                                                                     "%d",
  209.                                                                     node->bundle_index);
  210.                                                                 msg = bundle_msg;
  211.                                                         }
  212.  
  213.                                                         fprintf (
  214.                                                             f,
  215.                                                             "<tr><td>%s(%s)</td><td>%s</td> "
  216.                                                             "<td>%s(%s)</td> "
  217.                                                             "<td>%s</td><td>%s</td></tr>\n",
  218.                                                             connector->identifier,
  219.                                                             node->identifier,
  220.                                                             msg,
  221.                                                             fpga->identifier,
  222.                                                             bnode->node->identifier,
  223.                                                             bnode->net->name
  224.                                                                 ? bnode->net->identifier
  225.                                                                 : "",
  226.                                                             bnode->net->name ? bnode->net->name
  227.                                                                              : "");
  228.                                                         found_node =
  229.                                                             1; /* force loop termination */
  230.                                                 }
  231.                                                 bnode = bnode->next;
  232.                                         }
  233.                                 }
  234.                                 node = node->sktnext;
  235.                         }
  236.                         if (!first_print)
  237.                         {
  238.                                 printed++;
  239.                                 fprintf (f, "</table>\n<hr>\n");
  240.                         }
  241.                 }
  242.                 connector = connector->next;
  243.         }
  244.  
  245.         fprintf (
  246.             f,
  247.             "Tables generated by Vertical %s\n"
  248.             "<br>&copy; Philips Semiconductors SLS. "__DATE__
  249.             "<a "
  250.             "href=mailto:Mike.D.James@philips.com><address>mailto:Mike.D.James@philips.com</"
  251.             "address></a>\n"
  252.             "</html>\n",
  253.             Vertical_Version);
  254.  
  255.         vert_regfree (&preg);
  256.         Log (LOG_GENERAL, "-- located %d sockets matching pattern\n", sockets);
  257.         Log (LOG_GENERAL, "--  of which %d actually connect to '%s'\n", printed, fpga_id);
  258.         return TCL_OK;
  259. }
  260.