mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-22 22:03:40 +00:00
Added stdout flush and statistical info for debug
This commit is contained in:
parent
925741bf09
commit
5be70f436f
2 changed files with 28 additions and 6 deletions
|
@ -27,6 +27,7 @@ PRIVATE_NAMESPACE_BEGIN
|
||||||
struct ActivityProp {
|
struct ActivityProp {
|
||||||
Module *module;
|
Module *module;
|
||||||
SigMap sigmap;
|
SigMap sigmap;
|
||||||
|
uint32_t nbBitsWithActivity = 0;
|
||||||
|
|
||||||
// Split a string based on separator, returns a vector of tokens as reference argument
|
// Split a string based on separator, returns a vector of tokens as reference argument
|
||||||
// If skipEmpty is true, return "" for string " ", when separator is " "
|
// If skipEmpty is true, return "" for string " ", when separator is " "
|
||||||
|
@ -81,8 +82,10 @@ struct ActivityProp {
|
||||||
if (i < activities.size()) {
|
if (i < activities.size()) {
|
||||||
ActivityMap.emplace(bit, activities[i]);
|
ActivityMap.emplace(bit, activities[i]);
|
||||||
DutyMap.emplace(bit, duties[i]);
|
DutyMap.emplace(bit, duties[i]);
|
||||||
|
nbBitsWithActivity++;
|
||||||
} else {
|
} else {
|
||||||
log_warning("Zeroing out activity for module: %s, wire: %s, wiresize: %d, actisize: %ld", module->name.c_str(), wire->name.c_str(), GetSize(sig), activities.size());
|
log_warning("Zeroing out activity for module: %s, wire: %s, wire_size: %d, activ_size: %ld", module->name.c_str(),
|
||||||
|
wire->name.c_str(), GetSize(sig), activities.size());
|
||||||
ActivityMap.emplace(bit, "0.0");
|
ActivityMap.emplace(bit, "0.0");
|
||||||
DutyMap.emplace(bit, "0.0");
|
DutyMap.emplace(bit, "0.0");
|
||||||
}
|
}
|
||||||
|
@ -131,6 +134,8 @@ struct ActivityProp {
|
||||||
cell->set_string_attribute("$DUTY:", cell_ports_duty);
|
cell->set_string_attribute("$DUTY:", cell_ports_duty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t getNbBitsWithActivity() { return nbBitsWithActivity; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ActivityClear {
|
struct ActivityClear {
|
||||||
|
@ -168,10 +173,13 @@ struct ActivityPropPass : public Pass {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
extra_args(args, argidx, design);
|
extra_args(args, argidx, design);
|
||||||
|
uint32_t totalNbBitsWithActivity = 0;
|
||||||
for (auto module : design->modules()) {
|
for (auto module : design->modules()) {
|
||||||
ActivityProp worker(module);
|
ActivityProp worker(module);
|
||||||
|
totalNbBitsWithActivity += worker.getNbBitsWithActivity();
|
||||||
}
|
}
|
||||||
|
log("Collected %d bits with activity", totalNbBitsWithActivity);
|
||||||
|
log_flush();
|
||||||
}
|
}
|
||||||
} ActivityPropPass;
|
} ActivityPropPass;
|
||||||
|
|
||||||
|
|
|
@ -1576,7 +1576,7 @@ struct SimWorker : SimShared
|
||||||
} catch(fst_end_of_data_exception) {
|
} catch(fst_end_of_data_exception) {
|
||||||
// end of data detected
|
// end of data detected
|
||||||
}
|
}
|
||||||
|
log_flush();
|
||||||
write_output_files();
|
write_output_files();
|
||||||
delete fst;
|
delete fst;
|
||||||
}
|
}
|
||||||
|
@ -2414,6 +2414,7 @@ struct AnnotateActivity : public OutputWriter {
|
||||||
// Init map
|
// Init map
|
||||||
SignalActivityDataMap dataMap;
|
SignalActivityDataMap dataMap;
|
||||||
// For each event (new time when a value changed)
|
// For each event (new time when a value changed)
|
||||||
|
uint32_t nbTotalBits = 0;
|
||||||
for (auto &d : worker->output_data) {
|
for (auto &d : worker->output_data) {
|
||||||
// For each signal/values in that time slice
|
// For each signal/values in that time slice
|
||||||
for (auto &data : d.second) {
|
for (auto &data : d.second) {
|
||||||
|
@ -2425,6 +2426,7 @@ struct AnnotateActivity : public OutputWriter {
|
||||||
if (itr == dataMap.end()) {
|
if (itr == dataMap.end()) {
|
||||||
Const value = data.second;
|
Const value = data.second;
|
||||||
std::vector<uint64_t> vals(GetSize(value), 0);
|
std::vector<uint64_t> vals(GetSize(value), 0);
|
||||||
|
nbTotalBits += GetSize(value);
|
||||||
std::vector<double_t> dvals(GetSize(value), 0);
|
std::vector<double_t> dvals(GetSize(value), 0);
|
||||||
SignalActivityData data;
|
SignalActivityData data;
|
||||||
data.highTimes = vals;
|
data.highTimes = vals;
|
||||||
|
@ -2436,7 +2438,8 @@ struct AnnotateActivity : public OutputWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log("Computing signal activity for %ld signals (%d bits)", use_signal.size(), nbTotalBits);
|
||||||
|
log_flush();
|
||||||
// Max simulation time
|
// Max simulation time
|
||||||
int max_time = 0;
|
int max_time = 0;
|
||||||
// Inititalization of totalEventCounts and max_time
|
// Inititalization of totalEventCounts and max_time
|
||||||
|
@ -2544,6 +2547,8 @@ struct AnnotateActivity : public OutputWriter {
|
||||||
std::cout << "Clock period: " << clk_period << "\n";
|
std::cout << "Clock period: " << clk_period << "\n";
|
||||||
std::cout << "Frequency: " << frequency << "\n";
|
std::cout << "Frequency: " << frequency << "\n";
|
||||||
}
|
}
|
||||||
|
double totalActivity = 0.0f;
|
||||||
|
double totalDuty = 0.0f;
|
||||||
worker->top->write_output_header(
|
worker->top->write_output_header(
|
||||||
[this, debug](IdString name) {
|
[this, debug](IdString name) {
|
||||||
if (debug)
|
if (debug)
|
||||||
|
@ -2553,8 +2558,8 @@ struct AnnotateActivity : public OutputWriter {
|
||||||
if (debug)
|
if (debug)
|
||||||
std::cout << "endmodule\n";
|
std::cout << "endmodule\n";
|
||||||
},
|
},
|
||||||
[this, &use_signal, &dataMap, max_time, real_timescale, clk_period, debug](const char *name, int size, Wire *w, int id,
|
[this, &use_signal, &dataMap, max_time, real_timescale, clk_period, debug, &totalActivity, &totalDuty]
|
||||||
bool) {
|
(const char *name, int size, Wire *w, int id, bool) {
|
||||||
if (!use_signal.at(id) || (w == nullptr))
|
if (!use_signal.at(id) || (w == nullptr))
|
||||||
return;
|
return;
|
||||||
SignalActivityDataMap::const_iterator itr = dataMap.find(id);
|
SignalActivityDataMap::const_iterator itr = dataMap.find(id);
|
||||||
|
@ -2576,9 +2581,14 @@ struct AnnotateActivity : public OutputWriter {
|
||||||
std::cout << " ACK: ";
|
std::cout << " ACK: ";
|
||||||
}
|
}
|
||||||
std::string activity_str;
|
std::string activity_str;
|
||||||
|
if ((uint32_t) size != toggleCounts.size()) {
|
||||||
|
std::string full_name = form_vcd_name(name, size, w);
|
||||||
|
log_warning("Signal size/value mismatch for %s: %d vs %ld", full_name.c_str(), size, toggleCounts.size());
|
||||||
|
}
|
||||||
for (uint32_t i = 0; i < (uint32_t)size; i++) {
|
for (uint32_t i = 0; i < (uint32_t)size; i++) {
|
||||||
// Compute Activity
|
// Compute Activity
|
||||||
double activity = toggleCounts[i] / (((double)max_time * real_timescale / clk_period) * 2.0);
|
double activity = toggleCounts[i] / (((double)max_time * real_timescale / clk_period) * 2.0);
|
||||||
|
totalActivity += activity;
|
||||||
activity_str += std::to_string(activity) + " ";
|
activity_str += std::to_string(activity) + " ";
|
||||||
}
|
}
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
@ -2590,6 +2600,7 @@ struct AnnotateActivity : public OutputWriter {
|
||||||
for (uint32_t i = 0; i < (uint32_t)size; i++) {
|
for (uint32_t i = 0; i < (uint32_t)size; i++) {
|
||||||
// Compute Duty cycle
|
// Compute Duty cycle
|
||||||
double duty = (double)highTimes[i] / (double)max_time;
|
double duty = (double)highTimes[i] / (double)max_time;
|
||||||
|
totalDuty += duty;
|
||||||
duty_str += std::to_string(duty) + " ";
|
duty_str += std::to_string(duty) + " ";
|
||||||
}
|
}
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
@ -2599,6 +2610,9 @@ struct AnnotateActivity : public OutputWriter {
|
||||||
w->set_string_attribute("$ACKT", activity_str);
|
w->set_string_attribute("$ACKT", activity_str);
|
||||||
w->set_string_attribute("$DUTY", duty_str);
|
w->set_string_attribute("$DUTY", duty_str);
|
||||||
});
|
});
|
||||||
|
log("Average activity: %f\n", totalActivity / nbTotalBits);
|
||||||
|
log("Average duty : %f\n", totalDuty / nbTotalBits);
|
||||||
|
log_flush();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue