# Kite - Detailed Router

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

Algorimthmic datas associated the TrackSegment. More...

## Public Types

enum | SlackState { RipupPerpandiculars = 1, Minimize = 2, Dogleg = 3, Slacken = 4, ConflictSolveByHistory = 5, ConflictSolveByPlaceds = 6, LocalVsGlobal = 7, MoveUp = 8, MaximumSlack = 9, Unimplemented =10, Repair =11 }

## Public Member Functions

bool | hasRoutingEvent () const
RoutingEvent * | getRoutingEvent () const
TrackElement * | getTrackSegment () const
Track * | getTrack () const
DbU::Unit | getLeftMinExtend () const
DbU::Unit | getRightMinExtend () const
unsigned int | getTerminals () const
Net * | getNet () const
unsigned int | getState () const
unsigned int | getStateCount () const
unsigned int | getRipupCount () const
unsigned int | getStateAndRipupCount () const
DbU::Unit | getWiringDelta (DbU::Unit axis) const
const Interval & | getPerpandicularFree () const
void | setState (unsigned int, unsigned int flags=0)
void | setRoutingEvent (RoutingEvent *)
void | setRipupCount (unsigned int)
void | incRipupCount ()
void | decRipupCount ()
void | resetRipupCount ()
void | resetStateCount ()
void | update ()

## Detailed Description

Algorimthmic datas associated the TrackSegment.

The DataNegociate object contains all the informations the negociation algorithm needs to know about a TrackSegment. Those informations mostly describe the slackening and ripup state of that segment.

State related datas:

- The ripup count in the current state. The count is reset to zero at each state transition.
- The slackening state (see DataNegociate::SlackState). The state indicate the next topological modification to be applied on the segment should the ripup count reach it's maximal value.
- The associated RoutingEvent. If no RoutingEvent is present, it means the segment has been either successufully placed or the algorithm has given up trying to. If present, it is a pending request for placement.

Topological related datas:

- `leftMinExtend`, the potential minimal position of the segment left extension. May not be reachable due to other topological constraints.
- `rightMinExtend`, the potential minimal position of the segment right extension.
- `terminals`, the number of terminals attached to this segment.
- `attractors`, a table of coordinates of the end points of the perpandiculars to this segment. Used to compute the wiring delta if we move the axis of the segment.
- `perpandiculars`, a `vector` of the perpandicular TrackElement. This is a fast-access cache. It must be updated each time the topology of the net is modificated.
- `perpandicularFree`, the free interval defined by the perpandiculars, that is for the sgement axis.

# Perpandiculars, Free, Attractors & Wiring Delta

All those informations are computed and updated by the DataNegociate::update() method, which relies on:

- AutoSegment::getTopologicalInfos()
- AutoSegment::getTerminalCount()

They must be reviewed as they do not take advantage of the new AutoSegment structuration.

For every perpandicular set of AutoSegment to the TrackSegment we want to place, get the coordinates of the extremity not connected to the segment and put that coordinate into a table associated with it's spin. The spin tells if the extremity is attracting the segment up or down (for an horizontal segment). The spin is incremented for up and decremented for down. After all the extremities have been processeds, we took into account only the coordinates with a non-zero spin, which means they truly attract the segment (whatever the direction).

Fig 1: Attractors Computation

The wiring delta is the total wire length needed to connect from the attractors to the segment, should it be placed on `axis`.

Fig 2: Wiring Delta

# Modifications History

Main changes in DataNegociate class design:

- Merge in the separate class `Cost`.
- Suppress the `SlackState::Desalignate`, due to the simplificated structure of the AutoSegment/AutoContacts (no more collapseds, or forced alignements).

## Member Enumeration Documentation

## ◆ SlackState

enum SlackState

Describe the various stages of a TrackSegment slackening. The numerical values are choosen so we can increment them as a counter.

Enumerator
RipupPerpandiculars | Force perpandiculars to be riped up as well as the TrackSegment, then schedule the placement of the TrackSegment before it's perpandiculars.
Minimize | If the TrackSegment is made of multiple TrackSegments with a forced alignement, suppress the alignement constraint. This should be deprecated now. Try to displace the perpandiculars so the TrackSegment is reduced to it's minimal length.
Dogleg | Break the segment into two smaller ones.
Slacken | Create additional wiring so threre is no more contraints transmitted by the perpandiculars or the terminal contacts.
ConflictSolveByHistory | Try to solve a conflict between a set of global segments by analysing the event/ripup history. See SegmentFsm::conflictSolveByHistory().
ConflictSolveByPlaceds | Try to solve a conflict between a set of global segments by analysing the current track context. See SegmentFsm::conflictSolveByPlaceds().
LocalVsGlobal | To be reviewed.
MoveUp | The segment is to be moved up (if possible).
MaximumSlack | The final state, topological modifications are exhausteds, if it cannot place at this point, it never will.
Unimplemented | Used only during the development stage, telling that the state is not available yet.
Repair | The router is in repair mode.

## Member Function Documentation

