#ifndef BTOR2VCD_H_INCLUDED
#define BTOR2VCD_H_INCLUDED
#include <cinttypes>
#include <fstream>
#include <map>
#include <string>
#include <vector>
#include "btor2parser/btor2parser.h"
#include "btorsimhelpers.h"
#include "btorsimstate.h"
static const char id_start = 33;
static const char id_end = 127;
class ModuleTreeNode
{
public:
std::string name;
std::map<int64_t, std::pair<std::string, uint32_t>> wire_names;
std::vector<ModuleTreeNode*> submodules;
ModuleTreeNode (std::string name) : name (name){};
ModuleTreeNode (const char* s) : name (std::string (s)){};
~ModuleTreeNode ();
void sort_name (int64_t id,
std::string symbol,
uint32_t width,
bool symbol_fmt);
};
class BtorSimVCDWriter
{
private:
const bool readable_vcd; const bool symbol_fmt; std::ofstream vcd_file; int current_id; int64_t current_step; std::map<int64_t, std::string>
bv_identifiers; std::map<std::pair<int64_t, std::string>, std::string>
am_identifiers; std::vector<std::string>
value_changes;
std::string topname; enum ClkType
{
POSEDGE,
NEGEDGE,
EVENT
};
std::map<int64_t, ClkType> clocks;
std::string get_am_identifier (int64_t id, std::string);
std::string get_bv_identifier (int64_t id);
std::string generate_next_identifier ();
ModuleTreeNode* sort_names (Btor2Parser* model, std::string topname); void write_node_header (ModuleTreeNode* top);
public:
std::vector<BtorSimState> prev_value;
BtorSimVCDWriter (const char* vcd_path, bool readable_vcd, bool symbol_fmt);
~BtorSimVCDWriter ();
std::map<int64_t, std::string> read_info_file (const char* info_path);
void update_time (int64_t k);
void add_value_change (int64_t k, int64_t id, BtorSimState state);
void write_vcd (Btor2Parser* model);
};
#endif