# Hurricane VLSI Database

Classes | Typedefs | Enumerations | Enumerator | Functions
DbU/Unit description

Fixed point numbers management. More...

## Classes
class | Hurricane::DbU
| DataBase Unit managment (API). More...

## Typedefs
typedef std::int64_t | Hurricane::DbU::Unit

## Enumerations
enum | Hurricane::DbU::StringMode { Hurricane::DbU::Db = (1<<0), Hurricane::DbU::Grid = (1<<1), Hurricane::DbU::Symbolic = (1<<2) }
enum | Hurricane::DbU::UnitPower { Hurricane::DbU::Pico = 1, Hurricane::DbU::Nano, Hurricane::DbU::Micro, Hurricane::DbU::Milli, Hurricane::DbU::Unity, Hurricane::DbU::Kilo }
enum | Hurricane::DbU::SnapMode { Hurricane::DbU::Inferior = 1, Hurricane::DbU::Superior = 2, Hurricane::DbU::Nearest = 4 }

## Functions
static Unit | Hurricane::DbU::fromDb (Unit value)
static Unit | Hurricane::DbU::fromGrid (double value)
static Unit | Hurricane::DbU::fromLambda (double value)
static Unit | Hurricane::DbU::fromPhysical (double value, UnitPower p)
static Unit | Hurricane::DbU::toDb (Unit u)
static double | Hurricane::DbU::toGrid (Unit u)
static double | Hurricane::DbU::toLambda (Unit u)
static double | Hurricane::DbU::toPhysical (Unit u, UnitPower p)
static unsigned int | Hurricane::DbU::getPrecision ()
static unsigned int | Hurricane::DbU::getMaximalPrecision ()
static double | Hurricane::DbU::getResolution ()
static void | Hurricane::DbU::setGridsPerLambda (double gridsPerLambda, unsigned int flags=NoFlags)
static double | Hurricane::DbU::getGridsPerLambda ()
static void | Hurricane::DbU::setStringMode (unsigned int mode, UnitPower p=Nano)
static string | Hurricane::DbU::getValueString (Unit u, int mode=SmartTruncate)
static void | Hurricane::DbU::setPrecision (unsigned int precision, unsigned int flags=NoFlags)
static void | Hurricane::DbU::setRealSnapGridStep (DbU::Unit step)
static DbU::Unit | Hurricane::DbU::getRealSnapGridStep ()
static DbU::Unit | Hurricane::DbU::getOnRealSnapGrid (DbU::Unit u, SnapMode mode=Nearest)
static void | Hurricane::DbU::setSymbolicSnapGridStep (DbU::Unit step)
static DbU::Unit | Hurricane::DbU::getSymbolicSnapGridStep ()
static DbU::Unit | Hurricane::DbU::getOnSymbolicSnapGrid (DbU::Unit u, SnapMode mode=Nearest)
static DbU::Unit | Hurricane::DbU::getOnCustomGrid (DbU::Unit u, DbU::Unit step, SnapMode mode=Nearest)
static DbU::Unit | Hurricane::DbU::getOnPhysicalGrid (DbU::Unit u, SnapMode mode=Superior)

## Obsoleteds
Due to their somewhat unclear naming convention, those functions have been renamed by the to / from variants.
static Unit | Hurricane::DbU::db (Unit value)
static Unit | Hurricane::DbU::grid (double value)
static Unit | Hurricane::DbU::lambda (double value)
static Unit | Hurricane::DbU::getDb (Unit u)
static double | Hurricane::DbU::getGrid (Unit u)
static double | Hurricane::DbU::getLambda (Unit u)

## Detailed Description

Fixed point numbers management.

# Introduction

The DbU class provides the DbU::Unit type for modelling geometric length, that is abscissas, ordinates, widths, offsets and a set of functions to convert DbU::Unit to and from external coordinates.

Remark: The DbU class contains only static methods, and is not meant to
  be instanciated. The working type is DbU::Unit.

The DbU class manage three king of length :

- DbU::Unit : the working type. It is currently associated to a long integer and a precision/resolution. This way all numbers are bound to the same precision (unlike floating point numbers) preventing rounding errors.
- Real length : length, expressed in steps of founder grid. We have the straight relation ship : grid = unit * resolution
- Symbolic length : length, expressed in lambdas. A lambda is an even multiple of the founder grid step. lambda = grid / lambdaPerGrid

# Precision

It is possible to choose (once for all) the precision with which unit values are stored.

This precision represents the maximal number of decimal digits allowed (it applies globally to all units). Therefore for a precision of 3, the unit will represent a value of 0.001 and the founder grid value 23.54 will be represented by a unit equal to 23540.

Related functions :

- DbU::getPrecision()
- DbU::getMaximalPrecision()
- DbU::setPrecision()

# Resolution

The resolution is associated to the precision. Indeed it represents the external value associated to the smallest unit, that is the value returned by getGrid(Unit::db(1)).

Related functions : DbU::getResolution()

# Grids per Lambda ratio

Set the ratio between grids and lambdas. This must be an even integer. Once sets, musn't be changed.

Related functions :

- DbU::setGridsPerLambda()
- DbU::getGridsPerLambda()

# Grid

Thoses function are closely related to editors. They allow to restrict to positions on a grid. We support three kind of grid, real, symbolic and user defined.

- DbU::getRealSnapGridStep
- DbU::getOnRealSnapGrid
- DbU::setRealSnapGridStep
- DbU::getSymbolicSnapGridStep
- DbU::getOnSymbolicSnapGrid
- DbU::setSymbolicSnapGridStep
- DbU::getOnCustomGrid
- DbU::getOnPhysicalGrid

# Translators

Translate a DbU::Unit into grid or lambda length :

- long DbU::toDb (DbU::Unit u)
- double DbU::toGrid (DbU::Unit u)
- double DbU::toLambda (DbU::Unit u)
- double DbU::toPhysical (DbU::Unit u, UnitPower p)

Translate a lambda length into a DbU::Unit :

- DbU::Unit DbU::fromDb (long v)
- DbU::Unit DbU::fromGrid (double v)
- DbU::Unit DbU::fromLambda (double v)
- DbU::Unit DbU::fromPhysical (double v, UnitPower p)

## Typedef Documentation

## ◆ Unit

long Hurricane::DbU::Unit

The working DataBase type for storing dimensions.

## Enumeration Type Documentation

## ◆ StringMode

enum Hurricane::DbU::StringMode

Select how units are to be printed by getValueString().

Enumerator
Db | Units are printed "as is", their true value as stored in the DataBase.
Grid | Units are printed as founder grid steps.
Symbolic | Units are printed as symbolic (lambdas).

## ◆ UnitPower

enum Hurricane::DbU::UnitPower

This enumeration defines the power applicable to physical units.

Enumerator
Pico | 10e-12
Nano | 10e-9
Micro | 10e-6
Milli | 10e-3
Unity | 1
Kilo | 10e+3

## ◆ SnapMode

enum Hurricane::DbU::SnapMode

This enumeration defines the rounding applicable to the grid management functions.

Enumerator
Inferior | Round to the inferior grid point.
Superior | Round to the superior grid point.
Nearest | Round nearest grid point, inferior or superior depending on the distance.

## Function Documentation

## ◆ fromDb()

DbU::Unit Hurricane::DbU::fromDb | ( | DbU::Unit | value | ) |
| inline static

Returns: the unit corresponding to the value `<value>` according to the current precision. This function do nothing apart from a cast.

Referenced by Hurricane::DbU::db().

## ◆ fromGrid()

DbU::Unit Hurricane::DbU::fromGrid | ( | double | value | ) |
| inline static

Returns: the unit corresponding to the grid value `<value>` according to the current precision.

Referenced by Hurricane::DbU::fromLambda(), Hurricane::DbU::fromPhysical(), and Hurricane::DbU::grid().

## ◆ fromLambda()

DbU::Unit Hurricane::DbU::fromLambda | ( | double | value | ) |
| inline static

Returns: the unit corresponding to the symbolic value `<value>` according to the current precision.

References Hurricane::DbU::fromGrid().

Referenced by Hurricane::DbU::lambda().

## ◆ fromPhysical()

DbU::Unit Hurricane::DbU::fromPhysical | ( | double | value,
|  | UnitPower | p
| ) |  |
| inline static

Returns: the unit corresponding to the physical value `<value>` with power `p`, according to the current precision.

References Hurricane::DbU::fromGrid().

## ◆ toDb()

long Hurricane::DbU::toDb | ( | DbU::Unit | u | ) |
| inline static

Returns: the external value associated to the unit `<unit>` according to the current precision. This function do nothing apart from a type cast.

Referenced by Hurricane::DbU::getDb().

## ◆ toGrid()

double Hurricane::DbU::toGrid | ( | DbU::Unit | u | ) |
| inline static

Returns: the value expressed as a number of founder grid steps associated to the unit `<unit>` according to the current precision.

Referenced by Hurricane::DbU::getGrid(), and Hurricane::DbU::toLambda().

## ◆ toLambda()

double Hurricane::DbU::toLambda | ( | DbU::Unit | u | ) |
| inline static

Returns: the symbolic value (expressed as a number lambdas) associated to the unit `<unit>` according to the current precision.

References Hurricane::DbU::toGrid().

Referenced by Hurricane::DbU::getLambda().

## ◆ toPhysical()

double Hurricane::DbU::toPhysical | ( | DbU::Unit | u,
|  | UnitPower | p
| ) |  |
| inline static

Returns: the physical value of `u`, expressed in the power `p`.

## ◆ getPrecision()

unsigned Hurricane::DbU::getPrecision | ( |  | ) |
| static

Returns: the current precision (whose default is fixed to 1).

## ◆ getMaximalPrecision()

unsigned Hurricane::DbU::getMaximalPrecision | ( |  | ) |
| static

Returns: the maximal precision allowed (currently fixed to 3).

## ◆ getResolution()

double Hurricane::DbU::getResolution | ( |  | ) |
| static

Returns: the current resolution.

## ◆ setGridsPerLambda()

void Hurricane::DbU::setGridsPerLambda | ( | double | gridsPerLambda,
|  | unsigned int | flags = `NoFlags`
| ) |  |
| static

Returns: Sets how many founder grid steps makes one lambda. It must be an event integer otherwise an exception is thrown.

## ◆ getGridsPerLambda()

double Hurricane::DbU::getGridsPerLambda | ( |  | ) |
| static

Returns: How many founder grid steps makes one lambda.

## ◆ setStringMode()

void Hurricane::DbU::setStringMode | ( | unsigned int | mode,
|  | UnitPower | p = `Nano`
| ) |  |
| static

Sets in which length the units are to be displayed by getValueString(). Avalaibles modes are :

## ◆ getValueString()

string Hurricane::DbU::getValueString | ( | Unit | unit,
|  | int | mode = `SmartTruncate`
| ) |  |
| static

Returns
  A character string representing the external value of `<unit>`. The value is converted in the length according to setStringMode(): database, grid or symbolic.

Remark: This string is shorter than the one we could print from the
  external value because non needed decimals are not drawn (nor the point if value is integer).

## ◆ setPrecision()

void Hurricane::DbU::setPrecision | ( | unsigned int | precision,
|  | unsigned int | flags = `NoFlags`
| ) |  |
| static

Allows to set the precision at a requested value. This must be done at the begining of the program (before the creation of the first unit) and not changed for the following (unless mandatory and for a temporary period because all existing units would be misinterpreted).

Remark: This function throws an exception if the requested precision
  is greater than the maximal one.

## ◆ setRealSnapGridStep()

