2022-01-26 03:23:38 -06:00
|
|
|
/*
|
|
|
|
* yosys -- Yosys Open SYnthesis Suite
|
|
|
|
*
|
|
|
|
* Copyright (C) 2022 Miodrag Milanovic <micko@yosyshq.com>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FSTDATA_H
|
|
|
|
#define FSTDATA_H
|
|
|
|
|
|
|
|
#include "kernel/yosys.h"
|
|
|
|
#include "libs/fst/fstapi.h"
|
|
|
|
|
|
|
|
YOSYS_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
struct FstVar
|
|
|
|
{
|
2022-01-26 09:39:51 -06:00
|
|
|
fstHandle id;
|
|
|
|
std::string name;
|
|
|
|
bool is_alias;
|
|
|
|
std::string scope;
|
|
|
|
int width;
|
2022-01-26 03:23:38 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
class FstData
|
|
|
|
{
|
2022-01-26 09:39:51 -06:00
|
|
|
public:
|
|
|
|
FstData(std::string filename);
|
|
|
|
~FstData();
|
2022-01-26 03:23:38 -06:00
|
|
|
|
2022-01-26 09:39:51 -06:00
|
|
|
uint64_t getStartTime();
|
|
|
|
uint64_t getEndTime();
|
2022-01-26 03:23:38 -06:00
|
|
|
|
2022-01-26 09:39:51 -06:00
|
|
|
std::vector<FstVar>& getVars() { return vars; };
|
2022-01-26 03:23:38 -06:00
|
|
|
|
2022-01-26 09:39:51 -06:00
|
|
|
void reconstruct_callback(uint64_t pnt_time, fstHandle pnt_facidx, const unsigned char *pnt_value, uint32_t plen);
|
|
|
|
void reconstruct(std::vector<fstHandle> &signal);
|
|
|
|
void reconstuctAll();
|
2022-01-26 03:23:38 -06:00
|
|
|
|
2022-01-26 09:39:51 -06:00
|
|
|
void reconstruct_callback_attimes(uint64_t pnt_time, fstHandle pnt_facidx, const unsigned char *pnt_value, uint32_t plen);
|
|
|
|
void reconstructAtTimes(std::vector<fstHandle> &signal,std::vector<uint64_t> time);
|
2022-01-26 03:23:38 -06:00
|
|
|
void reconstructAllAtTimes(std::vector<uint64_t> time);
|
|
|
|
|
2022-01-26 09:39:51 -06:00
|
|
|
std::string valueAt(fstHandle signal, uint64_t time);
|
|
|
|
std::vector<uint64_t> edges(fstHandle signal, bool positive, bool negative);
|
|
|
|
void recalc_time_offsets(fstHandle signal, std::vector<uint64_t> time);
|
2022-01-26 03:23:38 -06:00
|
|
|
|
|
|
|
fstHandle getHandle(std::string name);
|
2022-01-26 09:39:51 -06:00
|
|
|
private:
|
|
|
|
void extractVarNames();
|
2022-01-26 03:23:38 -06:00
|
|
|
|
2022-01-26 09:39:51 -06:00
|
|
|
struct fstReaderContext *ctx;
|
|
|
|
std::vector<std::string> scopes;
|
|
|
|
std::vector<FstVar> vars;
|
|
|
|
std::map<fstHandle, FstVar> handle_to_var;
|
2022-01-26 03:23:38 -06:00
|
|
|
std::map<std::string, fstHandle> name_to_handle;
|
2022-01-26 09:39:51 -06:00
|
|
|
std::map<fstHandle, std::vector<std::pair<uint64_t, std::string>>> handle_to_data;
|
|
|
|
std::map<fstHandle, std::map<uint64_t, size_t>> time_to_index;
|
|
|
|
std::map<fstHandle, std::map<size_t, uint64_t>> index_to_time;
|
|
|
|
std::vector<uint64_t> sample_times;
|
|
|
|
size_t sample_times_ndx;
|
|
|
|
std::map<fstHandle, std::string> current;
|
2022-01-26 03:23:38 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
YOSYS_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif
|