From 543feb75cb3765746ea865c11aa6ceccaf0adeac Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 31 Jan 2022 10:52:47 +0100 Subject: Display simulation time data --- kernel/fstdata.cc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'kernel/fstdata.cc') diff --git a/kernel/fstdata.cc b/kernel/fstdata.cc index 5d6d85ed8..a7a2c80f7 100644 --- a/kernel/fstdata.cc +++ b/kernel/fstdata.cc @@ -21,10 +21,30 @@ USING_YOSYS_NAMESPACE + FstData::FstData(std::string filename) : ctx(nullptr) { + const std::vector g_units = { "s", "ms", "us", "ns", "ps", "fs", "as", "zs" }; ctx = (fstReaderContext *)fstReaderOpen(filename.c_str()); - timescale = pow(10.0, (int)fstReaderGetTimescale(ctx)); + int scale = (int)fstReaderGetTimescale(ctx); + timescale = pow(10.0, scale); + timescale_str = ""; + int unit = 0; + int zeros = 0; + if (scale > 0) { + zeros = scale; + } else { + if ((scale % 3) == 0) { + zeros = (-scale % 3); + unit = (-scale / 3); + } else { + zeros = 3 - (-scale % 3); + unit = (-scale / 3) + 1; + } + } + for (int i=0;i0)timescale_str += " "; + timescale_str += g_units[unit]; extractVarNames(); } -- cgit v1.2.3