netlist_visualizer.c File Reference

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "types.h"
#include "globals.h"
#include "netlist_utils.h"
#include "odin_util.h"
Include dependency graph for netlist_visualizer.c:

Go to the source code of this file.

Functions

void depth_first_traverse_visualize (nnode_t *node, FILE *fp, int traverse_mark_number)
void depth_first_traversal_graph_display (FILE *out, short marker_value, netlist_t *netllist)
void forward_traversal_net_graph_display (FILE *out, short marker_value, nnode_t *node)
void backward_traversal_net_graph_display (FILE *out, short marker_value, nnode_t *node)
void graphVizOutputNetlist (char *path, char *name, short marker_value, netlist_t *netlist)
void graphVizOutputCombinationalNet (char *path, char *name, short marker_value, nnode_t *current_node)

Function Documentation

void backward_traversal_net_graph_display ( FILE *  out,
short  marker_value,
nnode_t node 
)

Definition at line 305 of file netlist_visualizer.c.

00306 {
00307         int j;
00308         char *temp_string;
00309         char *temp_string2;
00310         nnode_t** stack_of_nodes;
00311         int index_in_stack = 0;
00312         int num_stack_of_nodes = 1;
00313 
00314         stack_of_nodes = (nnode_t**)malloc(sizeof(nnode_t*)*1);
00315         stack_of_nodes[0] = node;
00316 
00317         while (index_in_stack != num_stack_of_nodes)
00318         {
00319                 nnode_t *current_node = stack_of_nodes[index_in_stack];
00320 
00321                 /* mark it */
00322                 current_node->traverse_visited = marker_value;
00323                 
00324                 /* printout the details of it */
00325                 temp_string = make_simple_name(current_node->name, "^-+.", '_');
00326                 if (index_in_stack != 0)
00327                 {
00328                         if ((current_node->type == FF_NODE) || (current_node->type == BUF_NODE))
00329                         {
00330                                 fprintf(fp, "\t%s [shape=box];\n", temp_string);
00331                         }
00332                         else if (current_node->type == INPUT_NODE)
00333                         {
00334                                 fprintf(fp, "\t%s [shape=triangle];\n", temp_string);
00335                         }
00336                         else if (current_node->type == CLOCK_NODE)
00337                         {
00338                                 fprintf(fp, "\t%s [shape=triangle];\n", temp_string);
00339                         }
00340                         else if (current_node->type == OUTPUT_NODE)
00341                         {
00342                                 fprintf(fp, "\t%s_O [shape=triangle];\n", temp_string);
00343                         }
00344                         else
00345                         {
00346                                 fprintf(fp, "\t%s [label=\"%d:%d\"];\n", temp_string, current_node->forward_level, current_node->backward_level);
00347                         }
00348                 }
00349                 free(temp_string);
00350 
00351                 /* at each node visit all the outputs */
00352                 for (j = 0; j < current_node->num_input_pins; j++)
00353                 {
00354                         if (current_node->input_pins[j] == NULL)
00355                                 continue; 
00356 
00357                         if ((current_node->input_pins[j] == NULL) || (current_node->input_pins[j]->net == NULL) || (current_node->input_pins[j]->net->driver_pin == NULL))
00358                                 continue;
00359 
00360                         /* visit the fanout point */
00361                         nnode_t *next_node = current_node->input_pins[j]->net->driver_pin->node;
00362 
00363                         if (next_node == NULL)
00364                                 continue;
00365 
00366                         temp_string = make_simple_name(current_node->name, "^-+.", '_');
00367                         temp_string2 = make_simple_name(next_node->name, "^-+.", '_');
00368 
00369                         fprintf(fp, "\t%s -> %s [label=\"%s\"];\n", temp_string2, temp_string, current_node->input_pins[j]->name);
00370 
00371                         free(temp_string);
00372                         free(temp_string2);
00373 
00374                         if ((next_node->traverse_visited != marker_value) && (next_node->type != FF_NODE))
00375                         {
00376                                 /* IF - not visited yet then add to list */
00377                                 stack_of_nodes = (nnode_t**)realloc(stack_of_nodes, sizeof(nnode_t*)*(num_stack_of_nodes+1));
00378                                 stack_of_nodes[num_stack_of_nodes] = next_node;
00379                                 num_stack_of_nodes ++;
00380                         }
00381                 }
00382 
00383                 /* process next element in net */
00384                 index_in_stack ++;
00385         }
00386 }

Here is the call graph for this function:

Here is the caller graph for this function:

void depth_first_traversal_graph_display ( FILE *  out,
short  marker_value,
netlist_t netllist 
)

Definition at line 64 of file netlist_visualizer.c.

00065 {
00066         int i;
00067 
00068         /* start with the primary input list */
00069         for (i = 0; i < netlist->num_top_input_nodes; i++)
00070         {
00071                 if (netlist->top_input_nodes[i] != NULL)
00072                 {
00073                         depth_first_traverse_visualize(netlist->top_input_nodes[i], out, marker_value);
00074                 }
00075         }
00076         /* now traverse the ground and vcc pins */
00077         if (netlist->gnd_node != NULL)
00078                 depth_first_traverse_visualize(netlist->gnd_node, out, marker_value);
00079         if (netlist->vcc_node != NULL)
00080                 depth_first_traverse_visualize(netlist->vcc_node, out, marker_value);
00081 }

Here is the call graph for this function:

Here is the caller graph for this function:

void depth_first_traverse_visualize ( nnode_t node,
FILE *  fp,
int  traverse_mark_number 
)

Definition at line 86 of file netlist_visualizer.c.

00087 {
00088         int i, j;
00089         nnode_t *next_node;
00090         nnet_t *next_net;
00091 
00092         if (node->traverse_visited == traverse_mark_number)
00093         {
00094                 return;
00095         }
00096         else
00097         {
00098                 /* ELSE - this is a new node so depth visit it */
00099                 char *temp_string;
00100                 char *temp_string2;
00101 
00102                 /* mark that we have visitied this node now */
00103                 node->traverse_visited = traverse_mark_number;
00104                 
00105                 temp_string = make_simple_name(node->name, "^-+.", '_');
00106                 if ((node->type == FF_NODE) || (node->type == BUF_NODE))
00107                 {
00108                         fprintf(fp, "\t\"%s\" [shape=box];\n", temp_string);
00109                 }
00110                 else if (node->type == INPUT_NODE)
00111                 {
00112                         fprintf(fp, "\t\"%s\" [shape=triangle];\n", temp_string);
00113                 }
00114                 else if (node->type == CLOCK_NODE)
00115                 {
00116                         fprintf(fp, "\t\"%s\" [shape=triangle];\n", temp_string);
00117                 }
00118                 else if (node->type == OUTPUT_NODE)
00119                 {
00120                         fprintf(fp, "\t\"%s_O\" [shape=triangle];\n", temp_string);
00121                 }
00122                 else
00123                 {
00124                         fprintf(fp, "\t\"%s\"\n", temp_string);
00125                 }
00126                 free(temp_string);
00127 
00128                 for (i = 0; i < node->num_output_pins; i++)
00129                 {
00130                         if (node->output_pins[i]->net == NULL)
00131                                 continue;
00132 
00133 
00134                         next_net = node->output_pins[i]->net;
00135                         for (j = 0; j < next_net->num_fanout_pins; j++)
00136                         {
00137                                 next_node = next_net->fanout_pins[j]->node;
00138                                 if (next_node == NULL)
00139                                         continue;
00140 // To see just combinational stuff...also comment above triangels and box
00141 //                              if ((next_node->type == FF_NODE) || (next_node->type == INPUT_NODE) || (next_node->type == OUTPUT_NODE))
00142 //                                      continue;
00143 //                              if ((node->type == FF_NODE) || (node->type == INPUT_NODE) || (node->type == OUTPUT_NODE))
00144 //                                      continue;
00145 
00146                                 temp_string = make_simple_name(node->name, "^-+.", '_');
00147                                 temp_string2 = make_simple_name(next_node->name, "^-+.", '_');
00148                                 /* renaming for output nodes */
00149                                 if (node->type == OUTPUT_NODE)
00150                                 {
00151                                         /* renaming for output nodes */
00152                                         temp_string = (char*)realloc(temp_string, sizeof(char)*strlen(temp_string)+1+2);
00153                                         sprintf(temp_string, "%s_O", temp_string);
00154                                 }
00155                                 if (next_node->type == OUTPUT_NODE)
00156                                 {
00157                                         /* renaming for output nodes */
00158                                         temp_string2 = (char*)realloc(temp_string2, sizeof(char)*strlen(temp_string2)+1+2);
00159                                         sprintf(temp_string2, "%s_O", temp_string2);
00160                                 }
00161 
00162                                 fprintf(fp, "\t\"%s\" -> \"%s\"", temp_string, temp_string2); 
00163                                 if (next_net->fanout_pins[j]->name)
00164                                         fprintf(fp, "[label=\"%s\"]", next_net->fanout_pins[j]->name);
00165                                 fprintf(fp, ";\n");
00166 
00167                                 free(temp_string);
00168                                 free(temp_string2);
00169 
00170                                 /* recursive call point */
00171                                 depth_first_traverse_visualize(next_node, fp, traverse_mark_number);
00172                         }
00173                 }
00174         }
00175 }

