00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <string.h>
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include "types.h"
00029 #include "globals.h"
00030 #include "netlist_utils.h"
00031 #include "odin_util.h"
00032
00033 void depth_first_traverse_graphcrunch(FILE *out, short marker_value, netlist_t *netlist);
00034 void depth_first_traversal_graphcrunch_display(nnode_t *node, FILE *fp, int traverse_mark_number);
00035
00036
00037
00038
00039 void graphcrunch_output(char* path, char* name, short marker_value, netlist_t *netlist)
00040 {
00041 char path_and_file[4096];
00042 FILE *fp;
00043
00044
00045 sprintf(path_and_file, "%s/%s", path, name);
00046 fp = fopen(path_and_file, "w");
00047
00048 depth_first_traverse_graphcrunch(fp, marker_value, netlist);
00049
00050
00051 fclose(fp);
00052 }
00053
00054
00055
00056
00057 void depth_first_traverse_graphcrunch(FILE *out, short marker_value, netlist_t *netlist)
00058 {
00059 int i;
00060
00061
00062 for (i = 0; i < netlist->num_top_input_nodes; i++)
00063 {
00064 if (netlist->top_input_nodes[i] != NULL)
00065 {
00066 depth_first_traversal_graphcrunch_display(netlist->top_input_nodes[i], out, marker_value);
00067 }
00068 }
00069
00070 if (netlist->gnd_node != NULL)
00071 depth_first_traversal_graphcrunch_display(netlist->gnd_node, out, marker_value);
00072 if (netlist->vcc_node != NULL)
00073 depth_first_traversal_graphcrunch_display(netlist->vcc_node, out, marker_value);
00074 }
00075
00076
00077
00078
00079 void depth_first_traversal_graphcrunch_display(nnode_t *node, FILE *fp, int traverse_mark_number)
00080 {
00081 int i, j;
00082 nnode_t *next_node;
00083 nnet_t *next_net;
00084
00085 if (node->traverse_visited == traverse_mark_number)
00086 {
00087 return;
00088 }
00089 else
00090 {
00091
00092 char *temp_string;
00093 char *temp_string2;
00094
00095
00096 node->traverse_visited = traverse_mark_number;
00097
00098 for (i = 0; i < node->num_output_pins; i++)
00099 {
00100 if (node->output_pins[i]->net == NULL)
00101 continue;
00102
00103 next_net = node->output_pins[i]->net;
00104 for (j = 0; j < next_net->num_fanout_pins; j++)
00105 {
00106 if (next_net->fanout_pins[j] == NULL)
00107 continue;
00108
00109 next_node = next_net->fanout_pins[j]->node;
00110 if (next_node == NULL)
00111 continue;
00112
00113
00114
00115 temp_string = make_simple_name(node->name, "^-+.", '_');
00116 temp_string2 = make_simple_name(next_node->name, "^-+.", '_');
00117
00118 if (node->type == OUTPUT_NODE)
00119 {
00120
00121 temp_string = (char*)realloc(temp_string, sizeof(char)*strlen(temp_string)+1+2);
00122 sprintf(temp_string, "%s_O", temp_string);
00123 }
00124 if (next_node->type == OUTPUT_NODE)
00125 {
00126
00127 temp_string2 = (char*)realloc(temp_string2, sizeof(char)*strlen(temp_string2)+1+2);
00128 sprintf(temp_string2, "%s_O", temp_string2);
00129 }
00130
00131 fprintf(fp, "%s\t%s\n", temp_string, temp_string2);
00132
00133 free(temp_string);
00134 free(temp_string2);
00135
00136
00137 depth_first_traversal_graphcrunch_display(next_node, fp, traverse_mark_number);
00138 }
00139 }
00140 }
00141 }