From 6a54922044d96f601b5240ef9098ed67821499c1 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Sun, 19 Apr 2020 13:47:22 +0100 Subject: [PATCH] Set FST timescale correctly. (#2266) The FST trace timescale used to be set in the constructor via set_time_unit, but at that point we haven't normally opened the file yet so it was just dropped. On top of that, we actually want to use set_time_resolution... FST trace timescales now match the VCD. --- include/verilated_fst_c.cpp | 1 + include/verilated_fst_c.h | 8 +++++--- test_regress/t/t_interface_ref_trace_fst.out | 4 ++-- test_regress/t/t_trace_array_fst.out | 4 ++-- test_regress/t/t_trace_complex_fst.out | 4 ++-- test_regress/t/t_trace_complex_params_fst.out | 4 ++-- test_regress/t/t_trace_complex_structs_fst.out | 4 ++-- test_regress/t/t_trace_fst.out | 4 ++-- test_regress/t/t_trace_packed_struct_fst.out | 4 ++-- test_regress/t/t_trace_two_dumpfst_cc.out | 4 ++-- test_regress/t/t_trace_two_hdrfst_cc.out | 4 ++-- test_regress/t/t_trace_two_portfst_cc.out | 4 ++-- 12 files changed, 26 insertions(+), 23 deletions(-) diff --git a/include/verilated_fst_c.cpp b/include/verilated_fst_c.cpp index 68f7becf4..7f4a763bc 100644 --- a/include/verilated_fst_c.cpp +++ b/include/verilated_fst_c.cpp @@ -100,6 +100,7 @@ void VerilatedFst::open(const char* filename) VL_MT_UNSAFE { m_assertOne.check(); m_fst = fstWriterCreate(filename, 1); fstWriterSetPackType(m_fst, FST_WR_PT_LZ4); + fstWriterSetTimescaleFromString(m_fst, m_timeRes.c_str()); #ifdef VL_TRACE_THREADED fstWriterSetParallelMode(m_fst, 1); #endif diff --git a/include/verilated_fst_c.h b/include/verilated_fst_c.h index ed41eb031..b59b90a5b 100644 --- a/include/verilated_fst_c.h +++ b/include/verilated_fst_c.h @@ -65,6 +65,8 @@ private: // helpers std::vector m_valueStrBuffer; + std::string m_timeRes; + public: explicit VerilatedFst(void* fst = NULL); ~VerilatedFst(); @@ -77,11 +79,11 @@ public: fstWriterClose(m_fst); m_fst = NULL; } - void set_time_unit(const char* unitp) { fstWriterSetTimescaleFromString(m_fst, unitp); } + void set_time_unit(const char*) {} void set_time_unit(const std::string& unit) { set_time_unit(unit.c_str()); } - void set_time_resolution(const char*) {} - void set_time_resolution(const std::string& unit) { set_time_resolution(unit.c_str()); } + void set_time_resolution(const char* unitp) { m_timeRes = unitp; } + void set_time_resolution(const std::string& unit) { m_timeRes = unit; } // double timescaleToDouble(const char* unitp); // std::string doubleToTimescale(double value); diff --git a/test_regress/t/t_interface_ref_trace_fst.out b/test_regress/t/t_interface_ref_trace_fst.out index 0c3b36d2d..7ccec6303 100644 --- a/test_regress/t/t_interface_ref_trace_fst.out +++ b/test_regress/t/t_interface_ref_trace_fst.out @@ -1,12 +1,12 @@ $date - Wed Dec 4 07:48:29 2019 + Sun Apr 19 04:13:22 2020 $end $version fstWriter $end $timescale - 1ns + 1ps $end $scope module top $end $var wire 1 ! clk $end diff --git a/test_regress/t/t_trace_array_fst.out b/test_regress/t/t_trace_array_fst.out index 4bfede89b..52b55a782 100644 --- a/test_regress/t/t_trace_array_fst.out +++ b/test_regress/t/t_trace_array_fst.out @@ -1,12 +1,12 @@ $date - Sun Oct 21 21:57:08 2018 + Sun Apr 19 04:15:23 2020 $end $version fstWriter $end $timescale - 1ns + 1ps $end $scope module top $end $var wire 1 ! clk $end diff --git a/test_regress/t/t_trace_complex_fst.out b/test_regress/t/t_trace_complex_fst.out index 7ceb73591..8b05384c7 100644 --- a/test_regress/t/t_trace_complex_fst.out +++ b/test_regress/t/t_trace_complex_fst.out @@ -1,12 +1,12 @@ $date - Sun Apr 12 20:15:55 2020 + Sun Apr 19 04:15:26 2020 $end $version fstWriter $end $timescale - 1ns + 1ps $end $scope module top $end $var wire 1 ! clk $end diff --git a/test_regress/t/t_trace_complex_params_fst.out b/test_regress/t/t_trace_complex_params_fst.out index 63f837f52..c94200384 100644 --- a/test_regress/t/t_trace_complex_params_fst.out +++ b/test_regress/t/t_trace_complex_params_fst.out @@ -1,12 +1,12 @@ $date - Sun Apr 12 20:17:15 2020 + Sun Apr 19 04:15:31 2020 $end $version fstWriter $end $timescale - 1ns + 1ps $end $scope module top $end $var wire 1 ! clk $end diff --git a/test_regress/t/t_trace_complex_structs_fst.out b/test_regress/t/t_trace_complex_structs_fst.out index 8319f05a6..1cde8a16c 100644 --- a/test_regress/t/t_trace_complex_structs_fst.out +++ b/test_regress/t/t_trace_complex_structs_fst.out @@ -1,12 +1,12 @@ $date - Sun Apr 12 20:14:19 2020 + Sun Apr 19 04:15:33 2020 $end $version fstWriter $end $timescale - 1ns + 1ps $end $scope module top $end $var wire 1 ! clk $end diff --git a/test_regress/t/t_trace_fst.out b/test_regress/t/t_trace_fst.out index 0a3805543..dde4f07e0 100644 --- a/test_regress/t/t_trace_fst.out +++ b/test_regress/t/t_trace_fst.out @@ -1,12 +1,12 @@ $date - Sun Apr 12 20:17:58 2020 + Sun Apr 19 04:15:36 2020 $end $version fstWriter $end $timescale - 1ns + 1ps $end $scope module top $end $var wire 1 ! clk $end diff --git a/test_regress/t/t_trace_packed_struct_fst.out b/test_regress/t/t_trace_packed_struct_fst.out index 6335f7b24..ac5cfac00 100644 --- a/test_regress/t/t_trace_packed_struct_fst.out +++ b/test_regress/t/t_trace_packed_struct_fst.out @@ -1,12 +1,12 @@ $date - Sun Apr 12 20:19:35 2020 + Sun Apr 19 04:15:38 2020 $end $version fstWriter $end $timescale - 1ns + 1ps $end $scope module top $end $var wire 1 ! clk $end diff --git a/test_regress/t/t_trace_two_dumpfst_cc.out b/test_regress/t/t_trace_two_dumpfst_cc.out index 70134be06..c22d2b128 100755 --- a/test_regress/t/t_trace_two_dumpfst_cc.out +++ b/test_regress/t/t_trace_two_dumpfst_cc.out @@ -1,12 +1,12 @@ $date - Sat Apr 18 22:18:21 2020 + Sun Apr 19 04:15:48 2020 $end $version fstWriter $end $timescale - 1ns + 1ps $end $scope module topa $end $var wire 1 ! clk $end diff --git a/test_regress/t/t_trace_two_hdrfst_cc.out b/test_regress/t/t_trace_two_hdrfst_cc.out index 52aefd9cc..538f5e7e6 100755 --- a/test_regress/t/t_trace_two_hdrfst_cc.out +++ b/test_regress/t/t_trace_two_hdrfst_cc.out @@ -1,12 +1,12 @@ $date - Sat Mar 7 18:27:58 2020 + Sun Apr 19 04:15:51 2020 $end $version fstWriter $end $timescale - 1ns + 1ps $end $scope module topa $end $var wire 1 ! clk $end diff --git a/test_regress/t/t_trace_two_portfst_cc.out b/test_regress/t/t_trace_two_portfst_cc.out index cb4a741f0..a8a068954 100755 --- a/test_regress/t/t_trace_two_portfst_cc.out +++ b/test_regress/t/t_trace_two_portfst_cc.out @@ -1,12 +1,12 @@ $date - Sat Apr 18 22:19:21 2020 + Sun Apr 19 04:13:00 2020 $end $version fstWriter $end $timescale - 1ns + 1ps $end $scope module topa $end $var wire 1 ! clk $end