From 66ea3ca0eaf79a2549a80b7fd36c42bea643ce24 Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Sun, 2 Apr 2023 21:20:26 +0000 Subject: [PATCH] waveform.v fix potential hang in waveform.v --- firmware/rtl/waveform/Makefile | 2 ++ firmware/rtl/waveform/waveform_sim.cpp | 23 ++++++++++++++++++++++- firmware/rtl/waveform/waveform_sim.v | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/firmware/rtl/waveform/Makefile b/firmware/rtl/waveform/Makefile index 4534909..25de31f 100644 --- a/firmware/rtl/waveform/Makefile +++ b/firmware/rtl/waveform/Makefile @@ -1,5 +1,7 @@ # Makefile for tests and hardware verification. +include ../common.makefile + .PHONY: test clean codegen all: test codegen diff --git a/firmware/rtl/waveform/waveform_sim.cpp b/firmware/rtl/waveform/waveform_sim.cpp index 8471180..67a423a 100644 --- a/firmware/rtl/waveform/waveform_sim.cpp +++ b/firmware/rtl/waveform/waveform_sim.cpp @@ -67,20 +67,41 @@ int main(int argc, char *argv[]) { tb->mod.rdy = 1; tb->refresh_data(); tb->mod.time_to_wait = 10; + tb->mod.halt_on_finish = 1; tb->mod.arm = 1; do { tb->run_clock(); } 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; + + printf("second run\n"); do { tb->run_clock(); } while (!tb->mod.waveform_finished); + tb->mod.rdy = 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; + + printf("third run\n"); do { tb->run_clock(); } while (!tb->mod.waveform_finished); diff --git a/firmware/rtl/waveform/waveform_sim.v b/firmware/rtl/waveform/waveform_sim.v index ee74524..3f9fa28 100644 --- a/firmware/rtl/waveform/waveform_sim.v +++ b/firmware/rtl/waveform/waveform_sim.v @@ -24,6 +24,7 @@ module waveform_sim #( input arm, input halt_on_finish, output waveform_finished, + output running, input [TIMER_WID-1:0] time_to_wait, /* User interface */ @@ -101,6 +102,7 @@ waveform #( .clk(clk), .arm(arm), .halt_on_finish(halt_on_finish), + .running(running), .finished(waveform_finished), .time_to_wait(time_to_wait),