예제 #1
0
void
s_netlist_post_process (NETLIST *head, SCM netlist_mode)
{
  NETLIST *nl_current;
  CPINLIST *pl_current;

  if (verbose_mode) {
    printf("\n- Staring post processing\n");
    printf("- Naming nets:\n");
  }

  /* this pass gives all nets a name, whether specified or creates a */
  /* name */
  nl_current = head;
  while (nl_current != NULL) {
    if (nl_current->cpins) {
	    pl_current = nl_current->cpins;
	    while (pl_current != NULL) {

        verbose_print("p");

        if (pl_current->nets) {

          g_free(pl_current->net_name);

          verbose_print("n");

          pl_current->net_name =
            s_net_name (head,
                        pl_current->nets,
                        nl_current->hierarchy_tag,
                        PIN_TYPE_NET,
                        netlist_mode);

          /* put this name also in the first
             node of the nets linked list */
          if (pl_current->net_name && pl_current->nets) {
            if (pl_current->nets->next) {
              pl_current->nets->next->net_name =
                g_strdup (pl_current->net_name);
            }
          }
        }

        pl_current = pl_current->next;
	    }
    }
    nl_current = nl_current->next;
  }

  verbose_done();

  if (verbose_mode) {
    printf("- Resolving hierarchy:\n");
  }
  s_hierarchy_post_process (head);

  verbose_done();
}
예제 #2
0
파일: s_table.c 프로젝트: eivindkv/geda-gaf
/*! \brief Add pins to pin table.
 *
 * This function iterates over adds all items found on this page
 * looking for pins.  WHen it finds a pin, it gathers all
 * pin attribs and sticks them into the pin table. 
 * \param obj_list List of objects on page
 */
void s_table_add_toplevel_pin_items_to_pin_table (const GList *obj_list) {
  gchar *temp_uref;
  gchar *pinnumber;
  gchar *row_label;
  int row, col;
  gchar *attrib_text;
  gchar *attrib_name;
  gchar *attrib_value;
  const GList *o_iter;
  GList *a_iter;
  GList *o_lower_iter;
  OBJECT *pin_attrib;

  if (verbose_mode) {
    printf("- Starting internal pin TABLE creation\n");
  }

#ifdef DEBUG
  printf("=========== Just entered  s_table_add_toplevel_pin_items_to_pin_table!  ==============\n");
#endif

  /* -----  Iterate through all objects found on page  ----- */
  for (o_iter = obj_list; o_iter != NULL; o_iter = g_list_next (o_iter)) {
    OBJECT *o_current = o_iter->data;

#ifdef DEBUG
      printf("   ---> In s_table_add_toplevel_pin_items_to_pin_table, examining o_current->name = %s\n", o_current->name);
#endif

    /* -----  Now process objects found on page  ----- */
    if (o_current->type == OBJ_COMPLEX &&
        o_current->attribs != NULL) {

      /* ---- Don't process part if it lacks a refdes ----- */
      temp_uref = s_attrib_get_refdes(o_current);
      if (temp_uref) {

	/* -----  Now iterate through lower level objects looking for pins.  ----- */
        for (o_lower_iter = o_current->complex->prim_objs;
             o_lower_iter != NULL;
             o_lower_iter = g_list_next (o_lower_iter)) {
          OBJECT *o_lower_current = o_lower_iter->data;

	  if (o_lower_current->type == OBJ_PIN) {
	    /* -----  Found a pin.  First get its pinnumber.  then get attrib head and loop on attribs.  ----- */
	    pinnumber = o_attrib_search_object_attribs_by_name (o_lower_current, "pinnumber", 0);
	    row_label = g_strconcat(temp_uref, ":", pinnumber, NULL);

#if DEBUG
        printf("      In s_table_add_toplevel_pin_items_to_pin_table, examining pin %s\n", row_label);
#endif

	    a_iter = o_lower_current->attribs;
	    while (a_iter != NULL) {
	      pin_attrib = a_iter->data;
	      if (pin_attrib->type == OBJ_TEXT
		  && pin_attrib->text != NULL) {  /* found an attribute */
		attrib_text = g_strdup(pin_attrib->text->string);
		attrib_name = u_basic_breakup_string(attrib_text, '=', 0);
		attrib_value = s_misc_remaining_string(attrib_text, '=', 1);
 
		if ( (strcmp(attrib_name, "pinnumber") != 0) 
		     && (attrib_value != 0) ) {
		  /* Don't include "pinnumber" because it is already in other master list.
		   * Also must ensure that value is non-null; certain symbols are not well formed.
		   */

		  /* Get row and col where to put this attrib */
		  row = s_table_get_index(sheet_head->master_pin_list_head, row_label);
		  col = s_table_get_index(sheet_head->master_pin_attrib_list_head, attrib_name);
                  /* Sanity check */
                  if (row == -1 || col == -1) {
                    /* we didn't find the item in the table */
                    fprintf (stderr,
                             "In s_table_add_toplevel_pin_items_to_pin_table, we didn't find either row or col in the lists!\n");
                  } else {

#if DEBUG
                    printf("       In s_table_add_toplevel_pin_items_to_pin_table, about to add row %d, col %d, attrib_value = %s\n",
                           row, col, attrib_value);
                    printf(" . . . current address of attrib_value cell is [%p]\n", &((sheet_head->component_table)[row][col]).attrib_value);
#endif
                    /* Is there a compelling reason for me to put this into a separate fcn? */
                    ((sheet_head->pin_table)[row][col]).row = row;
                    ((sheet_head->pin_table)[row][col]).col = col;
                    ((sheet_head->pin_table)[row][col]).row_name = g_strdup(row_label);
                    ((sheet_head->pin_table)[row][col]).col_name = g_strdup(attrib_name);
                    ((sheet_head->pin_table)[row][col]).attrib_value = g_strdup(attrib_value);
                  }
                }
		g_free(attrib_name);
		g_free(attrib_text);
		g_free(attrib_value);
	      }
	      a_iter = g_list_next (a_iter);
           
	    }  /* while (pin_attrib != NULL) */
	    g_free(pinnumber);
	    g_free(row_label);
	  }

        }
      }

      g_free(temp_uref);
    }

  }
 
  verbose_done();
}
예제 #3
0
파일: s_table.c 프로젝트: eivindkv/geda-gaf
/*! \brief Add components to the component table
 *
 * This fcn iterates over adds all
 * objects found on this page looking
 * for components.  When it finds a component, it finds all component
 * attribs and sticks them in the TABLE.
 * \param obj_list pointer to GList containing objects on this page
 */
void s_table_add_toplevel_comp_items_to_comp_table (const GList *obj_list) {
  gchar *temp_uref;
  int row, col;
  gchar *attrib_text;
  gchar *attrib_name;
  gchar *attrib_value;
  const GList *o_iter;
  GList *a_iter;
  OBJECT *a_current;
  gint old_visibility, old_show_name_value;


  if (verbose_mode) {
    printf("- Starting internal component TABLE creation\n");
  }

#ifdef DEBUG
  fflush(stderr);
  fflush(stdout);
  printf("=========== Just entered  s_table_add_toplevel_comp_items_to_comp_table!  ==============\n");
#endif

  /* -----  Iterate through all objects found on page  ----- */
  for (o_iter = obj_list; o_iter != NULL; o_iter = g_list_next (o_iter)) {
    OBJECT *o_current = o_iter->data;

#ifdef DEBUG
      printf("   ---> In s_table_add_toplevel_comp_items_to_comp_table, examining o_current->name = %s\n", o_current->name);
#endif

    /* -----  Now process objects found on page  ----- */
    if (o_current->type == OBJ_COMPLEX &&
        o_current->attribs != NULL) {

      /* ---- Don't process part if it lacks a refdes ----- */
      temp_uref = g_strdup(s_attrib_get_refdes(o_current));
      if (temp_uref) {

#if DEBUG
        printf("      In s_table_add_toplevel_comp_items_to_comp_table, found component on page. Refdes = %s\n", temp_uref);
#endif
        verbose_print(" C");

        /* Having found a component, we loop over all attribs in this
         * component, and stick them
         * into cells in the table. */
        a_iter = o_current->attribs;
        while (a_iter != NULL) {
          a_current = a_iter->data;
          if (a_current->type == OBJ_TEXT
              && a_current->text != NULL) {  /* found an attribute */
            /* may need to check more thoroughly here. . . . */
            attrib_text = g_strdup(a_current->text->string);
            attrib_name = u_basic_breakup_string(attrib_text, '=', 0);
            attrib_value = s_misc_remaining_string(attrib_text, '=', 1);
            old_visibility = o_is_visible (pr_current, a_current)
              ? VISIBLE : INVISIBLE;
	    old_show_name_value = a_current->show_name_value;

	    /* Don't include "refdes" or "slot" because they form the row name. */
	    /* Also don't include "net" per bug found by Steve W.  4.3.2007 -- SDB */
            if ( (strcmp(attrib_name, "refdes") != 0) &&
		 (strcmp(attrib_name, "net") != 0) &&
		 (strcmp(attrib_name, "slot") != 0) ) {
               
              /* Get row and col where to put this attrib */
              row = s_table_get_index(sheet_head->master_comp_list_head, temp_uref);
              col = s_table_get_index(sheet_head->master_comp_attrib_list_head, attrib_name);
              /* Sanity check */
              if (row == -1 || col == -1) {
                /* we didn't find the item in the table */
                fprintf (stderr,
                         "In s_table_add_toplevel_comp_items_to_comp_table, we didn't find either row or col in the lists!\n");
              } else {

#if DEBUG
                printf("       In s_table_add_toplevel_comp_items_to_comp_table, about to add row %d, col %d, attrib_value = %s\n",
                       row, col, attrib_value);
                printf(" . . . current address of attrib_value cell is [%p]\n", &((sheet_head->component_table)[row][col]).attrib_value);
#endif
                /* Is there a compelling reason for me to put this into a separate fcn? */
                ((sheet_head->component_table)[row][col]).row = row;
                ((sheet_head->component_table)[row][col]).col = col;
                ((sheet_head->component_table)[row][col]).row_name = g_strdup(temp_uref);
                ((sheet_head->component_table)[row][col]).col_name = g_strdup(attrib_name);
                ((sheet_head->component_table)[row][col]).attrib_value = g_strdup(attrib_value);
                ((sheet_head->component_table)[row][col]).visibility = old_visibility;
                ((sheet_head->component_table)[row][col]).show_name_value = old_show_name_value;
              }
            }
            g_free(attrib_name);
            g_free(attrib_text);
            g_free(attrib_value);
          }
          a_iter = g_list_next (a_iter);
           
        }  /* while (a_current != NULL) */
        g_free(temp_uref);
      }  /* if (temp_uref) */
    }    /* if (o_current->type == OBJ_COMPLEX)  */
  }
 
  verbose_done();
 
}
예제 #4
0
파일: s_table.c 프로젝트: eivindkv/geda-gaf
/*! \brief Add nets to net table
 *
 * This function iterates over adds all
 * items found on this page looking
 * for nets and adds them individually to the net table.  Looping over
 * objects occurs here.
 *
 * \param start_obj Pointer to first object
 *
 * \todo Why do the calling semantics of this function disagree with
 *       s_table_add_toplevel_pin_items_to_pin_table()?  That function
 *       takes a GList, this one takes a pointer to OBJECT.
 */
