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

RAD-Sim Design Correctness Reporting #22

Merged
merged 5 commits into from
Dec 1, 2023
Merged

Conversation

geotrieu
Copy link
Collaborator

@geotrieu geotrieu commented Nov 28, 2023

Introduces the ReportDesignFailure() function in the RAD-Sim Design Context to report a design failure (i.e. when the design fails the test bench).
This is an optional call, if the function is not called, success is assumed and the original behaviour is preserved.
The design failure is returned as an exit code from the sc_main function.

This PR is a branch of the dev-gtrieu branch to observe the correct diffs. Please merge #21 before this, and change the base to main.

@@ -688,4 +688,12 @@ uint64_t RADSimDesignContext::GetPortBaseAddress(std::string &port_name) {
assert(_aximm_port_base_addresses.find(port_name) !=
_aximm_port_base_addresses.end());
return _aximm_port_base_addresses[port_name];
}

int RADSimDesignContext::GetDesignResult() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name _design_result might not be very intuitive. If this is meant to only report the success and failure of the simulation, we should name it something like _sim_exit_code (0 is success and 1 is failure).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, will change

@@ -12,6 +12,8 @@

class RADSimDesignContext {
private:
int _design_result = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about the name. I think you should also write a comment to explain what this variable is and what different values mean (0 is success and 1 is failure, maybe other outcomes can be added later if needed).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is design_result the number of failures? If so, better to rename it. If it can only be one or zero, better to make it a bool.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can imagine other exit codes than just 0 or 1 to report different failure reasons (e.g. simulation timeout after some number of cycles). Not sure though. That's why my earlier comment suggested renaming to _sim_exit_code and commenting what each code means.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this initially and had it as bool. But I came to the same conclusion as Andrew, yes - the exit code could be anything. Right now, we have it only as 0 or 1, thus there is a specific function to report a failure instead of a general function to set a result. It wouldn't be hard to add that functionality in the future if we wanted to report other exit codes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is design_result the number of failures? If so, better to rename it. If it can only be one or zero, better to make it a bool.

It is not the number of failures, it is just the exit code. However, it could be any signed integer, so it could represent something down the line.

@@ -294,7 +294,7 @@ def generate_radsim_main(design_name):
main_cpp_file.write("\tsim_trace_probe.dump_traces();\n")
main_cpp_file.write("\t(void)argc;\n")
main_cpp_file.write("\t(void)argv;\n")
main_cpp_file.write("\treturn radsim_design.GetDesignResult();\n")
main_cpp_file.write("\treturn radsim_design.GetDesignExitCode();\n")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't we naming this function GetSimExitCode instead of GetDesignExitCode?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@geotrieu geotrieu changed the base branch from dev-gtrieu to main December 1, 2023 16:54
@andrewboutros andrewboutros merged commit a239321 into main Dec 1, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants