From ce959ec1bb6c7ab9ac7e8273f8966a33b7fedb26 Mon Sep 17 00:00:00 2001 From: Stan Lee Date: Tue, 3 Feb 2026 12:42:33 -0800 Subject: [PATCH] fixes --- passes/sat/sim.cc | 51 +++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/passes/sat/sim.cc b/passes/sat/sim.cc index 34c94695f..d7b1c323e 100644 --- a/passes/sat/sim.cc +++ b/passes/sat/sim.cc @@ -2508,16 +2508,11 @@ struct AnnotateActivity : public OutputWriter { } } - // Retrieve VCD timescale - std::string timescale = worker->timescale; - double real_timescale = 1e-12; // ps - if (timescale == "ns") - real_timescale = 1e-9; - if (timescale == "fs") - real_timescale = 1e-15; - - // TODO: remove all debug sections when dev is completed - bool debug = false; + // Retrieve timescale from converted VCD file + double real_timescale = worker->fst->getTimescale(); + if (worker->debug) { + log_debug("Timescale %e seconds extracted from converted VCD file", real_timescale); + } // Compute clock period, find the highest toggling signal and compute its average period SignalActivityDataMap::iterator itr = dataMap.find(clk); @@ -2531,31 +2526,32 @@ struct AnnotateActivity : public OutputWriter { std::stringstream ss; ss << std::setprecision(4) << real_timescale; worker->top->module->set_string_attribute("$TIMESCALE", ss.str()); - if (debug) { - std::cout << "Clock toggle count: " << clktoggleCounts[0] << "\n"; - std::cout << "Max time: " << max_time << "\n"; - std::cout << "Clock period: " << clk_period << "\n"; - std::cout << "Frequency: " << frequency << "\n"; + if (worker->debug) { + log_debug("Clock toggle count: %f", clktoggleCounts[0]); + log_debug("Max time: %d", max_time); + log_debug("Clock period: %f", clk_period); + log_debug("Frequency: %f", frequency); } double totalActivity = 0.0f; double totalDuty = 0.0f; + + // TODO make this debug code less messy and more readable. worker->top->write_output_header( - [debug](IdString name) { - if (debug) - std::cout << stringf("module %s\n", log_id(name)); + [&](IdString name) { + if (worker->debug) + log_debug("module %s", log_id(name)); }, - [debug]() { - if (debug) - std::cout << "endmodule\n"; + [&]() { + if (worker->debug) + log_debug("endmodule"); }, - [&use_signal, &dataMap, max_time, real_timescale, clk_period, debug, &totalActivity, &totalDuty] - (const char *name, int size, Wire *w, int id, bool) { + [&](const char *name, int size, Wire *w, int id, bool) { if (!use_signal.at(id) || (w == nullptr)) return; SignalActivityDataMap::const_iterator itr = dataMap.find(id); const std::vector &toggleCounts = itr->second.toggleCounts; const std::vector &highTimes = itr->second.highTimes; - if (debug) { + if (worker->debug) { std::string full_name = form_vcd_name(name, size, w); std::cout << full_name << " " << id << ":\n"; std::cout << " TC: "; @@ -2581,7 +2577,7 @@ struct AnnotateActivity : public OutputWriter { totalActivity += activity; activity_str += std::to_string(activity) + " "; } - if (debug) { + if (worker->debug) { std::cout << activity_str; std::cout << "\n"; std::cout << " DUTY: "; @@ -2593,9 +2589,8 @@ struct AnnotateActivity : public OutputWriter { totalDuty += duty; duty_str += std::to_string(duty) + " "; } - if (debug) { - std::cout << duty_str; - std::cout << "\n"; + if (worker->debug) { + log_debug(" DUTY: %s", duty_str.c_str()); } w->set_string_attribute("$ACKT", activity_str); w->set_string_attribute("$DUTY", duty_str);