Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix accellera-official/fc4sc#20 #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/fir/src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void display::entry(){
<< " at time " << sc_time_stamp().to_double() << endl;

// generate the coverage database from the collected data
fc4sc::global::coverage_save("coverage_results.xml");
xml_printer::coverage_save("coverage_results.xml");
sc_stop();
};
}
Expand Down
23 changes: 21 additions & 2 deletions includes/fc4sc_coverpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class coverpoint final : public coverpoint_base
/*! Expression used to sample the data */
std::function<T()> sample_expression;

/*! Sample value resulted from evaluation of the sample_expression() function */
T sample_value_resulted;

/*!
* \brief Create a dynamic copy of this coverpoint with matching bin types
*/
Expand Down Expand Up @@ -550,13 +553,25 @@ class coverpoint final : public coverpoint_base
throw e;
}
if (cond) {
// 1) try to evaluate the sample_expression
try {
this->sample(sample_expression());
} catch(const std::exception& e) {
// sample_expression is a std::function which might throw an exception if it is not bound
sample_value_resulted = sample_expression();
}
catch(const std::exception& e) {
std::cerr << e.what() << "\n";
std::cerr << "sample_expression is not binded for coverpoint " << this->cvp_data->name << "\n";
throw e;
}
// 2) sample the value and catch any illegal bin value exception
try {
// sample call might throw an illegal_bin_sample_exception if an illegal_bin is hit
this->sample(sample_value_resulted);
}
catch(illegal_bin_sample_exception &e) {
e.update_cvp_info(this->name());
throw(e);
}
}
else {
// This is a fix so that crosses are not sampled if any of the coverpoints
Expand All @@ -566,6 +581,10 @@ class coverpoint final : public coverpoint_base
}
}
else {
// NOTE: This is the legacy implementation of the sampling logic
// (before the COVERPOINT macro was added).
// Eventually, it should be removed entirely, since it's obsolete and we
// don't want to have 2 APIs and implementations for the same functioality.
this->sample(*sample_point);
}
}
Expand Down