Here is the call graph for this function:

Here is the caller graph for this function:

void forward_traversal_net_graph_display ( FILE *  out,
short  marker_value,
nnode_t node 
)

Definition at line 203 of file netlist_visualizer.c.

00204 {
00205         int j, k;
00206         nnode_t** stack_of_nodes;
00207         int index_in_stack = 0;
00208         int num_stack_of_nodes = 1;
00209         char *temp_string;
00210         char *temp_string2;
00211 
00212         stack_of_nodes = (nnode_t**)malloc(sizeof(nnode_t*)*1);
00213         stack_of_nodes[0] = node;
00214 
00215         while (index_in_stack != num_stack_of_nodes)
00216         {
00217                 nnode_t *current_node = stack_of_nodes[index_in_stack];
00218 
00219                 /* mark it */
00220                 current_node->traverse_visited = marker_value;
00221                 
00222                 /* printout the details of it */
00223                 temp_string = make_simple_name(current_node->name, "^-+.", '_');
00224                 if (index_in_stack == 0)
00225                 {
00226                         fprintf(fp, "\t%s [shape=box,color=red];\n", temp_string);
00227                 }
00228                 else if ((current_node->type == FF_NODE) || (current_node->type == BUF_NODE))
00229                 {
00230                         fprintf(fp, "\t%s [shape=box];\n", temp_string);
00231                 }
00232                 else if (current_node->type == INPUT_NODE)
00233                 {
00234                         fprintf(fp, "\t%s [shape=triangle];\n", temp_string);
00235                 }
00236                 else if (current_node->type == CLOCK_NODE)
00237                 {
00238                         fprintf(fp, "\t%s [shape=triangle];\n", temp_string);
00239                 }
00240                 else if (current_node->type == OUTPUT_NODE)
00241                 {
00242                         fprintf(fp, "\t%s_O [shape=triangle];\n", temp_string);
00243                 }
00244                 else
00245                 {
00246                         fprintf(fp, "\t%s [label=\"%d:%d\"];\n", temp_string, current_node->forward_level, current_node->backward_level);
00247                 }
00248                 free(temp_string);
00249 
00250                 /* at each node visit all the outputs */
00251                 for (j = 0; j < current_node->num_output_pins; j++)
00252                 {
00253                         if (current_node->output_pins[j] == NULL)
00254                                 continue; 
00255 
00256                         for (k = 0; k < current_node->output_pins[j]->net->num_fanout_pins; k++)
00257                         {
00258                                 if ((current_node->output_pins[j] == NULL) || (current_node->output_pins[j]->net == NULL) || ( current_node->output_pins[j]->net->fanout_pins[k] == NULL))
00259                                         continue;
00260 
00261                                 /* visit the fanout point */
00262                                 nnode_t *next_node = current_node->output_pins[j]->net->fanout_pins[k]->node;
00263 
00264                                 if (next_node == NULL)
00265                                         continue;
00266 
00267                                 temp_string = make_simple_name(current_node->name, "^-+.", '_');
00268                                 temp_string2 = make_simple_name(next_node->name, "^-+.", '_');
00269                                 if (current_node->type == OUTPUT_NODE)
00270                                 {
00271                                         /* renaming for output nodes */
00272                                         temp_string = (char*)realloc(temp_string, sizeof(char)*strlen(temp_string)+1+2);
00273                                         sprintf(temp_string, "%s_O", temp_string);
00274                                 }
00275                                 if (next_node->type == OUTPUT_NODE)
00276                                 {
00277                                         /* renaming for output nodes */
00278                                         temp_string2 = (char*)realloc(temp_string2, sizeof(char)*strlen(temp_string2)+1+2);
00279                                         sprintf(temp_string2, "%s_O", temp_string2);
00280                                 }
00281 
00282                                 fprintf(fp, "\t%s -> %s [label=\"%s\"];\n", temp_string, temp_string2, current_node->output_pins[j]->net->fanout_pins[k]->name);
00283 
00284                                 free(temp_string);
00285                                 free(temp_string2);
00286 
00287                                 if ((next_node->traverse_visited != marker_value) && (next_node->type != FF_NODE))
00288                                 {
00289                                         /* IF - not visited yet then add to list */
00290                                         stack_of_nodes = (nnode_t**)realloc(stack_of_nodes, sizeof(nnode_t*)*(num_stack_of_nodes+1));
00291                                         stack_of_nodes[num_stack_of_nodes] = next_node;
00292                                         num_stack_of_nodes ++;
00293                                 }
00294                         }
00295                 }
00296 
00297                 /* process next element in net */
00298                 index_in_stack ++;
00299         }
00300 }

