From 264b1e6c5735b9981cd10f8ab8c0b48b2ec0d4b9 Mon Sep 17 00:00:00 2001
From: Erik Kooistra <kooistra@astron.nl>
Date: Wed, 11 May 2016 07:54:27 +0000
Subject: [PATCH] Made tb self stopping.

---
 libraries/base/util/tb/vhdl/tb_util_heater.vhd | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libraries/base/util/tb/vhdl/tb_util_heater.vhd b/libraries/base/util/tb/vhdl/tb_util_heater.vhd
index 6ddc4feb66..8555e7e537 100644
--- a/libraries/base/util/tb/vhdl/tb_util_heater.vhd
+++ b/libraries/base/util/tb/vhdl/tb_util_heater.vhd
@@ -51,6 +51,7 @@ ARCHITECTURE tb OF tb_util_heater IS
   
   CONSTANT c_reg_nof_words   : NATURAL := 2;  -- derived from c_nof_mac4 / c_word_w
   
+  SIGNAL tb_end        : STD_LOGIC := '0';
   SIGNAL mm_rst        : STD_LOGIC;
   SIGNAL mm_clk        : STD_LOGIC := '0';
   SIGNAL st_rst        : STD_LOGIC;
@@ -62,10 +63,10 @@ ARCHITECTURE tb OF tb_util_heater IS
 BEGIN
 
   -- as 10
-  -- run 20 us
+  -- run -all
   
-  mm_clk <= NOT mm_clk  AFTER mm_clk_period/2;
-  st_clk <= NOT st_clk  AFTER st_clk_period/2;
+  mm_clk <= NOT mm_clk OR tb_end AFTER mm_clk_period/2;
+  st_clk <= NOT st_clk OR tb_end AFTER st_clk_period/2;
   
   mm_rst <= '1', '0' AFTER mm_clk_period*5;
   st_rst <= '1', '0' AFTER st_clk_period*5;
@@ -99,6 +100,8 @@ BEGIN
     FOR I IN 0 TO c_time_heater_off-1 LOOP
       WAIT UNTIL rising_edge(mm_clk);
     END LOOP;
+    tb_end <= '1';
+    WAIT;
   END PROCESS;
   
   dut : ENTITY work.util_heater
-- 
GitLab