Skip to content

Commit

Permalink
Merge pull request #22 from andrewboutros/correctness-checks
Browse files Browse the repository at this point in the history
RAD-Sim Design Correctness Reporting
  • Loading branch information
andrewboutros authored Dec 1, 2023
2 parents fd857b9 + ec92d85 commit a239321
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 11 deletions.
2 changes: 1 addition & 1 deletion rad-sim/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 0;\n")
main_cpp_file.write("\treturn radsim_design.GetSimExitCode();\n")
main_cpp_file.write("}\n")

def prepare_build_dir(design_name):
Expand Down
8 changes: 6 additions & 2 deletions rad-sim/example-designs/add/add_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ void add_driver::sink() {
//std::cout << "Received " << response.read().to_uint64() << " sum from the adder!" << std::endl;
//std::cout << "The actual sum is " << actual_sum << std::endl;

if (response.read() != actual_sum) std::cout << "FAILURE - Output is not matching!" << std::endl;
else std::cout << "SUCCESS - Output is matching!" << std::endl;
if (response.read() != actual_sum) {
std::cout << "FAILURE - Output is not matching!" << std::endl;
radsim_design.ReportDesignFailure();
} else {
std::cout << "SUCCESS - Output is matching!" << std::endl;
}

end_cycle = GetSimulationCycle(radsim_config.GetDoubleKnob("sim_driver_period"));
end_time = std::chrono::steady_clock::now();
Expand Down
4 changes: 2 additions & 2 deletions rad-sim/example-designs/dlrm/dlrm_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ void dlrm_driver::sink() {
if (all_outputs_matching) {
std::cout << "Simulation PASSED! All outputs matching!" << std::endl;
} else {
std::cout << "Simulation FAILED! Some outputs are NOT matching!"
<< std::endl;
std::cout << "Simulation FAILED! Some outputs are NOT matching!" << std::endl;
radsim_design.ReportDesignFailure();
}
_end_cycle =
GetSimulationCycle(radsim_config.GetDoubleKnob("sim_driver_period"));
Expand Down
5 changes: 4 additions & 1 deletion rad-sim/example-designs/mlp/mlp_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ void mlp_driver::sink() {
}
wait();
}
if (mistake) std::cout << "FAILURE - Some outputs NOT matching!" << std::endl;
if (mistake) {
std::cout << "FAILURE - Some outputs NOT matching!" << std::endl;
radsim_design.ReportDesignFailure();
}
else std::cout << "SUCCESS - All outputs are matching!" << std::endl;

end_cycle = GetSimulationCycle(radsim_config.GetDoubleKnob("sim_driver_period"));
Expand Down
9 changes: 7 additions & 2 deletions rad-sim/example-designs/mlp_int8/mlp_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,19 @@ void mlp_driver::sink() {
}
wait();
}
if (mistake) std::cout << "FAILURE - Some outputs NOT matching!" << std::endl;
else std::cout << "SUCCESS - All outputs are matching!" << std::endl;
if (mistake) {
std::cout << "FAILURE - Some outputs NOT matching!" << std::endl;
radsim_design.ReportDesignFailure();
} else {
std::cout << "SUCCESS - All outputs are matching!" << std::endl;
}

end_cycle = GetSimulationCycle(radsim_config.GetDoubleKnob("sim_driver_period"));
end_time = std::chrono::steady_clock::now();
std::cout << "Simulation Cycles = " << end_cycle - start_cycle << std::endl;
std::cout << "Simulation Time = " << std::chrono::duration_cast<std::chrono::milliseconds> (end_time - start_time).count() << " ms" << std::endl;
NoCTransactionTelemetry::DumpStatsToFile("stats.csv");
NoCFlitTelemetry::DumpNoCFlitTracesToFile("flit_traces.csv");

std::vector<double> aggregate_bandwidths = NoCTransactionTelemetry::DumpTrafficFlows("traffic_flows",
end_cycle - start_cycle, radsim_design.GetNodeModuleNames());
Expand Down
8 changes: 6 additions & 2 deletions rad-sim/example-designs/rtl_add/rtl_add_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ void rtl_add_driver::sink() {
//std::cout << "Received " << response.read().to_uint64() << " sum from the adder!" << std::endl;
//std::cout << "The actual sum is " << actual_sum << std::endl;

if (response.read() != actual_sum) std::cout << "FAILURE - Output is not matching!" << std::endl;
else std::cout << "SUCCESS - Output is matching!" << std::endl;
if (response.read() != actual_sum) {
std::cout << "FAILURE - Output is not matching!" << std::endl;
radsim_design.ReportDesignFailure();
} else {
std::cout << "SUCCESS - Output is matching!" << std::endl;
}

end_cycle = GetSimulationCycle(radsim_config.GetDoubleKnob("sim_driver_period"));
end_time = std::chrono::steady_clock::now();
Expand Down
8 changes: 8 additions & 0 deletions rad-sim/sim/design_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::GetSimExitCode() {
return _sim_exit_code;
}

void RADSimDesignContext::ReportDesignFailure() {
_sim_exit_code = 1;
}
5 changes: 5 additions & 0 deletions rad-sim/sim/design_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

class RADSimDesignContext {
private:
int _sim_exit_code = 0;

std::vector<sc_clock *> _noc_clks;
std::vector<sc_clock *> _adapter_clks;
std::vector<sc_clock *> _module_clks;
Expand Down Expand Up @@ -96,6 +98,9 @@ class RADSimDesignContext {
void DumpDesignContext();
std::vector<std::vector<std::set<std::string>>> &GetNodeModuleNames();
uint64_t GetPortBaseAddress(std::string &port_name);

int GetSimExitCode();
void ReportDesignFailure();
};

extern RADSimDesignContext radsim_design;
2 changes: 1 addition & 1 deletion rad-sim/sim/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ int sc_main(int argc, char *argv[]) {
sim_trace_probe.dump_traces();
(void)argc;
(void)argv;
return 0;
return radsim_design.GetSimExitCode();
}

0 comments on commit a239321

Please sign in to comment.