2018-09-28 17:54:21 +02:00
|
|
|
// OpenSTA, Static Timing Analyzer
|
2024-01-12 01:34:49 +01:00
|
|
|
// Copyright (c) 2024, Parallax Software, Inc.
|
2018-09-28 17:54:21 +02: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
|
2022-01-04 18:17:08 +01:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2018-09-28 17:54:21 +02:00
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
2022-01-04 18:17:08 +01:00
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2018-09-28 17:54:21 +02:00
|
|
|
|
2020-02-16 01:13:16 +01:00
|
|
|
#pragma once
|
2018-09-28 17:54:21 +02:00
|
|
|
|
2024-11-14 04:09:27 +01:00
|
|
|
#include <string>
|
|
|
|
|
|
2018-09-28 17:54:21 +02:00
|
|
|
namespace sta {
|
|
|
|
|
|
2024-11-14 04:09:27 +01:00
|
|
|
using std::string;
|
|
|
|
|
|
2018-09-28 17:54:21 +02:00
|
|
|
class Unit
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-06-24 02:11:48 +02:00
|
|
|
Unit(const char *suffix);
|
2018-09-28 17:54:21 +02:00
|
|
|
Unit(float scale,
|
|
|
|
|
const char *suffix,
|
|
|
|
|
int digits);
|
2022-04-04 05:40:49 +02:00
|
|
|
// Convert from sta units to user interface units.
|
|
|
|
|
double staToUser(double value);
|
|
|
|
|
// Convert from user interface units to sta units.
|
|
|
|
|
double userToSta(double value);
|
2019-11-11 21:03:38 +01:00
|
|
|
void operator=(const Unit &unit);
|
2018-09-28 17:54:21 +02:00
|
|
|
float scale() const { return scale_; }
|
|
|
|
|
void setScale(float scale);
|
2023-04-17 17:52:20 +02:00
|
|
|
const char *scaleAbbreviation() const;
|
2024-11-14 04:09:27 +01:00
|
|
|
const char *suffix() const { return suffix_.c_str(); }
|
2023-04-17 17:52:20 +02:00
|
|
|
// scale abbreviation + suffix
|
2024-11-14 04:09:27 +01:00
|
|
|
const char *scaledSuffix() const { return scaled_suffix_.c_str(); }
|
2018-09-28 17:54:21 +02:00
|
|
|
void setSuffix(const char *suffix);
|
|
|
|
|
int digits() const { return digits_; }
|
|
|
|
|
void setDigits(int digits);
|
2020-06-24 02:11:48 +02:00
|
|
|
// Does not include suffix.
|
2018-11-26 18:15:52 +01:00
|
|
|
int width() const;
|
2018-09-28 17:54:21 +02:00
|
|
|
const char *asString(float value) const;
|
|
|
|
|
const char *asString(double value) const;
|
|
|
|
|
const char *asString(float value,
|
|
|
|
|
int digits) const;
|
|
|
|
|
|
|
|
|
|
private:
|
2023-04-17 17:52:20 +02:00
|
|
|
void setScaledSuffix();
|
|
|
|
|
|
2018-09-28 17:54:21 +02:00
|
|
|
float scale_; // multiplier from user units to internal units
|
2024-11-14 04:09:27 +01:00
|
|
|
string suffix_; // print suffix
|
|
|
|
|
string scaled_suffix_;
|
2018-09-28 17:54:21 +02:00
|
|
|
int digits_; // print digits (after decimal pt)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// User interface units.
|
|
|
|
|
// Sta internal units are always seconds, farads, volts, amps.
|
|
|
|
|
class Units
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-06-24 02:11:48 +02:00
|
|
|
Units();
|
2018-09-28 17:54:21 +02:00
|
|
|
Unit *find(const char *unit_name);
|
2019-11-11 21:03:38 +01:00
|
|
|
void operator=(const Units &units);
|
2018-09-28 17:54:21 +02:00
|
|
|
Unit *timeUnit() { return &time_unit_; }
|
|
|
|
|
const Unit *timeUnit() const { return &time_unit_; }
|
|
|
|
|
Unit *capacitanceUnit() { return &capacitance_unit_; }
|
|
|
|
|
const Unit *capacitanceUnit() const { return &capacitance_unit_; }
|
|
|
|
|
Unit *voltageUnit() { return &voltage_unit_; }
|
|
|
|
|
const Unit *voltageUnit() const { return &voltage_unit_; }
|
|
|
|
|
Unit *resistanceUnit() { return &resistance_unit_; }
|
|
|
|
|
const Unit *resistanceUnit() const { return &resistance_unit_; }
|
|
|
|
|
Unit *currentUnit() { return ¤t_unit_; }
|
|
|
|
|
const Unit *currentUnit() const { return ¤t_unit_; }
|
|
|
|
|
Unit *powerUnit() { return &power_unit_; }
|
|
|
|
|
const Unit *powerUnit() const { return &power_unit_; }
|
|
|
|
|
Unit *distanceUnit() { return &distance_unit_; }
|
|
|
|
|
const Unit *distanceUnit() const { return &distance_unit_; }
|
|
|
|
|
Unit *scalarUnit() { return &scalar_unit_; }
|
|
|
|
|
const Unit *scalarUnit() const { return &scalar_unit_; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Unit time_unit_;
|
2023-05-10 19:12:43 +02:00
|
|
|
Unit resistance_unit_;
|
2018-09-28 17:54:21 +02:00
|
|
|
Unit capacitance_unit_;
|
|
|
|
|
Unit voltage_unit_;
|
|
|
|
|
Unit current_unit_;
|
|
|
|
|
Unit power_unit_;
|
|
|
|
|
Unit distance_unit_;
|
|
|
|
|
Unit scalar_unit_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace
|