SRC/mst.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  s_mst_edge

Typedefs

typedef struct s_mst_edge t_mst_edge

Functions

t_mst_edgeget_mst_of_net (int inet)

Typedef Documentation

typedef struct s_mst_edge t_mst_edge

Function Documentation

t_mst_edge* get_mst_of_net ( int  inet  ) 

Definition at line 15 of file mst.c.

00016 {
00017     int i, ipin, node_dist, node_in_mst, num_pins_on_net, num_edges;
00018     int nearest_node, nearest_node_dist, nearest_node_in_mst;
00019     t_mst_edge *min_spantree;
00020     boolean *in_mst;
00021 
00022 /* given the net number, find and return its minimum spanning tree */
00023 
00024     num_pins_on_net = (net[inet].num_sinks + 1);
00025     if(num_pins_on_net > USHRT_MAX)
00026         {
00027             printf("Error: num_pins_on_net (%d) > USHRT_MAX(%u)\n",
00028                    num_pins_on_net, USHRT_MAX);
00029             exit(1);
00030         }
00031 
00032     /* minimum spanning tree represented by a set of edges */
00033     min_spantree =
00034         (t_mst_edge *) my_malloc(sizeof(t_mst_edge) * (num_pins_on_net - 1));
00035     in_mst = (boolean *) my_malloc(sizeof(boolean) * (num_pins_on_net));
00036 
00037     /* identifier for minimum spanning tree by nodes */
00038     in_mst[0] = TRUE;
00039     for(ipin = 1; ipin < num_pins_on_net; ipin++)
00040         in_mst[ipin] = FALSE;
00041 
00042     num_edges = 0;
00043 
00044     /* need to add num_pins - 1 number of edges */
00045     for(i = 1; i < num_pins_on_net; i++)
00046         {
00047             /* look at remaining num_pins - 1 pins, and add them to the mst one at a time */
00048 
00049             nearest_node = -1;
00050             nearest_node_dist = -1;
00051             nearest_node_in_mst = -1;
00052 
00053             for(ipin = 1; ipin < num_pins_on_net; ipin++)
00054                 {
00055                     /* look at each pin not in the mst, find the nearest to the current partial mst */
00056                     if(!in_mst[ipin])
00057                         {
00058                             node_dist =
00059                                 min_dist_from_mst(ipin, inet, in_mst,
00060                                                   &node_in_mst);
00061 
00062                             if(nearest_node == -1)
00063                                 {
00064                                     nearest_node = ipin;
00065                                     nearest_node_dist = node_dist;
00066                                     nearest_node_in_mst = node_in_mst;
00067                                 }
00068                             else
00069                                 {
00070                                     /* Does 0 make sense?  Currently allow.  0 means the net loops back to the same block */
00071                                     if(nearest_node_dist >= node_dist)
00072                                         {
00073                                             nearest_node = ipin;
00074                                             nearest_node_dist = node_dist;
00075                                             nearest_node_in_mst = node_in_mst;
00076                                         }
00077 
00078                                     if(nearest_node_dist < 0)
00079                                         {
00080                                             printf
00081                                                 ("Error: distance is negative\n");
00082                                             exit(1);
00083                                         }
00084                                 }
00085                         }
00086                 }
00087 
00088             /* found the nearest to the current partial mst, so add an edge to mst */
00089             min_spantree[num_edges].from_node = nearest_node_in_mst;
00090 
00091             min_spantree[num_edges].to_node = nearest_node;
00092 
00093             num_edges++;
00094 
00095             in_mst[nearest_node] = TRUE;
00096         }
00097 
00098     free(in_mst);
00099     return min_spantree;
00100 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Tue Jan 5 15:25:48 2010 for VPR5.0 by  doxygen 1.6.1