# Kite - Detailed Router

Public Types | Public Member Functions | List of all members
SegmentFsm Class Reference

Pseudo-decorator to process a RoutingEvent. More...

## Public Types

enum | State { MissingData = (1<<0), EmptyTrackList = (1<<1), Inserted = (1<<2), Self = (1<<3), Other = (1<<4), Ripup = (1<<5), MaximumSlack = (1<<6), SelfInserted = Self | Inserted, OtherRipup = Other | Ripup, SelfMaximumSlack = Self | MaximumSlack }

## Public Member Functions

| SegmentFsm (RoutingEvent *, RoutingEventQueue &, RoutingEventHistory &)
bool | isFullBlocked () const
RoutingEvent * | getEvent () const
RoutingEventQueue & | getQueue () const
RoutingEventHistory & | getHistory () const
unsigned int | getState () const
DataNegociate * | getData ()
Interval & | getConstraint ()
Interval & | getOptimal ()
vector< TrackCost > & | getCosts ()
TrackCost & | getCost (size_t)
Track * | getTrack (size_t)
size_t | getBegin (size_t)
size_t | getEnd (size_t)
vector< SegmentAction > & | getActions ()
void | setState (unsigned int)
void | addAction (TrackElement *, unsigned int type, DbU::Unit axisHint=0, unsigned int toState=0)
void | doActions ()
void | clearActions ()
bool | insertInTrack (size_t)
bool | conflictSolveByHistory ()
bool | conflictSolveByPlaceds ()
bool | desaturate ()
bool | slackenTopology (unsigned int flags=0)
bool | solveFullBlockages ()

## Detailed Description

Pseudo-decorator to process a RoutingEvent.

The SegmentFsm class actually perform the placement of the Kite::TrackElement of the Kite::RoutingEvent. It structured around three goals:

- Implement the finite state machine for the Kite::DataNegociate state.
- Provide a kind of decoration on the RoutingEvent/TrackElement (it do not abide by the definition from Design Patterns).
- Cache a lot of on-the-fly computed datas needed during the SegmentFsm lifetime and the Manipulator(s) it may uses.

# Update Mechanism

The constructor of SegmentFsm triggers the update of the RoutingEvent and through it DataNegociate.

# Slackening / FSM Transitions

A transition occurs in the FSM whenener all the availables ripup methods for a segment have failed. Failure means that the topology of the net itself must be altered to allow a greater level of flexibility. Modifying the net topology means to give the current segment some more slack.

Availables slackening operations:

1. DataNegociate::RipupPerpandiculars (Manipulator) place the segments before any of it's perpandiculars are placed to allow a maximum track choice.
2. DataNegociate::Minimize (Manipulator) try to fit the segment in a hole in a track, perform a hole detection.
3. DataNegociate::Dogleg (Manipulator) create a dogleg matching the first track candidate with a non-nul overlap.
4. DataNegociate::Slacken (Manipulator) to be reviewed.
5. DataNegociate::ConflictSolveByHistory (SegmentFsm) try to find a break point on the segment, based on the ripup history.
6. DataNegociate::ConflictSolveByPlaceds (SegmentFsm) try to find a break point on the segment, based on the current position of segments on the candidate tracks.
7. DataNegociate::MoveUp (Manipulator) try to move up the segment.

Simple slackening operations are defined in Manipulator and complex ones directly in SegmentFsm.

# Non-Slackening Operations

In addition, some operation that do not modifies the topology are availables:

1. Manipulator::forceOverLocals() mostly for global segments to ripup a track from all it's locals.
2. SegmentFsm::insertInTrack() automates the three subsequent ripup trials.

## Member Enumeration Documentation

## ◆ State

enum State

Indicates what the SegmentFsm has done the processed TrackElement, possible values are:

- SegmentFsm::MissingData, this is an error condition, the TrackElement do not have associated DataNegociate structure. Nothing is done.
- SegmentFsm::EmptyTrackList, no Track is available for placement (free or used).
- SegmentFsm::SelfInserted, the TrackElement can be successfully inserted in a Track (i.e. without overlap).
- SegmentFsm::SelfMaximumSlack, nothing can be done to further slacken the TrackElement, it is at maximum ripup of the last possible state (no more topological modifications are possibles).
- SegmentFsm::OtherRipup, the TrackElement can be inserted but it needs the ripup of some others.

Enumerator
MissingData | [Flag], see SegmentFsm::SegmentFsmValue.
EmptyTrackList | [Flag], see SegmentFsm::SegmentFsmValue.
Inserted | [Flag], the TrackElement can be inserted in a Track.
Self | [Flag], the action is related to the processed TrackSegment.
Other | [Flag], the action is not related to the processed TrackSegment, that is, others are being topologically modificated or riped up.
Ripup | [Flag], segement, that are not the processed one are being ripped up.
MaximumSlack | [Flag], the processed segment as reached it's maximum ripup count on the last possible slackening state.
SelfInserted | [Mask], see SegmentFsm::SegmentFsmValue.
OtherRipup | [Mask], see SegmentFsm::SegmentFsmValue.
SelfMaximumSlack | [Mask], see SegmentFsm::SegmentFsmValue.

