mirror of
https://github.com/openhwgroup/cva5.git
synced 2025-04-20 03:57:18 -04:00
verilator optional PC trace support
Signed-off-by: Eric Matthews <ematthew@sfu.ca>
This commit is contained in:
parent
bae3594995
commit
1ffbacbb51
3 changed files with 29 additions and 7 deletions
|
@ -112,7 +112,10 @@ void CVA5Tracer::reset() {
|
|||
void CVA5Tracer::set_log_file(std::ofstream* logFile) {
|
||||
this->logFile = logFile;
|
||||
}
|
||||
|
||||
void CVA5Tracer::set_pc_file(std::ofstream* pcFile) {
|
||||
this->pcFile = pcFile;
|
||||
logPC = true;
|
||||
}
|
||||
|
||||
void CVA5Tracer::update_UART() {
|
||||
if (tb->write_uart) {
|
||||
|
@ -151,7 +154,6 @@ void CVA5Tracer::tick() {
|
|||
verilatorWaveformTracer->dump(vluint32_t(cycle_count));
|
||||
#endif
|
||||
|
||||
|
||||
if (check_if_instruction_retired(BENCHMARK_START_COLLECTION_NOP)) {
|
||||
reset_stats();
|
||||
collect_stats = true;
|
||||
|
@ -170,6 +172,15 @@ void CVA5Tracer::tick() {
|
|||
update_stats();
|
||||
update_UART();
|
||||
update_memory();
|
||||
|
||||
#ifdef TRACE_ON
|
||||
for (int i =0; i < tb->NUM_RETIRE_PORTS; i++) {
|
||||
if (logPC && tb->retire_ports_valid[i]) {
|
||||
*pcFile << std::hex << tb->retire_ports_pc[i] << std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ public:
|
|||
void tick();
|
||||
|
||||
void set_log_file(std::ofstream* logFile);
|
||||
void set_pc_file(std::ofstream* pcFile);
|
||||
void start_tracer(const char *trace_file);
|
||||
uint64_t get_cycle_count();
|
||||
|
||||
|
@ -99,6 +100,9 @@ private:
|
|||
VerilatedVcdC *verilatorWaveformTracer;
|
||||
#endif
|
||||
std::ofstream* logFile;
|
||||
std::ofstream* pcFile;
|
||||
bool logPC = false;
|
||||
|
||||
int reset_length = 64;
|
||||
int stall_limit = 2000;
|
||||
int stall_count = 0;
|
||||
|
|
|
@ -16,7 +16,7 @@ CVA5Tracer *cva5Tracer;
|
|||
//#define TRACE_ON
|
||||
using namespace std;
|
||||
int main(int argc, char **argv) {
|
||||
ofstream logFile, sigFile;
|
||||
ofstream logFile, sigFile, pcFile;
|
||||
ifstream programFile;
|
||||
|
||||
// Initialize Verilators variables
|
||||
|
@ -42,6 +42,8 @@ int main(int argc, char **argv) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
logFile.open (argv[1]);
|
||||
sigFile.open (argv[2]);
|
||||
//printf("HW INIT:%s \n", argv[3]);
|
||||
|
@ -55,14 +57,18 @@ int main(int argc, char **argv) {
|
|||
cout << "Failed to open sigFile: " << argv[2] << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (!programFile.is_open()) {
|
||||
cout << "Failed to open programFile: " << argv[3] << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Create an instance of our module under test
|
||||
cva5Tracer = new CVA5Tracer(programFile);
|
||||
cva5Tracer->set_log_file(&logFile);
|
||||
|
||||
if (argv[5]) {
|
||||
pcFile.open (argv[5]);
|
||||
}
|
||||
if (pcFile.is_open()) {
|
||||
cva5Tracer->set_pc_file(&pcFile);
|
||||
}
|
||||
|
||||
#ifdef TRACE_ON
|
||||
cva5Tracer->start_tracer(argv[4]);
|
||||
#endif
|
||||
|
@ -93,6 +99,7 @@ int main(int argc, char **argv) {
|
|||
logFile.close();
|
||||
sigFile.close();
|
||||
programFile.close();
|
||||
pcFile.close();
|
||||
|
||||
delete cva5Tracer;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue