waveform.v

fix potential hang in waveform.v
This commit is contained in:
Peter McGoron 2023-04-02 21:20:26 +00:00
parent 657b400666
commit 66ea3ca0ea
3 changed files with 26 additions and 1 deletions

View File

@ -1,5 +1,7 @@
# Makefile for tests and hardware verification. # Makefile for tests and hardware verification.
include ../common.makefile
.PHONY: test clean codegen .PHONY: test clean codegen
all: test codegen all: test codegen

View File

@ -67,20 +67,41 @@ int main(int argc, char *argv[]) {
tb->mod.rdy = 1; tb->mod.rdy = 1;
tb->refresh_data(); tb->refresh_data();
tb->mod.time_to_wait = 10; tb->mod.time_to_wait = 10;
tb->mod.halt_on_finish = 1;
tb->mod.arm = 1; tb->mod.arm = 1;
do { do {
tb->run_clock(); tb->run_clock();
} while (!tb->mod.refresh_finished); } while (!tb->mod.refresh_finished);
printf("first run\n");
do {
tb->run_clock();
} while (!tb->mod.waveform_finished);
printf("waveform finished\n");
tb->mod.halt_on_finish = 0;
tb->mod.arm = 0;
tb->run_clock();
tb->mod.arm = 1;
tb->mod.halt_on_finish = 1; tb->mod.halt_on_finish = 1;
printf("second run\n");
do { do {
tb->run_clock(); tb->run_clock();
} while (!tb->mod.waveform_finished); } while (!tb->mod.waveform_finished);
tb->mod.rdy = 0;
tb->mod.halt_on_finish = 0; tb->mod.halt_on_finish = 0;
tb->run_clock(); tb->mod.refresh_start = 1;
do {
tb->run_clock();
} while (!tb->mod.refresh_finished);
tb->mod.rdy = 1;
tb->mod.halt_on_finish = 1; tb->mod.halt_on_finish = 1;
printf("third run\n");
do { do {
tb->run_clock(); tb->run_clock();
} while (!tb->mod.waveform_finished); } while (!tb->mod.waveform_finished);

View File

@ -24,6 +24,7 @@ module waveform_sim #(
input arm, input arm,
input halt_on_finish, input halt_on_finish,
output waveform_finished, output waveform_finished,
output running,
input [TIMER_WID-1:0] time_to_wait, input [TIMER_WID-1:0] time_to_wait,
/* User interface */ /* User interface */
@ -101,6 +102,7 @@ waveform #(
.clk(clk), .clk(clk),
.arm(arm), .arm(arm),
.halt_on_finish(halt_on_finish), .halt_on_finish(halt_on_finish),
.running(running),
.finished(waveform_finished), .finished(waveform_finished),
.time_to_wait(time_to_wait), .time_to_wait(time_to_wait),