## Constructor & Destructor Documentation

## ◆ SegmentFsm()

SegmentFsm | ( | RoutingEvent * | event,
|  | RoutingEventQueue & | queue,
|  | RoutingEventHistory & | history
| ) |  |

Parameters

  event | The RoutingEvent to be processed.
  queue | The RoutingEvent queue.
  history | The complete history of RoutingEvent.

Construct a SegmentFsm from a RoutingEvent. The constructor is in charge of computing all the cached values.

## Member Function Documentation

## ◆ isFullBlocked()

bool isFullBlocked | ( |  | ) | const

inline

Returns: true if there are Tracks avalaibles but the constraints are such that none is actually usable.

## ◆ getEvent()

RoutingEvent * getEvent | ( |  | ) | const

inline

Returns: The currently processed RoutingEvent (cached).

Referenced by SegmentFsm::doActions(), SegmentFsm::slackenTopology(), and SegmentFsm::solveFullBlockages().

## ◆ getQueue()

RoutingEventQueue & getQueue | ( |  | ) | const

inline

Returns: The RoutingEvent queue (cached).

## ◆ getHistory()

RoutingEventHistory & getHistory | ( |  | ) | const

inline

Returns: The RoutingEvent history (cached).

Referenced by SegmentFsm::conflictSolveByHistory().

## ◆ getState()

unsigned int getState | ( |  | ) | const

inline

Returns: The state (SegmentFsm::SegmentFsmValues) which the SegmentFsm has computed for the RoutingEvent. This is not the state of the DataNegociate

## ◆ getData()

DataNegociate * getData | ( |  | ) |

inline

Returns: The DataNegociate of the TrackElement (cached).

## ◆ getConstraint()

Interval & getConstraint | ( |  | ) |

inline

Returns: The interval into which the segment axis can be set (computed from the topological constraints and the placement constraints on the already placed perpandiculars).

## ◆ getOptimal()

Interval & getOptimal | ( |  | ) |

inline

Returns: The interval for an optimal placement of the segment axis.

## ◆ getCosts()

vector< TrackCost > & getCosts | ( |  | ) |

inline

Returns: The table of cost for all the candidates Tracks of the segment. The table is sorted in increasing cost order (see TrackCost).

Referenced by SegmentFsm::desaturate(), Manipulator::forceOverLocals(), Manipulator::makeDogleg(), and Manipulator::minimize().

## ◆ getCost()

TrackCost & getCost | ( | size_t | i | ) |

inline

Returns: The cost at index `i` in the table.

Referenced by SegmentFsm::desaturate(), Manipulator::forceOverLocals(), Manipulator::forceToTrack(), Manipulator::insertInTrack(), Manipulator::minimize(), and SegmentFsm::solveFullBlockages().

## ◆ getTrack()

Track * getTrack | ( | size_t | i | ) |

inline

Returns: The Track for cost at index `i` in the table.

Referenced by SegmentFsm::desaturate(), Manipulator::forceOverLocals(), Manipulator::forceToTrack(), Manipulator::insertInTrack(), Manipulator::makeDogleg(), Manipulator::minimize(), and Manipulator::shrinkToTrack().

## ◆ getBegin()

size_t getBegin | ( | size_t | i | ) |

inline

Returns: The overlapping begin index in Track for cost at index `i` in the table.

Referenced by SegmentFsm::desaturate(), Manipulator::forceOverLocals(), Manipulator::forceToTrack(), Manipulator::insertInTrack(), Manipulator::makeDogleg(), Manipulator::minimize(), and Manipulator::shrinkToTrack().

## ◆ getEnd()

size_t getEnd | ( | size_t | i | ) |

inline

Returns: The overlapping end index in Track for cost at index `i` in the table.

Referenced by SegmentFsm::desaturate(), Manipulator::forceOverLocals(), Manipulator::forceToTrack(), Manipulator::insertInTrack(), Manipulator::makeDogleg(), Manipulator::minimize(), and Manipulator::shrinkToTrack().

## ◆ getActions()

vector< SegmentAction * > & getActions | ( |  | ) |

inline

Returns: The table of SegmentAction, that is the delayed requests for RoutingEvent creation.

Referenced by Manipulator::shrinkToTrack().

## ◆ setState()

unsigned int setState | ( | unsigned int | state | ) |

inline

Returns: Sets the state of the state...

Referenced by SegmentFsm::desaturate(), Manipulator::forceOverLocals(), Manipulator::forceToTrack(), Manipulator::insertInTrack(), and Manipulator::shrinkToTrack().

## ◆ addAction()

void addAction | ( | TrackElement * | segment,
|  | unsigned int | type,
|  | DbU::Unit | axisHint = `0`,
|  | unsigned int | toState = `0`
| ) |  |

Request the creation of a new delayed RoutingEvent, for the meaning of the parameters, see SegmentAction::SegmentAction.

Referenced by SegmentFsm::desaturate(), Manipulator::forceOverLocals(), Manipulator::forceToTrack(), Manipulator::insertInTrack(), Manipulator::minimize(), Manipulator::relax(), Manipulator::repackPerpandiculars(), Manipulator::ripple(), Manipulator::ripup(), Manipulator::ripupPerpandiculars(), Manipulator::shrinkToTrack(), and SegmentFsm::slackenTopology().

## ◆ doActions()

bool doActions | ( |  | ) |

Actually generate RoutingEvent(s) from the SegmentAction(s).

## ◆ clearActions()

void clearActions | ( |  | ) |

inline

Clear the the table of requested actions, whithout generating them.

Referenced by Manipulator::insertInTrack(), and SegmentFsm::slackenTopology().

## ◆ insertInTrack()

bool insertInTrack | ( | size_t | i | ) |

Try to insert the TrackElement in the Track at index `i` (in the cost table). Return true if the insertion is possible.

The insertion is not done at this stage, but a set of ripup actions is emitted to allow insertion the next time the segment will be processed.

Three subsequent trials are done before giving up on inserting the segment:

1. Manipulator::insertInTrack(), try to push asides the neighbors.
2. Manipulator::shrinkToTrack(), try squeeze the segment in an existing free space.
3. Manipulator::forceToTrack(), perform a complete ripup of all the neighbors and their perpandiculars.

The event keeps track of the insertion attempt step (see RoutingEvent::getInsertState()).

## ◆ conflictSolveByHistory()

bool conflictSolveByHistory | ( |  | ) |

Returns: true if a suitable dogleg has been created in the segment.

Initially, global segments may be very long, and a placement solution in which each one is placed on a track of it's own may not be realisable. In that case, at least one of the global segment must be broken. The figure below illustrate the case: (a), (b), (c) form a first cluster and (d), (e), (f) form a second one. Due to the constraints of the segments the remaining free track cannot be the same in both clusters. The only solution to place (g) is to break it into two sub-globals. The whole point of the conflict solve is to correctly detect the cluster and choose the breaking point.

Conflict Between Globals

This variant of the conflict solve method try to guess the track span for which there is a conflict by looking at the event history.

Building Conflicting Intervals

Dislodger Definition:

A segment is said to be a dislodger if it matches the two following criterions:

- It's span intersect the to be inserted segment span.
- It has been placed on a track inside the perpandicular span of the to be placed segment.

For the time beeing we limit the search to the last three dislodgers, to not waste too much time looking back the event history. We merge overlapping intervals into one (see the undocumented class `UnionIntervals` and `RipupHistory` in `SegmentFsm.cpp`).

For the time beeing we only look on the track into which the to be inserted segment wants to be placed.

Then we try to break the to be placed segment, first under the lower bound (source) of the conflicting interval then, in case of failure under the upper bound (target).

Interval Breaking

## ◆ conflictSolveByPlaceds()

bool conflictSolveByPlaceds | ( |  | ) |

Returns: true if a suitable dogleg has been created in the segment or a dislodger has been moved up.

This methods achieve the same goal as SegmentFsm::conflictSolveByHistory() but uses a different strategy.

Instead of looking through the history to find dislodgers it analyses the placed segments in all the candidates tracks for the to be placed segment. Unlike it's sibling method, which creates only one dogleg, as it uses the Manipulator::relax() method, it may creates up to two doglegs.

Synthetic Description

1. For each track, find the dislodgers, merge the overlaps into one interval and store the length of the longuest overlap (aka conflict).
2. Sort the tracks according to decreasing longuest overlap/confict.
3. For each track in the sorted list, look for a dislodger under the middle of the to be placed segment. If no dislodger is present at this place go to the next track. Otherwise:
   - The dislodger is local, then try to relax the to placed segment around the dislodger.
   - The dislodger is global, try to move it up, if it is not possible, fallback to the relax approach.
4. Quit on the first successful move up or relax.
5. If there is no candidate tracks, this means the vertical constraints are too tight, in that case, ripup the perpandiculars (fallback plan).

Interval Accounting

Only global conflicting segments are took into account. Local segments may be took into account if they overlap global ones (all part of the same net). All overlapping segments are merged into one big conflict interval. The whole length of a conflict interval is took into account event if it's overlap with the to be placed segment is only partial.

Track Ordering (lexicographic)

1. The longuest (in one interval) conflict length.
2. The longuest cumulative conflict length (all interval summed up).

Interval accounting and Track ordering is managed through the undocumented `Cs1Candidate` class implemented in `SegmentFsm.cpp`.

Candidates Track Ordering

## ◆ desaturate()

bool desaturate | ( |  | ) |

Try to create a suitable empty space in a cost Track by moving up TrackElement in conflict.

## ◆ slackenTopology()

bool slackenTopology | ( | unsigned int | flags = `0` | ) |

Modificate the topology of the TrackElement to slacken it. It is the implementation of the slakening finite state machine.

## ◆ solveFullBlockages()

bool solveFullBlockages | ( |  | ) |

Try to solve a fully blocked configuration.

The documentation for this class was generated from the following files:

- SegmentFsm.h
- SegmentFsm.cpp
- SegmentFsm.dox