Add sim performance print
This commit is contained in:
parent
70d910e7d7
commit
11797fbb6e
|
@ -120,7 +120,7 @@ class success : public std::exception { };
|
||||||
|
|
||||||
class Workspace{
|
class Workspace{
|
||||||
public:
|
public:
|
||||||
|
static uint32_t cycles;
|
||||||
Memory mem;
|
Memory mem;
|
||||||
string name;
|
string name;
|
||||||
VVexRiscv* top;
|
VVexRiscv* top;
|
||||||
|
@ -215,6 +215,7 @@ public:
|
||||||
|
|
||||||
top->eval();
|
top->eval();
|
||||||
}
|
}
|
||||||
|
cycles += 1;
|
||||||
|
|
||||||
top->iRsp_inst = iRsp_inst_next;
|
top->iRsp_inst = iRsp_inst_next;
|
||||||
top->dRsp_data = dRsp_inst_next;
|
top->dRsp_data = dRsp_inst_next;
|
||||||
|
@ -238,6 +239,7 @@ public:
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
uint32_t Workspace::cycles = 0;
|
||||||
|
|
||||||
class TestA : public Workspace{
|
class TestA : public Workspace{
|
||||||
public:
|
public:
|
||||||
|
@ -341,10 +343,27 @@ string riscvTestMemory[] = {
|
||||||
// "rv32ui-p-remu.hex"]
|
// "rv32ui-p-remu.hex"]
|
||||||
|
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
struct timespec timer_start(){
|
||||||
|
struct timespec start_time;
|
||||||
|
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start_time);
|
||||||
|
return start_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
long timer_end(struct timespec start_time){
|
||||||
|
struct timespec end_time;
|
||||||
|
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end_time);
|
||||||
|
long diffInNanos = end_time.tv_nsec - start_time.tv_nsec;
|
||||||
|
return diffInNanos;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv, char **env) {
|
int main(int argc, char **argv, char **env) {
|
||||||
Verilated::randReset(2);
|
Verilated::randReset(2);
|
||||||
Verilated::commandArgs(argc, argv);
|
Verilated::commandArgs(argc, argv);
|
||||||
printf("BOOT\n");
|
printf("BOOT\n");
|
||||||
|
timespec startedAt = timer_start();
|
||||||
|
|
||||||
TestA().run();
|
TestA().run();
|
||||||
|
|
||||||
for(const string &name : riscvTestMain){
|
for(const string &name : riscvTestMain){
|
||||||
|
@ -353,6 +372,9 @@ int main(int argc, char **argv, char **env) {
|
||||||
for(const string &name : riscvTestMemory){
|
for(const string &name : riscvTestMemory){
|
||||||
RiscvTest(name).run();
|
RiscvTest(name).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long duration = timer_end(startedAt);
|
||||||
|
cout << "Had simulate " << Workspace::cycles << " clock cycles in " << duration*1e-9 << " s (" << Workspace::cycles / (duration*1e-9) << " Khz)" << endl;
|
||||||
printf("exit\n");
|
printf("exit\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ run: compile
|
||||||
./obj_dir/VVexRiscv
|
./obj_dir/VVexRiscv
|
||||||
|
|
||||||
verilate:
|
verilate:
|
||||||
verilator -cc ../../../../VexRiscv.v -CFLAGS -std=c++11 --gdbbt --trace -Wno-WIDTH --x-assign unique --exe main.cpp
|
verilator -cc ../../../../VexRiscv.v -O3 -CFLAGS -std=c++11 --gdbbt --trace -Wno-WIDTH --x-assign unique --exe main.cpp
|
||||||
|
|
||||||
compile: verilate
|
compile: verilate
|
||||||
make -j -C obj_dir/ -f VVexRiscv.mk VVexRiscv
|
make -j -C obj_dir/ -f VVexRiscv.mk VVexRiscv
|
||||||
|
|
Loading…
Reference in New Issue