File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ class Emulator
1818 parseArgs (argc, argv);
1919
2020 if (args.image == nullptr )
21- throw " Image file unspecified. Use -i to provide the image of flash" ;
21+ {
22+ printf (" Image file unspecified. Use -i to provide the image of flash" );
23+ exit (1 );
24+ }
2225 printf (" Initializing flash with \" %s\" ...\n " , args.image );
2326 flash_init (args.image );
2427
@@ -39,7 +42,7 @@ class Emulator
3942 if (args.dump_wave )
4043 {
4144 Verilated::traceEverOn (true );
42- printf (" Enabling waves .. .\n " );
45+ printf (" `dump-wave` enabled, waves will be written to \" vlt_dump.vcd \" .\n " );
4346 fp = new VerilatedVcdC;
4447 dut_ptr->trace (fp, 1 );
4548 fp->open (" vlt_dump.vcd" );
@@ -66,6 +69,11 @@ class Emulator
6669 dut_ptr->eval ();
6770 }
6871
72+ unsigned long long get_cycle ()
73+ {
74+ return cycle;
75+ }
76+
6977private:
7078 void parseArgs (int argc, char *argv[])
7179 {
@@ -124,6 +132,7 @@ class Emulator
124132 }
125133
126134 unsigned long long cycle = 0 ;
135+
127136 struct Args
128137 {
129138 bool dump_wave = false ;
Original file line number Diff line number Diff line change 11#include < cstdio>
2- #include < signal.h>
2+ #include < csignal>
3+ #include < chrono>
4+ namespace chrono = std::chrono;
35
46#include " verilated.h" // Defines common routines
57#include " VysyxSoCFull.h"
@@ -13,17 +15,24 @@ void sig_handler(int signo)
1315 if (signal_received != 0 )
1416 {
1517 puts (" SIGINT received, forcely shutting down.\n " );
16- _exit (0 );
18+ exit (0 );
1719 }
1820 puts (" SIGINT received, gracefully shutting down... Type Ctrl+C again to stop forcely.\n " );
1921 signal_received = signo;
2022}
2123
2224static Emulator *emu = nullptr ;
25+ chrono::system_clock::time_point sim_start_time;
2326void release ()
2427{
2528 if (emu != nullptr )
29+ {
30+ auto elapsed = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now () - sim_start_time);
31+ printf (" Simulated %llu cycles in %lds\n " ,
32+ emu->get_cycle (),
33+ elapsed.count ());
2634 delete emu;
35+ }
2736}
2837
2938int main (int argc, char *argv[])
@@ -38,6 +47,7 @@ int main(int argc, char *argv[])
3847
3948 emu = new Emulator (argc, argv);
4049 printf (" Start simulating ...\n " );
50+ sim_start_time = chrono::system_clock::now ();
4151 while (!Verilated::gotFinish () && signal_received == 0 )
4252 {
4353 emu->step ();
You can’t perform that action at this time.
0 commit comments