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); }
char *s_net_name_search(TOPLEVEL * pr_current, NET * net_head) { NET *n_current; char *name = NULL; n_current = net_head; while (n_current != NULL) { if (n_current->net_name) { if (name == NULL) { name = n_current->net_name; } else if (strcmp(name, n_current->net_name) != 0) { #if DEBUG fprintf(stderr, "Found a net with two names!\n"); fprintf(stderr, "Net called: [%s] and [%s]\n", name, n_current->net_name); #endif /* only rename if this net name has priority */ /* AND, you are using net= attributes as the */ /* netnames which have priority */ if (pr_current->net_naming_priority == NETATTRIB_ATTRIBUTE) { #if DEBUG printf("\nNETATTRIB_ATTRIBUTE\n"); #endif if (n_current->net_name_has_priority) { #if DEBUG fprintf(stderr, "Net is now called: [%s]\n", n_current->net_name); /* this show how to rename nets */ printf("\nRENAME all nets: %s -> %s\n", name, n_current->net_name); #endif s_rename_add(name, n_current->net_name); name = n_current->net_name; } else { #if DEBUG printf ("\nFound a net name called [%s], but it doesn't have priority\n", n_current->net_name); #endif /* do the rename anyways, this might cause problems */ /* this will rename net which have the same label= */ if (!s_rename_search (name, n_current->net_name, TRUE)) { fprintf(stderr, "Found duplicate net name, renaming [%s] to [%s]\n", name, n_current->net_name); s_rename_add(name, n_current->net_name); name = n_current->net_name; } } } else { /* NETNAME_ATTRIBUTE */ #if DEBUG printf("\nNETNAME_ATTRIBUTE\n"); #endif /* here we want to rename the net */ /* that has priority to the label */ /* name */ if (n_current->net_name_has_priority) { #if DEBUG /* this shows how to rename nets */ printf("\nRENAME all nets: %s -> %s (priority)\n", n_current->net_name, name); #endif s_rename_add(n_current->net_name, name); } else { #if DEBUG /* this shows how to rename nets */ printf ("\nRENAME all nets: %s -> %s (not priority)\n", name, n_current->net_name); #endif /* do the rename anyways, this might cause problems */ /* this will rename net which have the same label= */ if (!s_rename_search (name, n_current->net_name, TRUE)) { fprintf(stderr, "Found duplicate net name, renaming [%s] to [%s]\n", name, n_current->net_name); s_rename_add(name, n_current->net_name); name = n_current->net_name; } } #if DEBUG fprintf(stderr, "Net is now called: [%s]\n", name); #endif } } } n_current = n_current->next; } if (name) { return (name); } else { return (NULL); } }