題目:多位元計數器設計VHDL20240601_Counter8Bits
https://youtu.be/OyL_oZnofgQ 題目:多位元計數器設計 設計一個 8 位元二進制計數器,具有以下功能: 當 reset 為高電位時,計數器重置為 0。 當 enable 為高電位時,計數器每個時鐘周期遞增 1。 當計數器到達 255 時,溢出並重新開始從 0 計數。 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 VHDL20240601_Counter8Bits is port( clk_4M:in std_logic; reset:in std_logic; enable:in std_logic; BCD:buffer std_logic_vector(7 downto 0):="00000000"); end VHDL20240601_Counter8Bits; architecture aa of VHDL20240601_Counter8Bits is signal cnt1:integer range 0 to 1999999:=0; signal clk_sec:std_logic:='0'; begin process(clk_4M) begin if rising_edge(clk_4M) then cnt1<=cnt1+1; if cnt1=199999 then cnt1<=0; clk_sec<=not clk_sec; end if; end if; end process; process(reset, enable, clk_sec) begin if reset='0' then BCD<="00000000"; elsif rising_edge(clk_sec) then if enable='0' then BCD<=BCD+1; end if; en...