mirror of https://github.com/YosysHQ/yosys.git
Merge pull request #2403 from nakengelhardt/sim_timescale
sim -vcd: add date, version, and option for timescale
This commit is contained in:
commit
3b86b5da5f
|
@ -22,6 +22,8 @@
|
||||||
#include "kernel/celltypes.h"
|
#include "kernel/celltypes.h"
|
||||||
#include "kernel/mem.h"
|
#include "kernel/mem.h"
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
USING_YOSYS_NAMESPACE
|
USING_YOSYS_NAMESPACE
|
||||||
PRIVATE_NAMESPACE_BEGIN
|
PRIVATE_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
@ -620,6 +622,7 @@ struct SimWorker : SimShared
|
||||||
SimInstance *top = nullptr;
|
SimInstance *top = nullptr;
|
||||||
std::ofstream vcdfile;
|
std::ofstream vcdfile;
|
||||||
pool<IdString> clock, clockn, reset, resetn;
|
pool<IdString> clock, clockn, reset, resetn;
|
||||||
|
std::string timescale;
|
||||||
|
|
||||||
~SimWorker()
|
~SimWorker()
|
||||||
{
|
{
|
||||||
|
@ -631,6 +634,17 @@ struct SimWorker : SimShared
|
||||||
if (!vcdfile.is_open())
|
if (!vcdfile.is_open())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
vcdfile << stringf("$version %s $end\n", yosys_version_str);
|
||||||
|
|
||||||
|
std::time_t t = std::time(nullptr);
|
||||||
|
char mbstr[255];
|
||||||
|
if (std::strftime(mbstr, sizeof(mbstr), "%c", std::localtime(&t))) {
|
||||||
|
vcdfile << stringf("$date ") << mbstr << stringf(" $end\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!timescale.empty())
|
||||||
|
vcdfile << stringf("$timescale %s $end\n", timescale.c_str());
|
||||||
|
|
||||||
int id = 1;
|
int id = 1;
|
||||||
top->write_vcd_header(vcdfile, id);
|
top->write_vcd_header(vcdfile, id);
|
||||||
|
|
||||||
|
@ -770,6 +784,9 @@ struct SimPass : public Pass {
|
||||||
log(" -zinit\n");
|
log(" -zinit\n");
|
||||||
log(" zero-initialize all uninitialized regs and memories\n");
|
log(" zero-initialize all uninitialized regs and memories\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
|
log(" -timescale <string>\n");
|
||||||
|
log(" include the specified timescale declaration in the vcd\n");
|
||||||
|
log("\n");
|
||||||
log(" -n <integer>\n");
|
log(" -n <integer>\n");
|
||||||
log(" number of cycles to simulate (default: 20)\n");
|
log(" number of cycles to simulate (default: 20)\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
|
@ -820,6 +837,10 @@ struct SimPass : public Pass {
|
||||||
worker.resetn.insert(RTLIL::escape_id(args[++argidx]));
|
worker.resetn.insert(RTLIL::escape_id(args[++argidx]));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (args[argidx] == "-timescale" && argidx+1 < args.size()) {
|
||||||
|
worker.timescale = args[++argidx];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (args[argidx] == "-a") {
|
if (args[argidx] == "-a") {
|
||||||
worker.hide_internal = false;
|
worker.hide_internal = false;
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue