diff --git a/doc/OpenSTA.odt b/doc/OpenSTA.odt index 12cbd1cc..a6c9a62d 100644 Binary files a/doc/OpenSTA.odt and b/doc/OpenSTA.odt differ diff --git a/power/Power.i b/power/Power.i index 7202ea38..002598f5 100644 --- a/power/Power.i +++ b/power/Power.i @@ -110,9 +110,10 @@ set_power_pin_activity(const Pin *pin, } void -read_vcd_activities(const char *filename) +read_vcd_activities(const char *filename, + const char *scope) { - readVcdActivities(filename, Sta::sta()); + readVcdActivities(filename, scope, Sta::sta()); } void diff --git a/power/Power.tcl b/power/Power.tcl index d680b48f..2b8e3a01 100644 --- a/power/Power.tcl +++ b/power/Power.tcl @@ -251,15 +251,19 @@ proc set_power_activity { args } { ################################################################ -define_cmd_args "read_power_activities" { -vcd filename } +define_cmd_args "read_power_activities" { [-scope scope] -vcd filename } proc read_power_activities { args } { parse_key_args "read_power_activities" args \ - keys {} flags {-vcd} + keys {-scope} flags {-vcd} check_argc_eq1 "set_power_activity" $args set filename [file nativename [lindex $args 0]] - read_vcd_activities $filename + set scope "" + if { [info exists keys(-scope)] } { + set scope $keys(-scope) + } + read_vcd_activities $filename $scope } ################################################################ diff --git a/power/ReadVcdActivities.cc b/power/ReadVcdActivities.cc index 27fac3a9..87544a3d 100644 --- a/power/ReadVcdActivities.cc +++ b/power/ReadVcdActivities.cc @@ -33,6 +33,7 @@ using std::to_string; static void setVcdActivities(Vcd &vcd, + const char *scope, Sta *sta); static void findVarActivity(const char *pin_name, @@ -48,14 +49,16 @@ findVarActivity(const char *pin_name, void readVcdActivities(const char *filename, + const char *scope, Sta *sta) { Vcd vcd = readVcdFile(filename, sta); - setVcdActivities(vcd, sta); + setVcdActivities(vcd, scope, sta); } static void setVcdActivities(Vcd &vcd, + const char *scope, Sta *sta) { Debug *debug = sta->debug(); @@ -63,13 +66,20 @@ setVcdActivities(Vcd &vcd, Power *power = sta->power(); float clk_period = INF; + size_t scope_length = strlen(scope); for (Clock *clk : *sta->sdc()->clocks()) clk_period = min(clk->period(), clk_period); for (VcdVar &var : vcd.vars()) { const VcdValues &var_values = vcd.values(var); - if (!var_values.empty()) { + if (!var_values.empty() + && (var.type() == VcdVarType::wire + || var.type() == VcdVarType::reg)) { string var_name = var.name(); + // string::starts_with in c++20 + if (scope_length + && var_name.substr(0, scope_length) == scope) + var_name = var_name.substr(scope_length + 1); if (var_name[0] == '\\') var_name += ' '; const char *sta_name = verilogToSta(var_name.c_str()); diff --git a/power/ReadVcdActivities.hh b/power/ReadVcdActivities.hh index e79f5cf4..d1bfa60d 100644 --- a/power/ReadVcdActivities.hh +++ b/power/ReadVcdActivities.hh @@ -22,6 +22,7 @@ class Sta; void readVcdActivities(const char *filename, + const char *scope, Sta *sta); } // namespace diff --git a/power/VcdReader.cc b/power/VcdReader.cc index a7935ee4..35d833b3 100644 --- a/power/VcdReader.cc +++ b/power/VcdReader.cc @@ -183,16 +183,9 @@ VcdReader::parseVar() string id = tokens[2]; string name; - int level = 0; for (string &context : scope_) { - // Skip the first 2 levels of scope. - // -test bench module - // -design instance - if (level > 1) { - name += context; - name += '/'; - } - level++; + name += context; + name += '/'; } name += tokens[3]; // iverilog separates bus base name from bit range.