zmenene tlacitko na switch ked sa meni hodnota
This commit is contained in:
@@ -10,8 +10,8 @@ entity clock_logic is
|
||||
CLK : in STD_LOGIC;
|
||||
RST : in STD_LOGIC;
|
||||
CE_1HZ : in STD_LOGIC; -- Enable signal from the divider
|
||||
SW_DIN : in STD_LOGIC_VECTOR (3 downto 0); -- set data on btn_load
|
||||
BTN_LOAD : in STD_LOGIC_VECTOR (3 downto 0);
|
||||
DIGIT_SEL: in STD_LOGIC_VECTOR (3 downto 0); -- '0001'=M_UNITS, '0010'=M_TENS, atd.
|
||||
BTN_INC : in STD_LOGIC; -- drzanie tlacidla pre inkrement
|
||||
-- Outputs to the top module/display
|
||||
S_UNITS : out STD_LOGIC_VECTOR (3 downto 0);
|
||||
S_TENS : out STD_LOGIC_VECTOR (3 downto 0);
|
||||
@@ -45,32 +45,17 @@ architecture Behavioral of clock_logic is
|
||||
-- Reset for hours (to handle the 24 reset)
|
||||
signal hour_reset : std_logic;
|
||||
|
||||
-- Specific load enable signals that check for boundaries
|
||||
signal load_h_tens, load_h_units : std_logic;
|
||||
signal load_m_tens, load_m_units : std_logic;
|
||||
|
||||
-- Internal signals for the "Safe" load triggers
|
||||
signal safe_load_su, safe_load_st : std_logic;
|
||||
signal safe_load_mu, safe_load_mt : std_logic;
|
||||
signal safe_load_hu, safe_load_ht : std_logic;
|
||||
begin
|
||||
-- MINUTES CONSTRAINTS (Max 59)
|
||||
load_m_units <= BTN_LOAD(0) when (SW_DIN <= "1001") else '0'; -- 0-9
|
||||
load_m_tens <= BTN_LOAD(1) when (SW_DIN <= "0101") else '0'; -- 0-5
|
||||
-- HOURS CONSTRAINTS (Max 23)
|
||||
-- Rule A: Cannot load Tens > 2.
|
||||
-- Rule B: If Tens is 2, cannot load Units > 3.
|
||||
-- Rule C: If Units is > 3, cannot load Tens into 2.
|
||||
load_h_tens <= BTN_LOAD(3) when (
|
||||
SW_DIN < "0010" or
|
||||
(SW_DIN = "0010" and sig_h_units <= "0011")
|
||||
) else '0';
|
||||
signal inc_m_units : std_logic;
|
||||
signal inc_m_tens : std_logic;
|
||||
signal inc_h_units : std_logic;
|
||||
signal inc_h_tens : std_logic;
|
||||
|
||||
begin
|
||||
inc_m_units <= BTN_INC and DIGIT_SEL(0);
|
||||
inc_m_tens <= BTN_INC and DIGIT_SEL(1);
|
||||
inc_h_units <= BTN_INC and DIGIT_SEL(2);
|
||||
inc_h_tens <= BTN_INC and DIGIT_SEL(3);
|
||||
|
||||
load_h_units <= BTN_LOAD(2) when (
|
||||
(sig_h_tens < "0010" and SW_DIN <= "1001") or
|
||||
(sig_h_tens = "0010" and SW_DIN <= "0011")
|
||||
) else '0';
|
||||
|
||||
-------------------------------------------------------
|
||||
-- SECONDS SECTION
|
||||
-- SECONDS UNITS (0-9) - Triggered by the 1Hz pulse
|
||||
@@ -109,8 +94,8 @@ begin
|
||||
CLK => CLK,
|
||||
RST => RST,
|
||||
CE => tc_st,
|
||||
PE => load_m_units,
|
||||
DIN => SW_DIN,
|
||||
PE => inc_m_units, -- for M_UNITS (bit 0)
|
||||
DIN => "0001",
|
||||
TC => tc_mu,
|
||||
COUNT_OUT => sig_m_units
|
||||
);
|
||||
@@ -122,8 +107,8 @@ begin
|
||||
CLK => CLK,
|
||||
RST => RST,
|
||||
CE => tc_mu,
|
||||
PE => load_m_tens,
|
||||
DIN => SW_DIN,
|
||||
PE => inc_m_tens,
|
||||
DIN => "0010",
|
||||
TC => tc_mt,
|
||||
COUNT_OUT => sig_m_tens
|
||||
);
|
||||
@@ -156,8 +141,8 @@ begin
|
||||
CLK => CLK,
|
||||
RST => hour_reset,
|
||||
CE => tc_mt,
|
||||
PE => load_h_units,
|
||||
DIN => SW_DIN,
|
||||
PE => inc_h_units,
|
||||
DIN => "0100",
|
||||
TC => tc_hu,
|
||||
COUNT_OUT => sig_h_units
|
||||
);
|
||||
@@ -169,8 +154,8 @@ begin
|
||||
CLK => CLK,
|
||||
RST => hour_reset,
|
||||
CE => tc_hu,
|
||||
PE => load_h_tens,
|
||||
DIN => SW_DIN,
|
||||
PE => inc_h_tens,
|
||||
DIN => "1000",
|
||||
TC => open,
|
||||
COUNT_OUT => sig_h_tens
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user