summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLYAM <cous5830@gmail.com>2025-05-18 18:32:51 -0400
committerLYAM <cous5830@gmail.com>2025-05-18 18:32:51 -0400
commit5c72385b2d95a7842ddff0393e91744432da24af (patch)
tree33d499f7da5fe5ec1299c6563325f37b8c5c86af
parent3d81cfe9c1028ae989f580e42aad0414081b5e7c (diff)
copy pasted from LAB. needs modifications
-rw-r--r--pb_logique_seq.srcs/sources_1/imports/new/module_commande.vhd98
1 files changed, 95 insertions, 3 deletions
diff --git a/pb_logique_seq.srcs/sources_1/imports/new/module_commande.vhd b/pb_logique_seq.srcs/sources_1/imports/new/module_commande.vhd
index e36b87f..2141173 100644
--- a/pb_logique_seq.srcs/sources_1/imports/new/module_commande.vhd
+++ b/pb_logique_seq.srcs/sources_1/imports/new/module_commande.vhd
@@ -22,7 +22,12 @@ generic (nbtn : integer := 4; mode_simulation: std_logic := '0');
end module_commande;
ARCHITECTURE BEHAVIOR OF module_commande IS
-
+ type sound_effect is (effect_a, effect_b, effect_c, effect_d);
+ signal current_sound_effect : sound_effect;
+ signal wanted_sound_effect : sound_effect;
+ signal increase_selection : std_logic;
+ signal decrease_selection : std_logic;
+ signal has_pressed_selection_already : std_logic;
component conditionne_btn_v7 is
generic (nbtn : integer := nbtn; mode_simul: std_logic := '0');
@@ -35,10 +40,11 @@ generic (nbtn : integer := nbtn; mode_simul: std_logic := '0');
);
end component;
-
signal d_strobe_btn : std_logic_vector (nbtn-1 downto 0);
signal d_btn_cd : std_logic_vector (nbtn-1 downto 0);
signal d_reset : std_logic;
+ signal needs_to_increase : std_logic;
+ signal needs_to_decrease : std_logic;
BEGIN
@@ -59,10 +65,96 @@ BEGIN
end if;
end process;
+ reset_manager : process(d_reset, clk)
+ begin
+ if d_reset = '1' then
+ current_sound_effect <= effect_a;
+ elsif rising_edge(clk) then
+ -- Wanted sound effect is outputed on every clock edge
+ current_sound_effect <= wanted_sound_effect;
+ end if;
+ end process;
+
+button_spam_manager : process(d_btn_cd, d_reset, clk)
+ begin
+ if d_reset = '1' then
+ has_pressed_selection_already <= '0';
+ increase_selection <= '0';
+ decrease_selection <= '0';
+ elsif rising_edge(clk) then
+ -- Managing creating pulses for the button to avoid spam increasing states!
+ if (NOT (has_pressed_selection_already = '1')) AND ((d_btn_cd(0) = '1') OR (d_btn_cd(1) = '1')) then
+ -- No increase or decrease is called AND one of the buttons is pressed!
+ -- That means we can send a pulse to increase or decrease the counter.
+ has_pressed_selection_already <= '1';
+ if d_btn_cd(0) = '1' then
+ increase_selection <= '1';
+ decrease_selection <= '0';
+ elsif d_btn_cd(1) = '1' then
+ decrease_selection <= '1';
+ increase_selection <= '0';
+ end if;
+ else
+ increase_selection <= '0';
+ decrease_selection <= '0';
+ end if;
+ else
+ if ((d_btn_cd(0) = '0') AND (d_btn_cd(1) = '0')) then
+ -- no buttons is pressed. Therefor, we can start registering an increase or decrease again.
+ has_pressed_selection_already <= '0';
+ end if;
+ end if;
+ end process;
+
+state_manager : process(current_sound_effect, decrease_selection, increase_selection)
+ begin
+ case current_sound_effect is
+ when effect_a =>
+ o_selection_fct <= "00";
+ if increase_selection = '1' then
+ wanted_sound_effect <= effect_b;
+-- increase_selection <= '0';
+ elsif decrease_selection = '1' then
+ wanted_sound_effect <= effect_d;
+ --decrease_selection <= '0';
+ end if;
+
+ when effect_b =>
+ o_selection_fct <= "01";
+ if increase_selection = '1' then
+ wanted_sound_effect <= effect_c;
+ --increase_selection <= '0';
+ elsif decrease_selection = '1' then
+ wanted_sound_effect <= effect_a;
+ --decrease_selection <= '0';
+ end if;
+
+ when effect_c =>
+ o_selection_fct <= "10";
+ if increase_selection = '1' then
+ wanted_sound_effect <= effect_d;
+ --increase_selection <= '0';
+ elsif decrease_selection = '1' then
+ wanted_sound_effect <= effect_b;
+ --decrease_selection <= '0';
+ end if;
+
+ when effect_d =>
+ o_selection_fct <= "11";
+ if increase_selection = '1' then
+ wanted_sound_effect <= effect_a;
+ --increase_selection <= '0';
+ elsif decrease_selection = '1' then
+ wanted_sound_effect <= effect_c;
+ --decrease_selection <= '0';
+ end if;
+ end case;
+
+ end process;
o_btn_cd <= d_btn_cd;
o_selection_par <= i_sw(1 downto 0); -- mode de selection du parametre par sw
- o_selection_fct <= i_sw(3 downto 2); -- mode de selection de la fonction par sw
+ --o_selection_fct <= i_sw(3 downto 2); -- mode de selection de la fonction par sw
d_reset <= i_btn(3); -- pas de contionnement particulier sur reset
END BEHAVIOR;