diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2022-02-28 09:09:07 +0100 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2022-02-28 09:09:07 +0100 |
commit | 8be09b5b24ad5f6a09bbc0bc675ac0be241672ca (patch) | |
tree | 56cbcbd935d552b72458fbc9ee495c4302dbc204 | |
parent | ec4af6af2f380f397a17c82701d7b68feaba01fb (diff) | |
download | yosys-8be09b5b24ad5f6a09bbc0bc675ac0be241672ca.tar.gz yosys-8be09b5b24ad5f6a09bbc0bc675ac0be241672ca.tar.bz2 yosys-8be09b5b24ad5f6a09bbc0bc675ac0be241672ca.zip |
VCD reader support by using external tool
-rw-r--r-- | kernel/fstdata.cc | 19 | ||||
-rw-r--r-- | kernel/fstdata.h | 1 | ||||
-rw-r--r-- | passes/sat/sim.cc | 1 |
3 files changed, 21 insertions, 0 deletions
diff --git a/kernel/fstdata.cc b/kernel/fstdata.cc index af816e57e..587678ce3 100644 --- a/kernel/fstdata.cc +++ b/kernel/fstdata.cc @@ -22,8 +22,25 @@ USING_YOSYS_NAMESPACE +static std::string file_base_name(std::string const & path) +{ + return path.substr(path.find_last_of("/\\") + 1); +} + FstData::FstData(std::string filename) : ctx(nullptr) { + #if !defined(YOSYS_DISABLE_SPAWN) + std::string filename_trim = file_base_name(filename); + if (filename_trim.size() > 4 && filename_trim.compare(filename_trim.size()-4, std::string::npos, ".vcd") == 0) { + filename_trim.erase(filename_trim.size()-4); + tmp_file = stringf("/tmp/converted_%s.fst", filename_trim.c_str()); + std::string cmd = stringf("vcd2fst %s %s", filename.c_str(), tmp_file.c_str()); + log("Exec: %s\n", cmd.c_str()); + if (run_command(cmd) != 0) + log_cmd_error("Shell command failed!\n"); + filename = tmp_file; + } + #endif const std::vector<std::string> g_units = { "s", "ms", "us", "ns", "ps", "fs", "as", "zs" }; ctx = (fstReaderContext *)fstReaderOpen(filename.c_str()); if (!ctx) @@ -53,6 +70,8 @@ FstData::~FstData() { if (ctx) fstReaderClose(ctx); + if (!tmp_file.empty()) + remove(tmp_file.c_str()); } uint64_t FstData::getStartTime() { return fstReaderGetStartTime(ctx); } diff --git a/kernel/fstdata.h b/kernel/fstdata.h index 707d1b64e..4a355fd77 100644 --- a/kernel/fstdata.h +++ b/kernel/fstdata.h @@ -74,6 +74,7 @@ private: CallbackFunction callback; std::vector<fstHandle> clk_signals; bool all_samples; + std::string tmp_file; }; YOSYS_NAMESPACE_END diff --git a/passes/sat/sim.cc b/passes/sat/sim.cc index 1cd0a0338..bdec54a96 100644 --- a/passes/sat/sim.cc +++ b/passes/sat/sim.cc @@ -1160,6 +1160,7 @@ struct SimWorker : SimShared pool<Module*> wbmods; top->writeback(wbmods); } + delete fst; } void run_cosim_witness(Module *topmod) |