• No results found

The Routing Problem

After placement, each of the functional blocks in the input circuit is assigned to a physical block on the FPGA. The router has to determine which of the switches in the routing architecture need to be closed in order to connect the physical blocks in accordance with the way their associated functional blocks are connected in the mapped circuit. The interconnections between functional blocks are conventionally defined as a list of nets. Each net is an interconnection between one source and one or more sinks. The netlist can also be easily defined as a list of source-sink connections.

When the routing architecture of the FPGA is represented as a routing-resource graph, the routing problem reduces to finding a sub- graph of the routing resource graph, called a routing tree, for each net in the input circuit. The routing trees should be disjoint in order to avoid short circuits. Each routing tree should contain at least the source node and sink nodes of its associated net and enough wire nodes so that source and sink nodes are connected.

This problem definition can also be expressed in terms of connec- tions, in which a connection is an ordered pair containing a source and

a sink. Each net can be seen as a set of connections and thus all in- terconnection between logic blocks can be defined as a set of connec- tions. The routing problem then reduces to finding a simple path in the routing-resource graph for each connection in the circuit. Each path starts at the source node and ends at the sink node of its associated connection. These paths should only share nodes if the corresponding connections have the same source. Allowing other connections to share nodes would lead to short circuits.

Listing 6.1: Pseudo code for PATHFINDER

1 while(IllegalSharedResourcesExist()) :

2 for each Net n do:

3 ripUpRouting(n) 4 route(n) 5 n.resources() . updatePresentCongestionCost() 6 allResources() . updateHistoryCost() 7 updatePresentCongestionMultiplier() 8 allResources() . updatePresentCongestionCost()

6.3.1 PATHFINDER: A Negotiated Congestion Mechanism

The main structure of PATHFINDER is the negotiated congestion loop [100]. The pseudo-code is shown in Listing 6.1. In every rout- ing iteration, the algorithm rips up and reroutes all the nets in the circuit. These iterations are repeated until no resources are shared il- legally. This is achieved by gradually increasing the cost of illegally shared resources. During the first iteration, nets can illegally share re- sources at little extra cost. In the subsequent iterations, the cost of a routing resource does not only depend on the current sharing cost but also on the sharing history of the resource. Resources that were illegally shared in past routing iterations become more expensive. In this way a congestion map is built, which enables the router to avoid routing through heavily congested areas, if possible.

Listing 6.2: Pseudo code of the maze router implemented in VPR routers as a net router heuristic.

1 functionroute(Net n):

2 routingTree = {source} 3 for each Sink s of n:

4 path = dijkstra (routingTree, s)

B   B  

C   C  

A   A  

(a) A possible solution from Lee’s maze router (#wires=13)

B   B  

C   C  

A   A  

(b) One of the optimal Steiner tree solutions (#wires=10)

Figure 6.4: An example of the Lee’s maze router producing a subopti- mal solution for a net with three terminals

To route one net, the embedded net router tries to find a mini- mum cost routing tree in the RRG. This problem is called the minimum steiner tree problem and is NP-complete [65]. To find a solution in a reasonable time a heuristic is needed. In Listing 6.2 the pseudocode is shown for a variant of Lee’s maze router [78] as it is implemented in VPR. For each sink of the net, the heuristic extends the already found routing tree with the shortest path from the routing tree to the sink un- der consideration with Dijkstra’s shortest path algorithm [42]. This net router heuristic is fast but does not always come up with an optimal so- lution, certainly in case of nets with a high fanout. It forces the router to extend the routing tree alongside the paths that were previously added to the routing tree. As an example we show a suboptimal solution pro- duced by the maze router alongside an optimal Steiner tree solution in Figure 6.4. If the connection A-B is routed first and Dijkstra finds the path depicted in Figure 6.4 (a), then the resulting routing tree will not have any shared wires and will be suboptimal. To overcome this prob- lem the Connection router has a negotiated sharing mechanism which is explained in Section 6.5.

Once the nets are routed some of the wires are used by multiple nets. To solve this congestion, a negotiated congestion mechanism is used, which is the main contribution of [100]. To achieve a negotiated congestion mechanism the cost of the node is modulated with conges- tion penalties and timing factors. The following equation describes how the cost of a node is calculated. In what follows the equation is broken down and each factor and penalty explained.

The cost of the node is a weighted sum of the congestion cost and the timing cost. The weights are determined by the criticality factor. The criticality factor denotes how critical a connection is.

fcrit= min  1 − slack Treq,max , fcrit,max  , (6.2)

The criticality factor is zero in the first routing iteration and is updated after each iteration following a timing analysis and according to Equa- tion (6.2). The criticality factor is capped at fcrit,max to prevent dead-

lock in case a congested wire is occupied by several critical connections. Typically fcrit,max is around 0.99. Treq,max is the maximum of all re-

quired times and it is used to normalize the slack. Together with the slack it is calculated during the traversals of the timing graph during the timing analysis. The slack is calculated from the net delay, the ar- rival time acquired during a forward traversal and the required time acquired during a backward traversal.

slack = Treq− Tarr− Tdel (6.3)

The congestion cost in Equation (6.1) is the product of b(n), the base cost of the node, p(n), the present congestion penalty, and h(n), the historical congestion penalty. If a net is rerouted the present congestion penalty is updated as follows,

p(n) =    1 if cap(n) > occ(n) 1 + pf·

(occ(n) − cap(n) + 1) otherwise

, (6.4)

where cap(n) represents the capacity of the node and occ(n) is the occu- pancy of the node. The occupancy of a node is the number of nets that are presently using the node. The factor pfis used to increase the illegal

sharing cost as the algorithm progresses. After every routing iteration, i, the historical congestion penalty is updated as follows,

hi(n) =        1 if i = 1

h(i−1)(n) if cap(n) ≥ occ(n)

h(i−1)(n)+

hf(occ(n) − cap(n)) otherwise

. (6.5)

Again, the factor hf is used to control the impact of the historical con-

gestion penalty on the total resource cost. The way the congestion fac- tors pf and hf change as the algorithm progresses is called the routing

schedule. In the connection router the same routing schedule is used as in the VPR router.

The location of the sink node, found in the placement of the circuit, is used to direct the search and thereby reducing the number of nodes visited during the search. The nodes that lead to a least-cost path are

Listing 6.3: Pseudo code of the Connection Router

1 while(IllegalSharedResourcesExist()) :

2 for each Connection c do:

3 ripUpRouting(c) 4 route(c) 5 c . resources() . updatePresentCongestionCost() 6 allResources() . updateHistoryCost() 7 updatePresentCongestionMultiplier() 8 allResources() . updatePresentCongestionCost()

expanded first. Equation (6.1) is actually the path cost seen in the node under consideration. This results in a narrow wavefront that expands in the direction of the target pin to be connected. α is the direction factor, which determines how aggressively the router explores towards the target sink, cprev the cost of the previous wire nodes on the path

from the source to this wire node and cexpthe expected cost of the path

from this wire node to the sink node. The expected cost heuristic is cal- culated based on the Manhattan distance, ∆m, from current wire node

to the sink node as follows,

cexp = fcrit· ∆m· tlin+ ∆m2 · tquad+ Rup· ∆m· Cload +

(1 − fcrit) · (∆m· b + bipin+ bsink)

(6.6)

with tlinand tquadthe linear respectively quadratic timing weights.

Rupis the sum of all wire resistances of the wires upstream and Cloadis

the capacity per wire segment. b is the base cost of a wire segment, bipin

and bsinkare the base cost of an input pin and a sink node respectively.