[engine] code format

This commit is contained in:
tangxifan 2022-12-30 18:17:19 -08:00
parent 492b8a153a
commit d329f0bb44
2 changed files with 67 additions and 65 deletions

View File

@ -18,19 +18,23 @@ void add_vpr_commands(openfpga::Shell<OpenfpgaContext>& shell) {
ShellCommandId shell_cmd_vpr_id =
shell.add_command(shell_cmd_vpr,
"Start VPR core engine to pack, place and route a BLIF "
"design on a FPGA architecture; Note that this command will keep VPR results!");
"design on a FPGA architecture; Note that this command "
"will keep VPR results!");
shell.set_command_class(shell_cmd_vpr_id, vpr_cmd_class);
shell.set_command_execute_function(shell_cmd_vpr_id, vpr::vpr_wrapper);
/* Create a macro command of 'vpr_standalone' which will call the main engine of vpr in a standalone way
/* Create a macro command of 'vpr_standalone' which will call the main engine
* of vpr in a standalone way
*/
Command shell_cmd_vpr_stdalone("vpr_standalone");
ShellCommandId shell_cmd_vpr_stdalone_id =
shell.add_command(shell_cmd_vpr,
"Start a standalone VPR core engine to pack, place and route a BLIF "
"design on a FPGA architecture; Note that this command will NOT keep VPR results!");
ShellCommandId shell_cmd_vpr_stdalone_id = shell.add_command(
shell_cmd_vpr,
"Start a standalone VPR core engine to pack, place and route a BLIF "
"design on a FPGA architecture; Note that this command will NOT keep VPR "
"results!");
shell.set_command_class(shell_cmd_vpr_stdalone_id, vpr_cmd_class);
shell.set_command_execute_function(shell_cmd_vpr_stdalone_id, vpr::vpr_standalone_wrapper);
shell.set_command_execute_function(shell_cmd_vpr_stdalone_id,
vpr::vpr_standalone_wrapper);
}
} /* end namespace openfpga */

View File

@ -8,6 +8,7 @@
#include <cstring>
#include <ctime>
#include "command_exit_codes.h"
#include "globals.h"
#include "tatum/error.hpp"
#include "vpr_api.h"
@ -19,7 +20,6 @@
#include "vtr_log.h"
#include "vtr_memory.h"
#include "vtr_time.h"
#include "command_exit_codes.h"
namespace vpr {
@ -36,8 +36,7 @@ namespace vpr {
* 3. Place-and-route and timing analysis
* 4. Clean up
*/
static
int vpr(int argc, char** argv) {
static int vpr(int argc, char** argv) {
vtr::ScopedFinishTimer t("The entire flow of VPR");
t_options Options = t_options();
@ -107,66 +106,66 @@ int vpr_wrapper(int argc, char** argv) {
/**
* VPR program with clean up
*/
static
int vpr_standalone(int argc, char** argv) {
vtr::ScopedFinishTimer t("The entire flow of VPR");
static int vpr_standalone(int argc, char** argv) {
vtr::ScopedFinishTimer t("The entire flow of VPR");
t_options Options = t_options();
t_arch Arch = t_arch();
t_vpr_setup vpr_setup = t_vpr_setup();
t_options Options = t_options();
t_arch Arch = t_arch();
t_vpr_setup vpr_setup = t_vpr_setup();
try {
vpr_install_signal_handler();
try {
vpr_install_signal_handler();
/* Read options, architecture, and circuit netlist */
vpr_init(argc, const_cast<const char**>(argv), &Options, &vpr_setup, &Arch);
/* Read options, architecture, and circuit netlist */
vpr_init(argc, const_cast<const char**>(argv), &Options, &vpr_setup, &Arch);
if (Options.show_version) {
vpr_free_all(Arch, vpr_setup);
return SUCCESS_EXIT_CODE;
}
bool flow_succeeded = vpr_flow(vpr_setup, Arch);
if (!flow_succeeded) {
VTR_LOG("VPR failed to implement circuit\n");
vpr_free_all(Arch, vpr_setup);
return UNIMPLEMENTABLE_EXIT_CODE;
}
auto& timing_ctx = g_vpr_ctx.timing();
print_timing_stats("Flow", timing_ctx.stats);
/* free data structures */
vpr_free_all(Arch, vpr_setup);
VTR_LOG("VPR succeeded\n");
} catch (const tatum::Error& tatum_error) {
VTR_LOG_ERROR("%s\n", format_tatum_error(tatum_error).c_str());
vpr_free_all(Arch, vpr_setup);
return ERROR_EXIT_CODE;
} catch (const VprError& vpr_error) {
vpr_print_error(vpr_error);
if (vpr_error.type() == VPR_ERROR_INTERRUPTED) {
vpr_free_all(Arch, vpr_setup);
return INTERRUPTED_EXIT_CODE;
} else {
vpr_free_all(Arch, vpr_setup);
return ERROR_EXIT_CODE;
}
} catch (const vtr::VtrError& vtr_error) {
VTR_LOG_ERROR("%s:%d %s\n", vtr_error.filename_c_str(), vtr_error.line(), vtr_error.what());
vpr_free_all(Arch, vpr_setup);
return ERROR_EXIT_CODE;
if (Options.show_version) {
vpr_free_all(Arch, vpr_setup);
return SUCCESS_EXIT_CODE;
}
/* Signal success to scripts */
return SUCCESS_EXIT_CODE;
bool flow_succeeded = vpr_flow(vpr_setup, Arch);
if (!flow_succeeded) {
VTR_LOG("VPR failed to implement circuit\n");
vpr_free_all(Arch, vpr_setup);
return UNIMPLEMENTABLE_EXIT_CODE;
}
auto& timing_ctx = g_vpr_ctx.timing();
print_timing_stats("Flow", timing_ctx.stats);
/* free data structures */
vpr_free_all(Arch, vpr_setup);
VTR_LOG("VPR succeeded\n");
} catch (const tatum::Error& tatum_error) {
VTR_LOG_ERROR("%s\n", format_tatum_error(tatum_error).c_str());
vpr_free_all(Arch, vpr_setup);
return ERROR_EXIT_CODE;
} catch (const VprError& vpr_error) {
vpr_print_error(vpr_error);
if (vpr_error.type() == VPR_ERROR_INTERRUPTED) {
vpr_free_all(Arch, vpr_setup);
return INTERRUPTED_EXIT_CODE;
} else {
vpr_free_all(Arch, vpr_setup);
return ERROR_EXIT_CODE;
}
} catch (const vtr::VtrError& vtr_error) {
VTR_LOG_ERROR("%s:%d %s\n", vtr_error.filename_c_str(), vtr_error.line(),
vtr_error.what());
vpr_free_all(Arch, vpr_setup);
return ERROR_EXIT_CODE;
}
/* Signal success to scripts */
return SUCCESS_EXIT_CODE;
}
/* A wrapper to return proper codes for openfpga shell */
@ -177,5 +176,4 @@ int vpr_standalone_wrapper(int argc, char** argv) {
return openfpga::CMD_EXEC_SUCCESS;
}
} /* End namespace vpr */