void s_table_add_toplevel_net_items_to_net_table(OBJECT *start_obj) {
  OBJECT *o_current;
  char *temp_netname;
  int row, col;
  char *attrib_text;
  char *attrib_name;
  char *attrib_value;
  ATTRIB *a_current;
 
  /* -----  Iterate through all objects found on page  ----- */
  o_current = start_obj;
  while (o_current != NULL) {
 
    /* -----  Now process objects found on page  ----- */
    if (o_current->type == OBJ_NET) {
#if DEBUG
      fflush(stderr);
      fflush(stdout);
      printf("In s_table_add_toplevel_net_items_to_net_table, Found net on page\n");
#endif
      verbose_print(" N");
 
      /* Having found a net, we stick it into the table. */
      a_current = o_current->attribs;
      while (a_current != NULL) {
        if (a_current->object->type == OBJ_TEXT
            && a_current->object->text != NULL) {  /* found an attribute */
          /* may need to check more thoroughly here. . . . */
          attrib_text = g_strdup(a_current->object->text->string);
          attrib_name = u_basic_breakup_string(attrib_text, '=', 0);
          attrib_value = s_misc_remaining_string(attrib_text, '=', 1);
          if (strcmp(attrib_name, "netname") != 0) {
            /* Don't include "netname" */
             
            /* Get row and col where to put this attrib */
            row = s_table_get_index(sheet_head->master_net_list_head, temp_netname);
            col = s_table_get_index(sheet_head->master_net_attrib_list_head, attrib_name);
#if DEBUG
            fflush(stderr);
            fflush(stdout);
            printf("In s_table_add_toplevel_net_items_to_net_table, about to add row %d, col %d, attrib_value = %s\n",
                   row, col, attrib_value);
            printf(" . . . current address of attrib_value cell is [%p]\n", &((sheet_head->net_table)[row][col]).attrib_value);
#endif
            /* Is there a compelling reason for me to put this into a separate fcn? */
            ((sheet_head->net_table)[row][col]).row = row;
            ((sheet_head->net_table)[row][col]).col = col;
            ((sheet_head->net_table)[row][col]).row_name = g_strdup(temp_netname);
            ((sheet_head->net_table)[row][col]).col_name = g_strdup(attrib_name);
            ((sheet_head->net_table)[row][col]).attrib_value = g_strdup(attrib_value);
          }
          g_free(attrib_name);
          g_free(attrib_text);
          g_free(attrib_value);
        }
        a_current = a_current->next;
 
      }  /* while (a_current != NULL) */
      g_free(temp_netname);
 
    }    /*--- if (o_current->type == OBJ_NET)   ---*/
       
 
    o_current = o_current->next;  /* iterate to next object on page */
  }  /* while o_current != NULL */
 
  verbose_done();
 
#if DEBUG
  fflush(stderr);
  fflush(stdout);
  printf("In s_table_add_toplevel_net_items_to_net_table -- we are about to return\n");
#endif
 
}
예제 #5
0
파일: s_traverse.c 프로젝트: vzh/geda-gaf
void
s_traverse_sheet (TOPLEVEL * pr_current, const GList *obj_list, char *hierarchy_tag)
{
  NETLIST *netlist;
  char *temp;
  SCM scm_uref;
  char *temp_uref;
  gboolean is_hierarchy = TRUE;
  const GList *iter;
  GError *err = NULL;
  EdaConfig *cfg;

  cfg = eda_config_get_context_for_file (NULL);
  is_hierarchy = eda_config_get_boolean (cfg, "gnetlist", "traverse-hierarchy", &err);
  if (err != NULL) {
    is_hierarchy = TRUE;
    g_clear_error (&err);
  }

  if (verbose_mode) {
    printf("- Starting internal netlist creation\n");
  }

  for (iter = obj_list; iter != NULL; iter = g_list_next (iter)) {
    OBJECT *o_current = iter->data;

    netlist = s_netlist_return_tail(netlist_head);

    if (o_current->type == OBJ_PLACEHOLDER) {
      printf(_("WARNING: Found a placeholder/missing component, are you missing a symbol file? [%s]\n"), o_current->complex_basename);
    }

    if (o_current->type == OBJ_COMPLEX) {
      gboolean is_graphical = FALSE;

#if DEBUG
      printf("starting NEW component\n\n");
#endif

      verbose_print(" C");

      /* look for special tag */
      temp = o_attrib_search_object_attribs_by_name (o_current, "graphical", 0);
      if (g_strcmp0 (temp, "1") == 0) {
        /* traverse graphical elements, but adding them to the
	   graphical netlist */
	
	netlist = s_netlist_return_tail(graphical_netlist_head);
	is_graphical = TRUE;
	
    
      }
      g_free (temp);
      netlist = s_netlist_add(netlist);
      netlist->nlid = o_current->sid;

      scm_uref = g_scm_c_get_uref(pr_current, o_current);

      if (scm_is_string( scm_uref )) {
        temp_uref = scm_to_utf8_string (scm_uref);
        netlist->component_uref =
          s_hierarchy_create_uref(pr_current, temp_uref, hierarchy_tag);
        g_free(temp_uref);
      } else {
        if (hierarchy_tag) {
          netlist->component_uref = g_strdup (hierarchy_tag);
        } else {
          netlist->component_uref = NULL;
        }
      }
      
      if (hierarchy_tag) {
	netlist->hierarchy_tag = g_strdup (hierarchy_tag);
      }

      netlist->object_ptr = o_current;
      
      if (!netlist->component_uref) {
	
	/* search of net attribute */
	/* maybe symbol is not a component */
	/* but a power / gnd symbol */
	temp = o_attrib_search_object_attribs_by_name (o_current, "net", 0);
	
	/* nope net attribute not found */
	if ( (!temp) && (!is_graphical) ) {
	  
	  fprintf(stderr,
		  _("Could not find refdes on component and could not find any special attributes!\n"));
	  
	  netlist->component_uref = g_strdup("U?");
	} else {
	  
#if DEBUG
	  printf("yeah... found a power symbol\n");
#endif
	  /* it's a power or some other special symbol */
	  netlist->component_uref = NULL;
	  g_free(temp);
	}
	
      }

      netlist->cpins =
	s_traverse_component(pr_current, o_current,
			     hierarchy_tag);
      
      /* here is where you deal with the */
      /* net attribute */
      s_netattrib_handle(pr_current, o_current, netlist,
			 hierarchy_tag);
      
      /* now you need to traverse any underlying schematics */
      if (is_hierarchy) {
	s_hierarchy_traverse(pr_current, o_current, netlist);
      }
    }
  }

  verbose_done();
}