3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-24 01:25:33 +00:00

Precision fix

This commit is contained in:
Alain Dargelas 2024-12-03 09:35:11 -08:00
parent f65d98a00d
commit fe684f5fd2

View file

@ -28,6 +28,8 @@
#include "kernel/fmt.h"
#include <ctime>
#include <sstream>
#include <iomanip>
USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN
@ -2542,8 +2544,9 @@ struct AnnotateActivity : public OutputWriter {
double frequency = 1.0 / clk_period;
worker->top->module->set_string_attribute("$FREQUENCY", std::to_string(frequency));
worker->top->module->set_string_attribute("$DURATION", std::to_string(max_time));
// Timescale is scaled by 1e12 so it can be retrieved (not 0) in Python due to precision limitation during conversion
worker->top->module->set_string_attribute("$TIMESCALE", std::to_string(real_timescale * 1e12));
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";