Skip to content

Commit 8541f3f

Browse files
committed
Support specifying the period to dump wave
1 parent 4ecd413 commit 8541f3f

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

projects/soc/csrc/emu.h

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ class Emulator
2424

2525
printf("Initializing DUT...\n");
2626
dut_ptr = new VysyxSoCFull;
27-
dut_ptr->clock = 0;
28-
dut_ptr->reset = 1;
29-
dut_ptr->eval();
30-
dut_ptr->clock = 1;
3127
dut_ptr->reset = 1;
32-
dut_ptr->eval();
28+
for (int i = 0; i < 10; i++)
29+
{
30+
dut_ptr->clock = 0;
31+
dut_ptr->eval();
32+
dut_ptr->clock = 1;
33+
dut_ptr->eval();
34+
}
35+
dut_ptr->clock = 0;
3336
dut_ptr->reset = 0;
37+
dut_ptr->eval();
3438

35-
if (args.dumpWave)
39+
if (args.dump_wave)
3640
{
3741
Verilated::traceEverOn(true);
3842
printf("Enabling waves ...\n");
@@ -44,7 +48,7 @@ class Emulator
4448
}
4549
~Emulator()
4650
{
47-
if (args.dumpWave)
51+
if (args.dump_wave)
4852
{
4953
fp->close();
5054
delete fp;
@@ -55,13 +59,11 @@ class Emulator
5559
{
5660
dut_ptr->clock = 1;
5761
dut_ptr->eval();
58-
if (args.dumpWave)
59-
fp->dump(++cycle);
60-
62+
cycle++;
63+
if (args.dump_wave && args.dump_begin <= cycle && cycle <= args.dump_end)
64+
fp->dump((vluint64_t)cycle);
6165
dut_ptr->clock = 0;
6266
dut_ptr->eval();
63-
if (args.dumpWave)
64-
fp->dump(++cycle);
6567
}
6668

6769
private:
@@ -71,21 +73,23 @@ class Emulator
7173
int long_index;
7274
const struct option long_options[] = {
7375
{"dump-wave", 0, NULL, 0},
76+
{"log-begin", 1, NULL, 'b'},
77+
{"log-end", 1, NULL, 'e'},
7478
{"image", 1, NULL, 'i'},
7579
{"help", 0, NULL, 'h'},
7680
{0, 0, NULL, 0}};
7781

7882
int o;
7983
while ((o = getopt_long(argc, const_cast<char *const *>(argv),
80-
"-hi:", long_options, &long_index)) != -1)
84+
"-hi:b:e:", long_options, &long_index)) != -1)
8185
{
8286
switch (o)
8387
{
8488
case 0:
8589
switch (long_index)
8690
{
8791
case 0:
88-
args.dumpWave = true;
92+
args.dump_wave = true;
8993
continue;
9094
}
9195
// fall through
@@ -95,25 +99,36 @@ class Emulator
9599
case 'i':
96100
args.image = optarg;
97101
break;
102+
case 'b':
103+
args.dump_begin = atoll(optarg);
104+
break;
105+
case 'e':
106+
args.dump_end = atoll(optarg);
107+
break;
98108
}
99109
}
100110

101111
Verilated::commandArgs(argc, argv);
102112
}
113+
103114
static inline void print_help(const char *file)
104115
{
105116
printf("Usage: %s [OPTION...]\n", file);
106117
printf("\n");
107118
printf(" -i, --image=FILE run with this image file\n");
108119
printf(" --dump-wave dump waveform when log is enabled\n");
120+
printf(" -b, --log-begin=NUM display log from NUM th cycle\n");
121+
printf(" -e, --log-end=NUM stop display log at NUM th cycle\n");
109122
printf(" -h, --help print program help info\n");
110123
printf("\n");
111124
}
112125

113-
int cycle = 0;
126+
unsigned long long cycle = 0;
114127
struct Args
115128
{
116-
bool dumpWave = false;
129+
bool dump_wave = false;
130+
unsigned long dump_begin = 0;
131+
unsigned long dump_end = -1;
117132
const char *image = nullptr;
118133
} args;
119134

0 commit comments

Comments
 (0)