[lib] add verbose output option to fabric key assistant
This commit is contained in:
parent
cfaae55bda
commit
97619fc545
|
@ -31,7 +31,7 @@ static std::vector<std::string> format_argv(const std::string& cmd_name,
|
|||
* - Each alias of reference key can be found in the input key
|
||||
*/
|
||||
static int check_input_and_ref_key_alias_match(
|
||||
const openfpga::FabricKey& input_key, const openfpga::FabricKey& ref_key) {
|
||||
const openfpga::FabricKey& input_key, const openfpga::FabricKey& ref_key, const bool& verbose) {
|
||||
size_t num_errors = 0;
|
||||
size_t num_keys_checked = 0;
|
||||
float progress = 0.;
|
||||
|
@ -44,7 +44,7 @@ static int check_input_and_ref_key_alias_match(
|
|||
input_key.find_key_by_alias(curr_alias);
|
||||
progress = static_cast<float>(num_keys_checked) /
|
||||
static_cast<float>(ref_key.num_keys()) * 100.0;
|
||||
VTR_LOG("[%lu%] Checking key alias '%s'\r", size_t(progress),
|
||||
VTR_LOGV(verbose, "[%lu%] Checking key alias '%s'\r", size_t(progress),
|
||||
curr_alias.c_str());
|
||||
if (input_found_keys.empty()) {
|
||||
VTR_LOG_ERROR(
|
||||
|
@ -74,7 +74,8 @@ static int check_input_and_ref_key_alias_match(
|
|||
* - Number of keys match
|
||||
*/
|
||||
static int check_input_key(const openfpga::FabricKey& input_key,
|
||||
const openfpga::FabricKey& ref_key) {
|
||||
const openfpga::FabricKey& ref_key,
|
||||
const bool& verbose) {
|
||||
if (ref_key.num_regions() != input_key.num_regions()) {
|
||||
VTR_LOG_ERROR(
|
||||
"Different number of configuration regions between reference key "
|
||||
|
@ -92,20 +93,20 @@ static int check_input_key(const openfpga::FabricKey& input_key,
|
|||
size_t num_errors = 0;
|
||||
size_t curr_num_err = 0;
|
||||
VTR_LOG("Checking key alias in reference key...\n");
|
||||
curr_num_err = openfpga::check_fabric_key_alias(ref_key, true);
|
||||
curr_num_err = openfpga::check_fabric_key_alias(ref_key, verbose);
|
||||
VTR_LOG("Checking key alias in reference key... %s\n",
|
||||
curr_num_err ? "[Fail]" : "[Pass]");
|
||||
VTR_LOG("Checking key names and values in reference key...\n");
|
||||
curr_num_err = openfpga::check_fabric_key_names_and_values(ref_key, true);
|
||||
curr_num_err = openfpga::check_fabric_key_names_and_values(ref_key, verbose);
|
||||
num_errors += curr_num_err;
|
||||
VTR_LOG("Checking key names and valus in reference key... %s\n",
|
||||
curr_num_err ? "[Fail]" : "[Pass]");
|
||||
VTR_LOG("Checking key alias in input key...\n");
|
||||
curr_num_err = openfpga::check_fabric_key_alias(input_key, true);
|
||||
curr_num_err = openfpga::check_fabric_key_alias(input_key, verbose);
|
||||
num_errors += curr_num_err;
|
||||
VTR_LOG("Checking key alias in input key... %s\n",
|
||||
curr_num_err ? "[Fail]" : "[Pass]");
|
||||
num_errors += check_input_and_ref_key_alias_match(input_key, ref_key);
|
||||
num_errors += check_input_and_ref_key_alias_match(input_key, ref_key, verbose);
|
||||
return num_errors ? openfpga::CMD_EXEC_FATAL_ERROR
|
||||
: openfpga::CMD_EXEC_SUCCESS;
|
||||
}
|
||||
|
@ -116,7 +117,8 @@ static int check_input_key(const openfpga::FabricKey& input_key,
|
|||
* the reference key
|
||||
*/
|
||||
static int update_input_key(openfpga::FabricKey& input_key,
|
||||
const openfpga::FabricKey& ref_key) {
|
||||
const openfpga::FabricKey& ref_key,
|
||||
const bool& verbose) {
|
||||
size_t num_errors = 0;
|
||||
size_t num_keys_checked = 0;
|
||||
float progress = 0.;
|
||||
|
@ -128,7 +130,7 @@ static int update_input_key(openfpga::FabricKey& input_key,
|
|||
ref_key.find_key_by_alias(curr_alias);
|
||||
progress = static_cast<float>(num_keys_checked) /
|
||||
static_cast<float>(input_key.num_keys()) * 100.0;
|
||||
VTR_LOG("[%lu%] Pairing key alias '%s'\r", size_t(progress),
|
||||
VTR_LOGV(verbose, "[%lu%] Pairing key alias '%s'\r", size_t(progress),
|
||||
curr_alias.c_str());
|
||||
if (ref_found_keys.empty()) {
|
||||
VTR_LOG_ERROR(
|
||||
|
@ -147,7 +149,7 @@ static int update_input_key(openfpga::FabricKey& input_key,
|
|||
/* Now we have a key, get the name and value, and update input key */
|
||||
input_key.set_key_name(key_id, ref_key.key_name(ref_found_keys[0]));
|
||||
input_key.set_key_value(key_id, ref_key.key_value(ref_found_keys[0]));
|
||||
VTR_LOG("[%lu%] Pairing key alias '%s' -> ('%s', %lu)\r", size_t(progress),
|
||||
VTR_LOGV(verbose, "[%lu%] Pairing key alias '%s' -> ('%s', %lu)\r", size_t(progress),
|
||||
curr_alias.c_str(), input_key.key_name(key_id).c_str(),
|
||||
input_key.key_value(key_id));
|
||||
num_keys_checked++;
|
||||
|
@ -162,13 +164,14 @@ static int update_input_key(openfpga::FabricKey& input_key,
|
|||
* - Each alias can be found in the reference key
|
||||
*/
|
||||
static int check_and_update_input_key(openfpga::FabricKey& input_key,
|
||||
const openfpga::FabricKey& ref_key) {
|
||||
const openfpga::FabricKey& ref_key,
|
||||
const bool& verbose) {
|
||||
int status = openfpga::CMD_EXEC_SUCCESS;
|
||||
status = check_input_key(input_key, ref_key);
|
||||
status = check_input_key(input_key, ref_key, verbose);
|
||||
if (status != openfpga::CMD_EXEC_SUCCESS) {
|
||||
return openfpga::CMD_EXEC_FATAL_ERROR;
|
||||
}
|
||||
return update_input_key(input_key, ref_key);
|
||||
return update_input_key(input_key, ref_key, verbose);
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
|
@ -184,6 +187,8 @@ int main(int argc, const char** argv) {
|
|||
openfpga::CommandOptionId opt_output = cmd.add_option(
|
||||
"output", true, "Specify the final fabric key file to be outputted");
|
||||
cmd.set_option_require_value(opt_output, openfpga::OPT_STRING);
|
||||
openfpga::CommandOptionId opt_verbose =
|
||||
cmd.add_option("verbose", false, "Show verbose outputs");
|
||||
openfpga::CommandOptionId opt_help =
|
||||
cmd.add_option("help", false, "Show help desk");
|
||||
|
||||
|
@ -214,7 +219,7 @@ int main(int argc, const char** argv) {
|
|||
openfpga::read_xml_fabric_key(cmd_ctx.option_value(cmd, opt_input).c_str());
|
||||
|
||||
/* Check the input key */
|
||||
if (check_and_update_input_key(input_key, ref_key)) {
|
||||
if (check_and_update_input_key(input_key, ref_key, cmd_ctx.option_enable(cmd, opt_verbose))) {
|
||||
return openfpga::CMD_EXEC_FATAL_ERROR;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue