1
0
mirror of https://github.com/olofk/serv.git synced 2026-01-26 03:41:21 +00:00

Add timeout argument

This commit is contained in:
Olof Kindgren
2019-08-22 09:46:06 +02:00
parent 65eb89323a
commit e059b7cf09
3 changed files with 17 additions and 1 deletions

View File

@@ -107,6 +107,11 @@ int main(int argc, char **argv, char **env)
signal(SIGINT, INThandler);
vluint64_t timeout = 0;
const char *arg_timeout = Verilated::commandArgsPlusMatch("timeout=");
if (arg_timeout[0])
timeout = atoi(arg_timeout+9);
top->wb_clk = 1;
bool q = top->q;
while (!(done || Verilated::gotFinish())) {
@@ -118,6 +123,12 @@ int main(int argc, char **argv, char **env)
do_uart(&uart_context, top->q);
else
do_gpio(&gpio_context, top->q);
if (timeout && (main_time >= timeout)) {
printf("Timeout: Exiting at time %lu\n", main_time);
done = true;
}
top->wb_clk = !top->wb_clk;
main_time+=31.25;