TA147

Ejecicios y trabajos prácticos de la materia Taller de Sistemas Digitales (TA147)
Index Commits Files Refs
commit bbdfe75892a77fb0031f81a44795a309858eabfb
parent db99ababd2f6291ff564b5f4169ea7200ffe8e41
Author: Martin Klöckner <mjkloeckner@gmail.com>
Date:   Sat, 18 Apr 2026 12:12:49 -0300

Do not read `tick_cnt` when `rst` is active

Diffstat:
Mtps/1/src/rtl/cnt.vhd | 17++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/tps/1/src/rtl/cnt.vhd b/tps/1/src/rtl/cnt.vhd
@@ -18,6 +18,7 @@ architecture cnt_arq of cnt is
 
     constant YELLOW_S : unsigned(5 downto 0) := to_unsigned(3, 6);
     constant RED_GREEN_S : unsigned(5 downto 0) := to_unsigned(30, 6);
+
     signal tick_cnt : unsigned(5 downto 0);
 
 begin
@@ -54,11 +55,17 @@ begin
 
     end process;
     
-    state_flag <= '1' when state /= state_1r_2g and 
-           state /= state_1g_2r and 
-           tick_cnt = YELLOW_S - 1 and ena = '1'
+    state_flag <=
+       '1' when rst = '0' and
+                ena = '1' and
+                state /= state_1r_2g and 
+                state /= state_1g_2r and 
+                tick_cnt = YELLOW_S - 1
+       else
+       '1' when rst = '0' and
+                ena = '1' and
+                tick_cnt = RED_GREEN_S - 1
        else
-           '1' when tick_cnt = RED_GREEN_S - 1 and ena = '1'
-       else '0';
+       '0';
 
 end architecture;