Subversion Repositories Vertical

Rev

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

  1. /*
  2.  * $Id: unrouted.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $
  3.  *
  4.  * $Log: unrouted.c,v $
  5.  * Revision 1.1.1.1  2003/11/04 23:34:57  mjames
  6.  * Imported into local repositrory
  7.  *
  8.  * Revision 1.5  2002/09/27 22:27:37  MJAMES
  9.  * Added lhs_expr for cases like
  10.  *
  11.  * x(0) <= y
  12.  *
  13.  * where x is std_logic_vector(0 downto 0) and y is std_logic.
  14.  *
  15.  * Revision 1.4  2002/01/16 10:08:53  mjames
  16.  * converted to use #ident
  17.  *
  18.  * Revision 1.3  2001/10/31 22:20:19  mjames
  19.  * Tidying up problematical comments caused by CVS
  20.  * 'intelligent' comment guessing
  21.  *
  22.  */
  23.  
  24. #include <stdio.h>
  25. #include <string.h>
  26. #include <stdlib.h>
  27. #include <ctype.h>
  28.  
  29. #include "vertcl_main.h"
  30. #include "expression.h"
  31. #include "generic.h"
  32. #include "database.h"
  33. #include "lx_support.h"
  34. #include "unrouted.h"
  35. #include "statistics.h"
  36. #include "cmdparse.h"
  37. #include "cmdlog.h"
  38.  
  39. #ident "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/unrouted.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $"
  40.  
  41.  
  42.  
  43. /* function that creates the node reference lists for one chip in the list ,
  44.    these functions perform operations that were done inside database.c.
  45.   */
  46.    
  47. int create_nodes_from_refs(socket_t * socket,int donesomething)
  48.   {
  49.   unrouted_ref_t * ref,*prev;
  50.   node_t * cnode;
  51.   net_t *  cnet;
  52.   char null_name;
  53.   char * netname;
  54.   int errseen = 0;
  55.   if(!socket) {
  56.     Log(LOG_ERROR,"-- missing socket \n");
  57.     return(1);
  58.     }
  59.  
  60.   ref = socket->unrouted_refs;
  61.   while(ref) {
  62.  
  63. /* pick up any new pin identifiers */
  64.     cnode = find_node(socket,Ident,ref->identifier,Create);
  65.  
  66. /* if this node is already on a net on the routed list,
  67.    it has already been linked up
  68.    so it should not be duplicated !!  */  
  69. /* iterate each node on the chip */
  70.  
  71.     if ((ref->listref == &routed_list) &&  cnode->net) /* duplicate !!! */  
  72.       {
  73.       if(! errseen) {
  74.         errseen=1;
  75.         Log(LOG_ERROR,"-- Errors while creating unrouted list from pins :\n");
  76.         }
  77.       Log(LOG_ERROR,"--  Error ! node %s(%s) is already in existence on routed net %s\n",
  78.          socket->identifier,ref->identifier,cnode->net->name);
  79.  
  80.       }        
  81.     else {
  82.       netname   = ref->name;
  83.       null_name = ISNULLSTR(netname);
  84.     /* bidir pins are essentially free for routing */
  85.       if (null_name || socket->is_template) {
  86.         if(ref->pindir != BIDIR)
  87.           cnode->fixed_pin = 1;
  88.         cnode->pindir    = ref->pindir;
  89.       }
  90.      if(socket->is_template || ref->listref == &routed_list) {
  91.        cnode->pin_group = ref->pin_group;
  92.  
  93.  
  94.        cnode->vhdltype  = ref->vhdltype;
  95. #if defined DEBUG_EXPRESSION  
  96.        if (cnode->vhdltype) {
  97.          print_msg_expression(stdout,"COPYING ",cnode->vhdltype->expr);
  98.          }
  99. #endif
  100.        if(!null_name)
  101.        cnode->name      = strdup(netname);
  102.        }  
  103.      if (!socket->is_template && !null_name ) {
  104.        cnet  = find_net(ref->listref,
  105.                         Ident,
  106.                         netname,
  107.                         Create);
  108.        connect_node_net(ref->orig_name,
  109.              cnode,cnet,ref->pindir,
  110.              ref->vhdltype,
  111.              ref->orig_vhdltype,
  112.              ref->lhs_expr);
  113.        donesomething = 1;  
  114.        };  
  115.     }
  116.     prev=ref;
  117.     ref= ref->next;
  118.     free(prev);
  119.     }
  120.   socket->unrouted_refs = NULL; /* remove any references to unrouted stuff,
  121.                                    they are all free()'d now */    
  122.  
  123.   return 0;
  124.   }
  125.  
  126.  
  127. /* creates the unrouted list from unrouted_refs list for all sockets */
  128.  
  129. void create_unrouted_list(void)
  130. {
  131.   socket_t * socket = socket_head;
  132.   int donesomething = 0;
  133.   while(socket) {
  134.     donesomething = create_nodes_from_refs(socket,donesomething);
  135.   socket=socket->next;
  136.  
  137.   }
  138.   if(donesomething)
  139.     Log(LOG_GENERAL,"-- New pins converted to unrouted net\n");
  140.  
  141. }
  142.  
  143.  
  144. void rename_unrouted_pin_socket(socket_t * socket,
  145.                                 char * old_name,
  146.                                 char * new_name,vhdl_t * vhdl_type)  {
  147.   unrouted_ref_t * ref;
  148.   char * socket_name;
  149.  
  150.  
  151.   socket_name = socket->identifier;
  152.  
  153.   ref = socket->unrouted_refs;
  154.    
  155.   if(!ref)
  156.     Log(LOG_ERROR,"# ERROR pin rename : no pin '%s.%s'\n",socket_name,old_name);
  157.    
  158.    
  159.   while(ref) {
  160.     if(strcmp2(old_name,ref->name)==0) {
  161.     /* do rename only if there is a rename */
  162.       if(strcmp2(ref->orig_name,ref->name)!=0) {
  163.         ref->orig_name = ref->name; /* keep old name in alias part */
  164.         ref->name = strdup(new_name); /* and rename the unrouted node */
  165.         }
  166. /* if it does not have a base type then copy it */
  167.     if(!vhdl_type->basetype)
  168.       vhdl_type->basetype = default_vhdl_datatype->basetype;
  169.  
  170.     /* do pinslicing only if there is a pin slice involved */
  171.              
  172.       if(vhdl_type != default_vhdl_datatype) {
  173.         ref->orig_vhdltype = ref->vhdltype; /* keep old VHDL type around */
  174.         if(vhdl_type)
  175.           ref->vhdltype = copy_vhdl(vhdl_type,socket);         /* assign the new vhdl type */
  176.  
  177.         }
  178.  
  179.  
  180.       if(level & 16)
  181.         {    
  182.         Log(LOG_GENERAL,"# renaming '%s.%s' to be '%s'\n",socket_name,ref->orig_name,ref->name);
  183.         }
  184.       break;
  185.       }
  186.     ref=ref->next;
  187.     }
  188.   }
  189.  
  190.  
  191. void rename_unrouted_pin(char * socket_name,char * old_name,char * new_name,vhdl_t * vhdl_type)  {
  192.   socket_t * socket;
  193.   socket = find_socket(Ident,socket_name,Search,&socket_head);  
  194.   if(!socket) {
  195.     Log(LOG_ERROR,"# ERROR connecting port : Cannot Locate socket identified as '%s'\n",socket_name);
  196.     }
  197.   else
  198.     rename_unrouted_pin_socket(socket,old_name,new_name,vhdl_type);
  199.   }
  200.