2022-10-26 23:53:42 +02:00
|
|
|
// OpenSTA, Static Timing Analyzer
|
2024-01-12 01:34:49 +01:00
|
|
|
// Copyright (c) 2024, Parallax Software, Inc.
|
2022-10-26 23:53:42 +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
|
|
|
|
|
// 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/>.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-06-12 17:23:00 +02:00
|
|
|
#include <cstdint>
|
2022-10-26 23:53:42 +02:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
#include "StaState.hh"
|
|
|
|
|
|
|
|
|
|
namespace sta {
|
|
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
using std::vector;
|
|
|
|
|
using std::map;
|
|
|
|
|
using std::max;
|
|
|
|
|
using std::min;
|
|
|
|
|
|
|
|
|
|
class VcdVar;
|
|
|
|
|
class VcdValue;
|
|
|
|
|
typedef vector<VcdValue> VcdValues;
|
2022-10-28 19:52:27 +02:00
|
|
|
typedef int64_t VcdTime;
|
2022-10-26 23:53:42 +02:00
|
|
|
typedef vector<string> VcdScope;
|
2022-11-02 03:08:22 +01:00
|
|
|
typedef map<string, VcdVar*> VcdNameMap;
|
2022-10-26 23:53:42 +02:00
|
|
|
|
2023-04-24 20:35:58 +02:00
|
|
|
enum class VcdVarType {
|
|
|
|
|
wire,
|
|
|
|
|
reg,
|
|
|
|
|
parameter,
|
|
|
|
|
integer,
|
|
|
|
|
real,
|
|
|
|
|
supply0,
|
|
|
|
|
supply1,
|
2023-09-18 03:00:47 +02:00
|
|
|
time,
|
2023-04-24 20:35:58 +02:00
|
|
|
tri,
|
|
|
|
|
triand,
|
|
|
|
|
trior,
|
|
|
|
|
trireg,
|
|
|
|
|
tri0,
|
|
|
|
|
tri1,
|
|
|
|
|
wand,
|
|
|
|
|
wor,
|
|
|
|
|
unknown
|
|
|
|
|
};
|
2022-10-26 23:53:42 +02:00
|
|
|
|
|
|
|
|
class Vcd : public StaState
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Vcd(StaState *sta);
|
2022-11-02 03:08:22 +01:00
|
|
|
Vcd(const Vcd &vcd);
|
|
|
|
|
// Move copy assignment.
|
|
|
|
|
Vcd& operator=(Vcd &&vcd1);
|
|
|
|
|
~Vcd();
|
|
|
|
|
VcdVar *var(const string name);
|
|
|
|
|
VcdValues &values(VcdVar *var);
|
2022-10-26 23:53:42 +02:00
|
|
|
|
|
|
|
|
const string &date() const { return date_; }
|
|
|
|
|
void setDate(const string &date);
|
|
|
|
|
const string &comment() const { return comment_; }
|
|
|
|
|
void setComment(const string &comment);
|
|
|
|
|
const string &version() const { return version_; }
|
|
|
|
|
void setVersion(const string &version);
|
|
|
|
|
double timeScale() const { return time_scale_; }
|
|
|
|
|
void setTimeScale(double time_scale);
|
|
|
|
|
const string &timeUnit() const { return time_unit_; }
|
2022-10-28 00:12:32 +02:00
|
|
|
double timeUnitScale() const { return time_unit_scale_; }
|
2022-10-26 23:53:42 +02:00
|
|
|
void setTimeUnit(const string &time_unit,
|
|
|
|
|
double time_unit_scale);
|
2022-10-28 19:52:27 +02:00
|
|
|
VcdTime timeMax() const { return time_max_; }
|
|
|
|
|
void setTimeMax(VcdTime time_max);
|
|
|
|
|
VcdTime minDeltaTime() const { return min_delta_time_; }
|
|
|
|
|
void setMinDeltaTime(VcdTime min_delta_time);
|
2022-11-02 03:08:22 +01:00
|
|
|
vector<VcdVar*> vars() { return vars_; }
|
2022-10-26 23:53:42 +02:00
|
|
|
void makeVar(string &name,
|
|
|
|
|
VcdVarType type,
|
|
|
|
|
int width,
|
|
|
|
|
string &id);
|
|
|
|
|
int maxVarWidth() const { return max_var_width_; }
|
|
|
|
|
int maxVarNameLength() const { return max_var_name_length_; }
|
|
|
|
|
bool varIdValid(string &id);
|
|
|
|
|
void varAppendValue(string &id,
|
2022-10-28 19:52:27 +02:00
|
|
|
VcdTime time,
|
2022-10-26 23:53:42 +02:00
|
|
|
char value);
|
|
|
|
|
void varAppendBusValue(string &id,
|
2022-10-28 19:52:27 +02:00
|
|
|
VcdTime time,
|
2022-10-26 23:53:42 +02:00
|
|
|
int64_t bus_value);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
string date_;
|
|
|
|
|
string comment_;
|
|
|
|
|
string version_;
|
|
|
|
|
double time_scale_;
|
|
|
|
|
string time_unit_;
|
|
|
|
|
double time_unit_scale_;
|
|
|
|
|
|
2022-11-02 03:08:22 +01:00
|
|
|
vector<VcdVar*> vars_;
|
|
|
|
|
VcdNameMap var_name_map_;
|
2022-10-26 23:53:42 +02:00
|
|
|
size_t max_var_name_length_;
|
|
|
|
|
int max_var_width_;
|
|
|
|
|
map<string, VcdValues> id_values_map_;
|
2022-10-28 19:52:27 +02:00
|
|
|
VcdTime min_delta_time_;
|
|
|
|
|
VcdTime time_max_;
|
2022-10-26 23:53:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class VcdVar
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
VcdVar(string name,
|
|
|
|
|
VcdVarType type,
|
|
|
|
|
int width,
|
|
|
|
|
string id);
|
|
|
|
|
const string& name() const { return name_; }
|
|
|
|
|
VcdVarType type() const { return type_; }
|
|
|
|
|
int width() const { return width_; }
|
|
|
|
|
const string& id() const { return id_; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
string name_;
|
|
|
|
|
VcdVarType type_;
|
|
|
|
|
int width_;
|
|
|
|
|
string id_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class VcdValue
|
|
|
|
|
{
|
|
|
|
|
public:
|
2022-10-28 19:52:27 +02:00
|
|
|
VcdValue(VcdTime time,
|
2022-10-26 23:53:42 +02:00
|
|
|
char value,
|
|
|
|
|
uint64_t bus_value);
|
2022-10-28 19:52:27 +02:00
|
|
|
VcdTime time() const { return time_; }
|
2022-10-26 23:53:42 +02:00
|
|
|
char value() const { return value_; }
|
|
|
|
|
uint64_t busValue() const { return bus_value_; }
|
2023-10-23 01:51:18 +02:00
|
|
|
char value(int value_bit) const;
|
2022-10-26 23:53:42 +02:00
|
|
|
|
|
|
|
|
private:
|
2022-10-28 19:52:27 +02:00
|
|
|
VcdTime time_;
|
2022-10-26 23:53:42 +02:00
|
|
|
// 01XUZ or '\0' when width > 1 to use bus_value_.
|
|
|
|
|
char value_;
|
|
|
|
|
uint64_t bus_value_;
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-28 00:12:32 +02:00
|
|
|
} // namespace
|