Here is the call graph for this function:

Here is the caller graph for this function:

void graphVizOutputCombinationalNet ( char *  path,
char *  name,
short  marker_value,
nnode_t current_node 
)

Definition at line 180 of file netlist_visualizer.c.

00181 {
00182         char path_and_file[4096];
00183         FILE *fp;
00184 
00185         /* open the file */
00186         sprintf(path_and_file, "%s/%s.dot", path, name);
00187         fp = fopen(path_and_file, "w");
00188 
00189         /* open graph */
00190         fprintf(fp, "digraph G {\n\tranksep=.25;\n");
00191         
00192         forward_traversal_net_graph_display(fp, marker_value, current_node);
00193         backward_traversal_net_graph_display(fp, marker_value, current_node);
00194 
00195         /* close graph */
00196         fprintf(fp, "}\n");
00197         fclose(fp);
00198 }

Here is the call graph for this function:

Here is the caller graph for this function:

void graphVizOutputNetlist ( char *  path,
char *  name,
short  marker_value,
netlist_t netlist 
)

Definition at line 42 of file netlist_visualizer.c.

00043 {
00044         char path_and_file[4096];
00045         FILE *fp;
00046 
00047         /* open the file */
00048         sprintf(path_and_file, "%s/%s.dot", path, name);
00049         fp = fopen(path_and_file, "w");
00050 
00051         /* open graph */
00052         fprintf(fp, "digraph G {\n\tranksep=.25;\n");
00053         
00054         depth_first_traversal_graph_display(fp, marker_value, netlist);
00055 
00056         /* close graph */
00057         fprintf(fp, "}\n");
00058         fclose(fp);
00059 }

Here is the call graph for this function:

Here is the caller graph for this function:

Generated on Tue Aug 2 10:43:33 2011 for ODIN_II by  doxygen 1.6.3