[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: CVS update: g_netlist.c



  User: cnieves 
  Date: 06/04/22 16:09:27

  Modified:    .        g_netlist.c g_register.c globals.c s_netlist.c
                        s_traverse.c
  Log:
  Added support for directives as graphical objects in schematics.
  
  Changed the drc2 backend to use directives, as well as include several 
  
  improvements.
  
  
  
  
  Revision  Changes    Path
  1.43      +86 -0     eda/geda/devel/gnetlist/src/g_netlist.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: g_netlist.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gnetlist/src/g_netlist.c,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -b -r1.42 -r1.43
  --- g_netlist.c	6 Mar 2006 18:25:21 -0000	1.42
  +++ g_netlist.c	22 Apr 2006 20:09:27 -0000	1.43
  @@ -941,6 +941,92 @@
   }
   
   
  +/* given a net name, an attribute, and a wanted attribute, return all 
  +   the given attribute of all the graphical objects connected to that 
  +   net name */
  +SCM g_graphical_objs_in_net_with_attrib_get_attrib (SCM scm_netname, SCM scm_has_attribute, SCM scm_wanted_attribute)
  +{
  +
  +    SCM list = SCM_EOL;
  +    NETLIST *nl_current;
  +    CPINLIST *pl_current;
  +    char *wanted_net_name;
  +    char *wanted_attrib;
  +    char *has_attrib;
  +    char *net_name;
  +    char *attrib_value=NULL;
  +    char *has_attrib_value = NULL;
  +    char *has_attrib_name = NULL;
  +
  +    SCM_ASSERT( (SCM_NIMP (scm_netname) && SCM_STRINGP (scm_netname) ),
  +		 scm_netname, SCM_ARG1, 
  +		"gnetlist:get-attr-of-conn-graph-objs-with-attr");
  +
  +    SCM_ASSERT( (SCM_NIMP (scm_wanted_attribute) && 
  +		 SCM_STRINGP (scm_wanted_attribute) ),
  +		 scm_wanted_attribute, SCM_ARG2, 
  +		"gnetlist:get-attr-of-conn-graph-objs-with-attr");
  +
  +    SCM_ASSERT( (SCM_NIMP (scm_has_attribute) && 
  +		 SCM_STRINGP (scm_has_attribute) ),
  +		 scm_has_attribute, SCM_ARG3, 
  +		"gnetlist:get-attr-of-conn-graph-objs-with-attr");
  +
  +    wanted_net_name = SCM_STRING_CHARS (scm_netname);
  +    wanted_attrib = SCM_STRING_CHARS (scm_wanted_attribute);
  +    has_attrib = SCM_STRING_CHARS (scm_has_attribute);
  +    
  +    if (wanted_net_name == NULL) {
  +	return list;
  +    }
  +
  +
  +    nl_current = graphical_netlist_head;
  +    
  +    /* walk through the list of components, and through the list
  +     * of individual pins on each, adding net names to the list
  +     * being careful to ignore duplicates, and unconnected pins 
  +     */
  +    while (nl_current != NULL) {
  +	pl_current = nl_current->cpins;
  +	while (pl_current != NULL) {
  +	    if (pl_current->net_name) {
  +		net_name = pl_current->net_name;
  +		if (strcmp(net_name, wanted_net_name) == 0) {
  +
  +		  if (o_attrib_get_name_value (has_attrib, &has_attrib_name,
  +					       &has_attrib_value) != 0) {
  +		    attrib_value = 
  +		      o_attrib_search_name_single(nl_current->object_ptr,
  +						  has_attrib_name, NULL);
  +		    
  +		    if ( ((has_attrib_value == NULL) && (attrib_value == NULL)) ||
  +			 ((has_attrib_value != NULL) && (attrib_value != NULL) &&
  +			  (strcmp(attrib_value, has_attrib_value) == 0)) ) {
  +		      g_free (attrib_value);
  +		      attrib_value = o_attrib_search_name_single(nl_current->object_ptr,
  +								 wanted_attrib, NULL);
  +		      if (attrib_value) {
  +			list = scm_cons (scm_makfrom0str (attrib_value), list);
  +		      }
  +		      g_free (attrib_value);
  +		    }
  +		    g_free (has_attrib_name);
  +		    g_free (has_attrib_value);
  +		  }
  +		}
  +	    }
  +	    pl_current = pl_current->next;
  +	}
  +	nl_current = nl_current->next;
  +    }
  +
  +    return list;
  +}
  +
  +
  +
  +
   
   /* 
    * This function is in s_rename.c:  SCM g_get_renamed_nets(SCM scm_level)
  
  
  
  1.31      +3 -0      eda/geda/devel/gnetlist/src/g_register.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: g_register.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gnetlist/src/g_register.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -b -r1.30 -r1.31
  --- g_register.c	4 Feb 2005 23:14:30 -0000	1.30
  +++ g_register.c	22 Apr 2006 20:09:27 -0000	1.31
  @@ -89,6 +89,9 @@
     { "gnetlist:get-slots",           1, 0, 0, g_get_slots },
     { "gnetlist:get-unique-slots",    1, 0, 0, g_get_unique_slots },
   
  +  { "gnetlist:graphical-objs-in-net-with-attrib-get-attrib",    
  +    3, 0, 0, g_graphical_objs_in_net_with_attrib_get_attrib },
  +
     /* SDB -- 9.1.2003 */
     { "gnetlist:get-calling-flags",   0, 0, 0, g_get_calling_flags },
     /* SDB -- 8.22.2004 */
  
  
  
  1.23      +2 -0      eda/geda/devel/gnetlist/src/globals.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: globals.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gnetlist/src/globals.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -b -r1.22 -r1.23
  --- globals.c	27 Nov 2005 00:15:00 -0000	1.22
  +++ globals.c	22 Apr 2006 20:09:27 -0000	1.23
  @@ -64,6 +64,8 @@
   
   /* netlist specific variables */
   NETLIST *netlist_head=NULL;
  +NETLIST *graphical_netlist_head=NULL; /* Special objects with 
  +					 graphical=1 attribute */
   char *guile_proc=NULL; 
   
   
  
  
  
  1.19      +89 -0     eda/geda/devel/gnetlist/src/s_netlist.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: s_netlist.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gnetlist/src/s_netlist.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -b -r1.18 -r1.19
  --- s_netlist.c	4 Feb 2005 23:14:31 -0000	1.18
  +++ s_netlist.c	22 Apr 2006 20:09:27 -0000	1.19
  @@ -220,3 +220,92 @@
   
       verbose_done();
   }
  +
  +void s_netlist_name_named_nets (TOPLEVEL *pr_current,
  +				NETLIST *named_netlist,
  +				NETLIST *unnamed_netlist) {
  +
  +  NETLIST *nl_current;
  +  CPINLIST *pl_current;
  +  NET *n_current;
  +  char *net_name;
  +  
  +  if (verbose_mode) {
  +    printf("\n- Staring post processing\n");
  +    printf("- Naming nets of graphical objects:\n");
  +  }
  +  
  +  /* this pass gives all nets a name, whether specified or creates a */
  +  /* name */
  +  nl_current = unnamed_netlist;
  +  while (nl_current != NULL) {
  +    if (nl_current->cpins) {
  +      pl_current = nl_current->cpins;
  +      while (pl_current != NULL) {
  +	
  +	if (pl_current->plid != -1) {
  +	  verbose_print("p");
  +	}
  +	
  +	if (pl_current->plid != -1 && pl_current->nets) {
  +	  verbose_print("n");
  +	  net_name = NULL;
  +	  n_current = pl_current->nets;
  +	  while (n_current != NULL) {
  +	    if (n_current->net_name) {
  +	      free (n_current->net_name);
  +	    }	    
  +	    n_current->net_name = s_netlist_netname_of_netid(pr_current,
  +							     named_netlist,
  +							     n_current->nid);
  +	    
  +	    if (n_current->net_name != NULL) {
  +	      net_name = n_current->net_name;
  +	    }
  +	    n_current = n_current->next;
  +	  }
  +	  if (net_name != NULL) {
  +	    pl_current->net_name = g_strdup(net_name);
  +	  }
  +	}
  +	pl_current = pl_current->next;
  +      }
  +    }
  +    nl_current = nl_current->next;
  +  }
  +
  +  verbose_done();
  +    
  +}
  +
  +char *s_netlist_netname_of_netid (TOPLEVEL *pr_current,
  +				  NETLIST *netlist_head,
  +				  int net_id) {
  +
  +  NETLIST *nl_current;
  +  CPINLIST *pl_current;
  +  NET *n_current;
  +  
  +  nl_current = netlist_head;
  +  
  +  /* walk through the list of components, and through the list
  +   * of individual pins on each, looking for the net identifier
  +   */
  +  while (nl_current != NULL) {
  +    pl_current = nl_current->cpins;
  +    while (pl_current != NULL) {
  +      if (pl_current->net_name) {
  +	n_current = pl_current->nets;
  +	while (n_current != NULL) {
  +	  if (n_current->nid == net_id) {
  +	    return (g_strdup(n_current->net_name));
  +	  }
  +	  n_current = n_current->next;
  +	}
  +      }
  +      pl_current = pl_current->next;
  +    }
  +    nl_current = nl_current->next;
  +    } 
  +  return NULL;
  +}
  
  
  
  1.42      +88 -76    eda/geda/devel/gnetlist/src/s_traverse.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: s_traverse.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gnetlist/src/s_traverse.c,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -b -r1.41 -r1.42
  --- s_traverse.c	4 Jan 2006 14:36:25 -0000	1.41
  +++ s_traverse.c	22 Apr 2006 20:09:27 -0000	1.42
  @@ -39,6 +39,9 @@
       netlist_head = s_netlist_add(NULL);
       netlist_head->nlid = -1;	/* head node */
   
  +    graphical_netlist_head = s_netlist_add(NULL);
  +    graphical_netlist_head->nlid = -1;	/* head node */
  +
       if (verbose_mode) {
   	printf
   	    ("\n\n------------------------------------------------------\n");
  @@ -84,6 +87,10 @@
       /* post processing work */
       s_netlist_post_process(pr_current, netlist_head);
   
  +    /* Now match the graphical netlist with the net names already assigned */
  +    s_netlist_name_named_nets(pr_current, netlist_head, 
  +			      graphical_netlist_head);
  +			      
       if (verbose_mode) {
   	printf("\nInternal netlist representation:\n\n");
   	s_netlist_print(netlist_head);
  @@ -99,6 +106,7 @@
     NETLIST *netlist;
     char *temp;
     char *temp_uref;
  +  gboolean is_graphical=FALSE;
   
     if (verbose_mode) {
       printf("- Starting internal netlist creation\n");
  @@ -125,10 +133,15 @@
         /* look for special tag */
         temp = o_attrib_search_component(o_current, "graphical");
         if (temp) {
  -        /* don't want to traverse graphical elements */
  +        /* traverse graphical elements, but adding them to the
  +	   graphical netlist */
           free(temp);
   
  -      } else {
  +	netlist = s_netlist_return_tail(graphical_netlist_head);
  +	is_graphical = TRUE;
  +	
  +    
  +      }
           netlist = s_netlist_add(netlist);
           netlist->nlid = o_current->sid;
   
  @@ -173,7 +186,7 @@
                                    "net", 0);
   
             /* nope net attribute not found */
  -          if (!temp) {
  +	if ( (!temp) && (!is_graphical) ) {
   
               fprintf(stderr,
                       "Could not find refdes on component and could not find any special attributes!\n");
  @@ -208,7 +221,6 @@
             s_hierarchy_traverse(pr_current, o_current, netlist);
           }
         }
  -    }
   
       o_current = o_current->next;
     }