commit 353c7170a377ccf7920e6b89a229703fb929fd4e
parent 104a1c4c015f6788d8c8fc7328b0472f6fab2585
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date: Fri, 17 Apr 2026 17:10:34 -0300
Fix yellow lights turning on at the same time
Diffstat:
3 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/tps/1/img/waveform_view_markers.png b/tps/1/img/waveform_view_markers.png
Binary files differ.
diff --git a/tps/1/img/waveform_view_markers_dark.png b/tps/1/img/waveform_view_markers_dark.png
Binary files differ.
diff --git a/tps/1/src/intersection_ctrl.vhd b/tps/1/src/intersection_ctrl.vhd
@@ -24,7 +24,7 @@ architecture intersection_ctrl_arq of intersection_ctrl is
constant YEL_TIME_MS : integer := 3e3;
constant GRE_TIME_MS : integer := 30e3;
- type state_t is(state_0, state_1, state_2, state_3);
+ type state_t is(state_0, state_1, state_2, state_3, state_4, state_5);
signal state : state_t := state_0;
signal clk_ms : std_logic;
@@ -49,19 +49,18 @@ begin
ms_tick_cnt <= ms_tick_cnt + 1;
case state is
when state_0 =>
- if ms_tick_cnt = RED_TIME_MS then
+ if ms_tick_cnt = (RED_TIME_MS - 2*YEL_TIME_MS) then
ms_tick_cnt <= (others => '0');
state <= state_1;
red_1 <= '1';
- yel_1 <= '1';
+ yel_1 <= '0';
gre_1 <= '0';
red_2 <= '0';
yel_2 <= '1';
gre_2 <= '0';
-
end if;
when state_1 =>
if ms_tick_cnt = YEL_TIME_MS then
@@ -69,6 +68,20 @@ begin
ms_tick_cnt <= (others => '0');
state <= state_2;
+ red_1 <= '1';
+ yel_1 <= '1';
+ gre_1 <= '0';
+ red_2 <= '1';
+ yel_2 <= '0';
+ gre_2 <= '0';
+
+ end if;
+ when state_2 =>
+ if ms_tick_cnt = YEL_TIME_MS then
+
+ ms_tick_cnt <= (others => '0');
+ state <= state_3;
+
red_1 <= '0';
yel_1 <= '0';
gre_1 <= '1';
@@ -77,21 +90,35 @@ begin
gre_2 <= '0';
end if;
- when state_2 =>
+ when state_3 =>
if ms_tick_cnt = GRE_TIME_MS then
ms_tick_cnt <= (others => '0');
- state <= state_3;
+ state <= state_4;
red_1 <= '0';
yel_1 <= '1';
gre_1 <= '0';
red_2 <= '1';
+ yel_2 <= '0';
+ gre_2 <= '0';
+
+ end if;
+ when state_4 =>
+ if ms_tick_cnt = YEL_TIME_MS then
+
+ ms_tick_cnt <= (others => '0');
+ state <= state_5;
+
+ red_1 <= '1';
+ yel_1 <= '0';
+ gre_1 <= '0';
+ red_2 <= '1';
yel_2 <= '1';
gre_2 <= '0';
end if;
- when state_3 =>
+ when state_5 =>
if ms_tick_cnt = YEL_TIME_MS then
ms_tick_cnt <= (others => '0');