void Hurricane::DbU::setRealSnapGridStep | ( | DbU::Unit | step | ) |
| inline static

Set the real (founder) grid step.

## ◆ getRealSnapGridStep()

DbU::Unit Hurricane::DbU::getRealSnapGridStep | ( |  | ) |
| static

Get the real (founder) grid step.

## ◆ getOnRealSnapGrid()

DbU::Unit Hurricane::DbU::getOnRealSnapGrid | ( | DbU::Unit | u,
|  | DbU::SnapMode | mode = `Nearest`
| ) |  |
| static

Get the snap point from the unit `u`, using the rounding mode `mode`.

## ◆ setSymbolicSnapGridStep()

void Hurricane::DbU::setSymbolicSnapGridStep | ( | DbU::Unit | step | ) |
| inline static

Set the symbolic grid step.

## ◆ getSymbolicSnapGridStep()

DbU::Unit Hurricane::DbU::getSymbolicSnapGridStep | ( |  | ) |
| static

Get the symbolic grid step.

## ◆ getOnSymbolicSnapGrid()

DbU::Unit Hurricane::DbU::getOnSymbolicSnapGrid | ( | DbU::Unit | u,
|  | DbU::SnapMode | mode = `Nearest`
| ) |  |
| static

Get the snap point from the unit `u`, using the rounding mode `mode`.

## ◆ getOnCustomGrid()

DbU::Unit Hurricane::DbU::getOnCustomGrid | ( | DbU::Unit | u,
|  | DbU::Unit | step,
|  | DbU::SnapMode | mode = `Nearest`
| ) |  |
| static

Get the snap point from the unit `u`, with grid step `step` using the rounding mode `mode`.

Referenced by Hurricane::DbU::getOnPhysicalGrid().

## ◆ getOnPhysicalGrid()

DbU::Unit Hurricane::DbU::getOnPhysicalGrid | ( | DbU::Unit | u,
|  | DbU::SnapMode | mode = `Superior`
| ) |  |
| inline static

Get the physical grid unit nearest to `u`, with `mode` rounding. using the rounding mode `mode`.

References Hurricane::DbU::getOnCustomGrid(), and Hurricane::DbU::grid().

## ◆ db()

DbU::Unit Hurricane::DbU::db | ( | DbU::Unit | value | ) |
| inline static

Returns: the unit corresponding to the value `<value>` according to the current precision. This function do nothing apart from a cast.

References Hurricane::DbU::fromDb().

## ◆ grid()

DbU::Unit Hurricane::DbU::grid | ( | double | value | ) |
| inline static

Returns: the unit corresponding to the grid value `<value>` according to the current precision.

References Hurricane::DbU::fromGrid().

Referenced by Hurricane::DbU::getOnPhysicalGrid().

## ◆ lambda()

DbU::Unit Hurricane::DbU::lambda | ( | double | value | ) |
| inline static

Returns: the unit corresponding to the symbolic value `<value>` according to the current precision.

References Hurricane::DbU::fromLambda().

## ◆ getDb()

long Hurricane::DbU::getDb | ( | DbU::Unit | u | ) |
| inline static

Returns: the external value associated to the unit `<unit>` according to the current precision. This function do nothing apart from a type cast.

References Hurricane::DbU::toDb().

## ◆ getGrid()

double Hurricane::DbU::getGrid | ( | DbU::Unit | u | ) |
| inline static

Returns: the value expressed as a number of founder grid steps associated to the unit `<unit>` according to the current precision.

References Hurricane::DbU::toGrid().

## ◆ getLambda()

double Hurricane::DbU::getLambda | ( | DbU::Unit | u | ) |
| inline static

Returns: the symbolic value (expressed as a number lambdas) associated to the unit `<unit>` according to the current precision.

References Hurricane::DbU::toLambda().

Generated by doxygen 1.8.14 on Sun Mar 8 2020 | Return to top of page

Hurricane VLSI Database | Copyright © 2000-2016 Bull S.A. All rights reserved