svf_jtag: add progressbar

This commit is contained in:
aisuneko icecat 2026-05-06 23:04:39 +08:00
parent 38acd7644c
commit f0e0f3a3f9
1 changed files with 13 additions and 1 deletions

View File

@ -18,6 +18,7 @@
#include <vector>
#include "jtag.hpp"
#include "progressBar.hpp"
void SVF_jtag::split_str(std::string const &str, std::vector<std::string> &vparse)
@ -379,6 +380,14 @@ void SVF_jtag::parse(std::string filename)
return;
}
unsigned int lineno = 0;
int lines_total = std::count(std::istreambuf_iterator<char>(fs),
std::istreambuf_iterator<char>(), '\n') + 1;
fs.clear();
fs.seekg(0,std::ios::beg);
printf("Reading %s with %d lines", filename.c_str(), lines_total);
ProgressBar progress("Writing SVF " + filename, lines_total, 50, _verbose);
try {
while (getline(fs, str)) {
if(str.empty()){
@ -409,13 +418,16 @@ void SVF_jtag::parse(std::string filename)
handle_instruction(vstr);
vstr.clear();
}
progress.display(lineno);
}
}
catch (std::exception &e)
{
std::cerr << "Cannot proceed because of error(s) at line " << lineno << std::endl;
std::cerr << "Cannot proceed because of error(s) at line " << std::dec << lineno << std::endl;
progress.fail();
throw;
}
progress.done();
std::cout << "end of SVF file" << std::endl;
}