OpenSTA/graph/DelayNormal2.hh

94 lines
2.6 KiB
C++
Raw Normal View History

2018-11-26 18:15:52 +01:00
// OpenSTA, Static Timing Analyzer
2019-01-01 21:26:11 +01:00
// Copyright (c) 2019, Parallax Software, Inc.
2018-11-26 18:15:52 +01:00
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
2019-01-01 21:25:25 +01:00
#ifndef STA_DELAY_NORMAL2_H
#define STA_DELAY_NORMAL2_H
2018-11-26 18:15:52 +01:00
#include "MinMax.hh"
namespace sta {
// Delay values defined as objects that hold a float value.
class Delay;
// Normal distribution with early(left)/late(right) std deviations.
class Delay
{
public:
Delay();
Delay(float mean);
Delay(float mean,
2018-12-11 19:47:04 +01:00
float sigma2_early,
float sigma2_late);
2018-11-26 18:15:52 +01:00
float mean() const { return mean_; }
float sigma(const EarlyLate *early_late) const;
2018-12-11 19:47:04 +01:00
// sigma^2
float sigma2(const EarlyLate *early_late) const;
float sigma2Early() const;
float sigma2Late() const;
2018-11-26 18:15:52 +01:00
void operator=(const Delay &delay);
void operator=(float delay);
void operator+=(const Delay &delay);
void operator+=(float delay);
Delay operator+(const Delay &delay) const;
Delay operator+(float delay) const;
Delay operator-(const Delay &delay) const;
Delay operator-(float delay) const;
Delay operator-() const;
void operator-=(float delay);
2019-01-27 08:03:01 +01:00
void operator-=(const Delay &delay);
2018-11-26 18:15:52 +01:00
bool operator==(const Delay &delay) const;
bool operator>(const Delay &delay) const;
bool operator>=(const Delay &delay) const;
bool operator<(const Delay &delay) const;
bool operator<=(const Delay &delay) const;
protected:
static const int early_index = 0;
static const int late_index = 1;
private:
float mean_;
2018-12-11 19:47:04 +01:00
// Sigma^2
float sigma2_[EarlyLate::index_count];
2018-11-26 18:15:52 +01:00
};
const Delay delay_zero(0.0);
2018-12-11 19:47:04 +01:00
Delay
2018-11-26 18:15:52 +01:00
makeDelay(float delay,
float sigma_early,
2018-12-11 19:47:04 +01:00
float sigma_late);
2018-11-26 18:15:52 +01:00
inline float
delayAsFloat(const Delay &delay) { return delay.mean(); }
// Most non-operator functions on Delay are not defined as member
// functions so they can be defined on floats, where there is no class
// to define them.
Delay operator+(float delay1,
const Delay &delay2);
// Used for parallel gate delay calc.
Delay operator/(float delay1,
const Delay &delay2);
// Used for parallel gate delay calc.
Delay operator*(const Delay &delay1,
float delay2);
} // namespace
#endif