[ENG-1794] Support for start/stop time in read_vcd Command#46
[ENG-1794] Support for start/stop time in read_vcd Command#46stanminlee wants to merge 33 commits intomainfrom
Conversation
Greptile SummaryThis PR adds
Confidence Score: 3/5Not safe to merge: the end_time clipping bug will silently produce wrong duty cycles for any real VCD where transitions occur after the specified end_time. Two P1 findings remain: (1) out-of-window incrCounts calls overwrite prev_value_, discarding the tail of the last high interval and causing incorrect duty cycle calculations; (2) static filter fields are fragile. The test suite passes only because the test VCD has no value changes after any tested end_time boundary. power/VcdReader.cc — specifically the incrCounts and highTime methods and the static VcdCount::filter_start_/filter_end_ members Important Files Changed
Reviews (2): Last reviewed commit: "ok this is a real fix" | Re-trigger Greptile |
|
@stanminlee can you address greptile and lmk when ready for review? |
|
@greptile review my pull request again |
| static void setFilter(VcdTime start, VcdTime end); | ||
|
|
||
| private: | ||
| VcdTime clippedIntervalStart() const; | ||
| PinSeq pins_; | ||
| VcdTime prev_time_; | ||
| char prev_value_; | ||
| VcdTime high_time_; | ||
| double transition_count_; | ||
|
|
||
| static VcdTime filter_start_; | ||
| static VcdTime filter_end_; | ||
| }; | ||
|
|
||
| // Define static members | ||
| VcdTime VcdCount::filter_start_ = -1; | ||
| VcdTime VcdCount::filter_end_ = -1; |
There was a problem hiding this comment.
Static filter fields make
VcdCount non-reentrant across read_vcd calls
filter_start_ and filter_end_ are static class members, so they are shared by every VcdCount instance in the entire process. setFilter() is called once per readActivities(), which is correct for a single sequential call, but introduces a latent issue: if read_vcd is ever invoked without a filter after a previous call that did set a filter, the statics retain the old window values until the next setFilter(). Since setFilter is always called at the top of readActivities() before parsing, this is currently safe — but only by convention. A future refactor that skips the no-filter case could silently re-apply the previous call's filter.
Consider making filter_start_ / filter_end_ instance members (non-static) and passing them via the constructor or a per-instance setFilter call.
Add -start_time and -stop_time arguments to read_vcd to only count transitions/signals from the specified timestamps.
To do this, we add support for start/stop time to be passed in to relevant functions (most of the changes are for this).