## ◆ hasRoutingEvent()

bool hasRoutingEvent | ( |  | ) | const

inline

Returns: true if there is a pending RoutingEvent for this TrackSegment.

Referenced by NegociateWindow::addRoutingEvent(), and TrackSegment::reschedule().

## ◆ getRoutingEvent()

RoutingEvent * getRoutingEvent | ( |  | ) | const

inline

Returns: The pending RoutingEvent. `NULL` will be returned if there is no pending event, meaning that the segment has been placed.

Referenced by SegmentAction::doAction(), Manipulator::makeDogleg(), Manipulator::relax(), TrackSegment::reschedule(), RoutingEvent::reschedule(), and TrackSegment::swapTrack().

## ◆ getTrackSegment()

TrackSegment * getTrackSegment | ( |  | ) | const

inline

Returns: The associated TrackSegment.

## ◆ getTrack()

Track * getTrack | ( |  | ) | const

inline

Returns: A proxy accessor for the segment's track.

## ◆ getLeftMinExtend()

DbU::Unit getLeftMinExtend | ( |  | ) | const

inline

Returns: The minimum extend possible of the segment's source (left) ending. Computed by DataNegociate::update().

Referenced by Manipulator::insertInTrack().

## ◆ getRightMinExtend()

DbU::Unit getRightMinExtend | ( |  | ) | const

inline

Returns: The minimum extend possible of the segment's target (right) ending. Computed by DataNegociate::update().

Referenced by Manipulator::insertInTrack().

## ◆ getTerminals()

unsigned int getTerminals | ( |  | ) | const

inline

Returns: The number of terminal to which this segment is connected Computed by DataNegociate::update().

Must be refined: direct or indirect?.

## ◆ getNet()

Net * getNet | ( |  | ) | const

inline

Returns: A cached accessor to the segment's net (for faster access).

## ◆ getState()

unsigned int getState | ( |  | ) | const

inline

Returns: The current state (see DataNegociate::SlackState).

Referenced by RoutingEvent::getState(), Manipulator::insertInTrack(), and Manipulator::ripupPerpandiculars().

## ◆ getStateCount()

unsigned int getStateCount | ( |  | ) | const

inline

Returns: The number of times we have reached the ripup limit while in this stage.

Referenced by SegmentFsm::conflictSolveByPlaceds().

## ◆ getRipupCount()

unsigned int getRipupCount | ( |  | ) | const

inline

Returns: The number of times the segment has been riped up in this stage.

Referenced by Manipulator::canRipup(), SegmentAction::doAction(), and RoutingEvent::process().

## ◆ getStateAndRipupCount()

unsigned int getStateAndRipupCount | ( |  | ) | const

inline

Returns
  A composite number combining the state and the ripup count: `(state<<4)+ripup`.

## ◆ getWiringDelta()

DbU::Unit getWiringDelta | ( | DbU::Unit | axis | ) | const

Returns: The wiring length needed to connect to the attractors if the segment is put on `axis`. The lower, the better...

## ◆ getPerpandicularFree()

const Interval & getPerpandicularFree | ( |  | ) | const

inline

Returns: The range of legal positions generated only by the perpandiculars.

## ◆ setState()

void setState | ( | unsigned int | state,
|  | unsigned int | flags = `0`
| ) |  |

inline

Set or reset the slacking state (see SlackState). If the `state` is the same as the current one, the state count is incremented. If the new state changes or `flags` contain KtReset, the state count is reset to one.

Referenced by SegmentAction::doAction(), Manipulator::relax(), Manipulator::repackPerpandiculars(), RoutingEvent::reschedule(), Manipulator::ripupPerpandiculars(), and RoutingEvent::setState().

## ◆ setRoutingEvent()

void setRoutingEvent | ( | RoutingEvent * | event | ) |

inline

Associate `event` to this TrackSegment.

Referenced by RoutingEvent::reschedule(), and RoutingEvent::setSegment().

## ◆ setRipupCount()

void setRipupCount | ( | unsigned int | count | ) |

inline

Directly sets the ripup count to `count`.

Referenced by SegmentAction::doAction().

## ◆ incRipupCount()

void incRipupCount | ( |  | ) |

inline

Increment the ripup count. No check is performed for bound limit.

## ◆ decRipupCount()

void decRipupCount | ( |  | ) |

inline

Decrement the ripup count (will never go below zero).

## ◆ resetRipupCount()

void resetRipupCount | ( |  | ) |

inline

Reset the ripup count to zero.

Referenced by SegmentAction::doAction().

## ◆ resetStateCount()

void resetStateCount | ( |  | ) |

inline

Reset the state count to zero.

## ◆ update()

void update | ( |  | ) |

Recompute `leftMinExtend`, `righMinExtend`, number of terminals and attractors positions.

Remark: The constructor do not calls it. It is to the algorithm responsability
  to call it before using the computed datas.

Referenced by NegociateWindow::setGCells().

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

- DataNegociate.h
- DataNegociate.cpp
- DataNegociate.dox