VHDL20240527_counter_fsm 有限狀態計數器
https://youtube.com/shorts/xX-JP7SjK-I?si=XezkWrq6dcKhDNTT library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; use ieee.numeric_std.all; entity VHDL20240527_counter_fsm is port( clk_4M:in std_logic; reset:in std_logic; start:in std_logic; seg7_scan:out std_logic_vector(3 downto 0):="1110"; state_BCD:out std_logic_vector(2 downto 0):="000"; seg7_out:out std_logic_vector(6 downto 0)); end VHDL20240527_counter_fsm; architecture aa of VHDL20240527_counter_fsm is signal cnt1:integer range 0 to 1999:=0; signal cnt2:integer range 0 to 1999:=0; signal clk_2k:std_logic:='0'; signal clk_sec:std_logic:='0'; type state_type is (IDLE, COUNTING, DONE); signal state:state_type:=IDLE; signal counter:std_logic_vector(3 downto 0):="0000"; begin process(clk_4M) begin if rising_edge(clk_4M) then cnt1<=cnt1+1; if cnt1=1999 then cnt1<=0; clk_2k<=not