/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2022 Miodrag Milanovic * * 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 { fstHandle id; std::string name; bool is_alias; std::string scope; int width; }; class FstData { public: FstData(std::string filename); ~FstData(); uint64_t getStartTime(); uint64_t getEndTime(); std::vector& getVars() { return vars; }; void reconstruct_edges_callback(uint64_t pnt_time, fstHandle pnt_facidx, const unsigned char *pnt_value, uint32_t plen); std::vector getAllEdges(std::vector &signal, uint64_t start_time, uint64_t end_time); void reconstruct_callback_attimes(uint64_t pnt_time, fstHandle pnt_facidx, const unsigned char *pnt_value, uint32_t plen); void reconstructAtTimes(std::vector &signal,std::vector time); void reconstructAllAtTimes(std::vector time); std::string valueAt(fstHandle signal, uint64_t time); fstHandle getHandle(std::string name); double getTimescale() { return timescale; } private: void extractVarNames(); struct fstReaderContext *ctx; std::vector scopes; std::vector vars; std::map handle_to_var; std::map name_to_handle; std::map>> handle_to_data; std::map last_data; std::map> time_to_index; std::vector sample_times; size_t sample_times_ndx; double timescale; uint64_t start_time; uint64_t end_time; std::vector edges; }; YOSYS_NAMESPACE_END #endif