working buttons and DIN to control display

This commit is contained in:
filipriec skolsky PC
2026-03-23 17:22:08 +01:00
parent 07f021abe6
commit 3e2b49671e
3 changed files with 30 additions and 8 deletions

View File

@@ -37,6 +37,8 @@ entity counter is
Port ( CLK : in STD_LOGIC;
RST : in STD_LOGIC;
CE : in STD_LOGIC;
PE : in STD_LOGIC;
DIN : in STD_LOGIC_VECTOR(3 downto 0);
TC : out STD_LOGIC;
COUNT_OUT : out STD_LOGIC_VECTOR (3 downto 0));
end counter;
@@ -53,6 +55,9 @@ begin
if RST = '1' then
s_cnt <= "0000";
TC <= '0'; -- Reset TC
elsif PE = '1' then
s_cnt <= DIN;
TC <= '0';
elsif CE = '1' then
if s_cnt = MAX_LIMIT then
s_cnt <= "0000"; -- Reset to 0 when limit is hit

View File

@@ -35,6 +35,8 @@ entity top_modul is
Port ( CLK : in STD_LOGIC;
RST : in STD_LOGIC;
START : in STD_LOGIC;
SW_DIN : in STD_LOGIC_VECTOR (3 downto 0); -- The value to set
BTN_LOAD : in STD_LOGIC_VECTOR (3 downto 0); -- Which digit to set
SEGMENTS : out STD_LOGIC_VECTOR (7 downto 0);
ANODS : out STD_LOGIC_VECTOR (3 downto 0));
end top_modul;
@@ -57,6 +59,8 @@ architecture Behavioral of top_modul is
Generic ( MAX_LIMIT : STD_LOGIC_VECTOR(3 downto 0) := "1001" ); -- Default to 9
Port ( CLK : in STD_LOGIC;
CE : in STD_LOGIC;
PE : in STD_LOGIC;
DIN : in STD_LOGIC_VECTOR(3 downto 0);
RST : in STD_LOGIC;
TC : out STD_LOGIC;
COUNT_OUT : out STD_LOGIC_VECTOR (3 downto 0));
@@ -129,6 +133,8 @@ begin
CLK => CLK,
RST => RST,
CE => s_ce_units,
PE => BTN_LOAD(0),
DIN => SW_DIN,
TC => tc_mu,
COUNT_OUT => sig_m_units
);
@@ -140,6 +146,8 @@ begin
CLK => CLK,
RST => RST,
CE => tc_mu,
PE => BTN_LOAD(1),
DIN => SW_DIN,
TC => tc_mt,
COUNT_OUT => sig_m_tens
);
@@ -154,6 +162,8 @@ begin
CLK => CLK,
RST => hour_reset,
CE => tc_mt,
PE => BTN_LOAD(2),
DIN => SW_DIN,
TC => tc_hu,
COUNT_OUT => sig_h_units
);
@@ -165,6 +175,8 @@ begin
CLK => CLK,
RST => hour_reset,
CE => tc_hu,
PE => BTN_LOAD(3),
DIN => SW_DIN,
TC => open,
COUNT_OUT => sig_h_tens
);