Switchbox Algorithm



 

Overview

The program begins by reading in the .dot file, parsing it and mapping it to an array representation called board of the switchbox to be routed. For the homework example this array is given:
 
 
0 1 0 2 3 0 0 1 3 0
0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 2
7 0 0 0 0 0 0 0 0 4
0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 4
7 0 0 0 0 0 0 0 0 0
0 6 0 0 6 3 0 0 0 0
 

A vector pinnums contains the number of unrouted pins remaining for each net (i.e. at the beginning of the algorithm pinnums[1] = 4, since net 1 has 4 pins to be routed). Another array pinlist contains the locations of these pins with respect to the board array.

Each pass of the algorithm proceeds as follows. A pin of net n at position (x1,y1) is selected to route (this is done sequentially - first a pin from net 1 is routed, then a pin from net 2, and so on). Using a maze searching technique, the closest point belonging to net n on the board, (x2,y2), is located. Clearly this will find another pin at the beginning of the algorithm, but if two pins from n have already been routed, anywhere along the wire between them is acceptable as an output from the maze search. Now we consider the problem of routing the pin at (x1,y1) towards (x2,y2). We treat this as another search problem. Note that (x2,y2) is merely used to direct the search - the final position we route may well be a different one, but (x2,y2) is a good direction in which to aim.

We start investigating a path beginning at (x1,y1). Our initial direction is necessarily chosen to be perpendicular to the face of the switchbox upon which we are starting. Our search is rule based, employing simple heuristics to decide when to turn left and right, and bad moves are recorded so that they are never repeated. A path will continue in a straight line as long as doing so brings it closer to (x2,y2) or it is blocked by a via from another net. In that sense the search is similar to line based search, although many rules are incorporated to prevent paths which may prove injurious to the routing of different nets later.

The operation of the procedure to route (x1,y1) to (x2,y2) is explained in the following pseudocode:

routeab
initialize direction;
move(direction);
while(not routed){
   if (any adjacent position = valid end position)
      move in the appropriate direction;
      insert a via if appropriate;
      routed = true;
   else if (no move is possible)
      mark the board so this position is never reached again;
      move backwards;
   else if (a straight move is forced)                                                       (1)
      move forwards;
   else if (a straight move is possible and constitutes a 'good' move)        (2)
      move forwards;
   else if (a right move is possible and constitutes a 'good' move)            (2)
      insert a via;
      move right;
   else if (a left move is possible and constitutes a 'good' move)              (2)
      insert a via;
      move left;
   else {
       if (a forward move is possible) move forward;
       else if (a right move is possible) move right;
       else if (a left move is possible) move left;
   }
}

Note the points in the above algorithm:

  1. 1: A straight move is forced if, in turning, the resultant via would result in blocking another pin's entry into the board.
  2. 2: A 'good' move is regarded simply as a move which brings the path closer to the solution. This simple definition proved sufficient to route the example given.
When a pin is routed it is removed dynamically from pinlist. Pins are sequentially selected and routed in this fashion until the board is routed. For the example given there proved to be no need for a 'rip-up-and-reroute' facility. If such a facility were necessary, it could be implemented by identifying which path is pivotal in blocking the current path, deleting it and adding the de-routed pins to  pinlist again.



 

Data Structures

There are really only three important data structures involved in the switchbox routing algorithm:
 

Conclusion and Evaluation

Why did you make these design decisions:
In reality it was not very clear to me the purpose of the assignment; whether it was to be an exercise in programming or an exercise in router design. If the former, I would simply have found a paper on switchbox routing and implemented the routines therein. I favored the latter idea as it would give me a chance to investigate my own routing strategies. The router I implemented is not very sophisticated but it does use sensible rules to reach its goal. The decision not to support rip-up-and-reroute was purely motivated by the fact that the example given did not require it, but I would be happy to try to incorporate it in a later assignment.

A short description of your experience with implementing the algorithm, programming in Java, etc...:
The homework assignment was, I felt, very long and I don't think this was as clear to the TA as it proved to be for the students afterwards. Not knowing Java before was, of course, a hindrance, and I really feel a class devoted to the TA discussing (a) Java fundamentals, and (b) the graph package we were supposed to use as our framework would have saved everyone a great deal of time. Having said this I certainly learned quite a bit of Java, but my code is sub-optimal - for the most part I tried to treat Java as though it were C, thereby missing out on the advantageous features which Java supports.

Second assignment:
The second assignment should be less lengthy, I feel. What I would like to implement is an on-line router wherein the user may specify an arbitrary pin configuration in a switchbox of arbitrary dimension. This would really test our routing algorithms to the full.



 Return to the switchbox router