/* object being a pin */ char *s_net_return_connected_string(TOPLEVEL * pr_current, OBJECT * object, char *hierarchy_tag) { OBJECT *o_current; char *pinnum = NULL; char *uref = NULL; SCM scm_uref; char *temp_uref = NULL; char *string; char *misc; o_current = object; pinnum = o_attrib_search_object_attribs_by_name (o_current, "pinnumber", 0); #if DEBUG printf("found pinnum: %s\n", pinnum); #endif scm_uref = g_scm_c_get_uref(pr_current, o_current->parent); if (scm_is_string( scm_uref )) { temp_uref = scm_to_utf8_string (scm_uref); } /* apply the hierarchy name to the uref */ uref = s_hierarchy_create_uref(pr_current, temp_uref, hierarchy_tag); if (uref && pinnum) { string = g_strdup_printf("%s %s", uref, pinnum); } else { if (pinnum) { string = g_strdup_printf("POWER %s", pinnum); } else { if (hierarchy_tag) { misc = s_hierarchy_create_uref(pr_current, "U?", hierarchy_tag); string = g_strdup_printf("%s ?", misc); g_free(misc); } else { string = g_strdup("U? ?"); } fprintf(stderr, "Missing Attributes (refdes and pin number)\n"); } } g_free(pinnum); g_free(uref); g_free(temp_uref); return (string); }
int s_hierarchy_setup_rename(TOPLEVEL * pr_current, NETLIST * head, char *uref, char *label, char *new_name) { NETLIST *nl_current; CPINLIST *pl_current; char *wanted_uref = NULL; int did_work = FALSE; /* this is questionable, because I'm not sure if it's exactly the */ /* same as the #if 0'ed out line */ /* search for the uref which has the name: label/uref (or whatever the */ /* hierarchy tag/separator order is) */ wanted_uref = s_hierarchy_create_uref(pr_current, label, uref); #if DEBUG printf("label: %s, uref: %s, wanted_uref: %s\n", label, uref, wanted_uref); #endif nl_current = head; while (nl_current != NULL) { if (nl_current->component_uref) { pl_current = nl_current->cpins; if (strcmp(nl_current->component_uref, wanted_uref) == 0) { if (nl_current->cpins) { /* skip over head of special io symbol */ pl_current = nl_current->cpins->next;; #if DEBUG printf("net to be renamed: %s\n", pl_current->net_name); printf("%s -> %s\n", pl_current->net_name, new_name); #endif s_rename_add(pl_current->net_name, new_name); #if DEBUG printf("Going to remove %s\n", nl_current->component_uref); #endif s_hierarchy_remove_urefconn(head, nl_current-> component_uref); did_work = TRUE; } } } nl_current = nl_current->next; } return (did_work); }
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(); }