library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity A is
Port (
clk : in STD_LOGIC;
reset: in std_logic; -- reset input
counter: out std_logic_vector(3 downto 0) := "0000"-- output 4-bit counter
);
end A;
architecture Behavioral of A is
signal counter_up: std_logic_vector(3 downto 0) := "0000";
signal countOf : integer := -1;
signal count : integer := 0;
signal temp : std_logic := '0';
begin
-- up counter
process(clk)
begin
if(clk'event and clk='1') then
count <=count+1;
if(count = 50000000) then
temp <= not temp;
count <=1;
end if;
end if;
end process;
process(temp,reset)
begin
if(reset = '1') then
countOf <= 0;
else
if(temp = '1') then
if(countOf < 4) then countOf <= countOf + 1;
else countOf <= 0; end if;
if(countOf = 0) then counter_up <= "0000"; end if;
if(countOf = 1) then counter_up <= "0001"; end if;
if(countOf = 2) then counter_up <= "0010"; end if;
if(countOf = 3) then counter_up <= "0100"; end if;
if(countOf = 4) then counter_up <= "1000"; end if;
end if;
end if;
end process;
counter <= counter_up;
end Behavioral;
안녕하세요 저는 0에서 4까지의 카운터를 만들고 싶습니다. 제 시계를 1 HZ로 나누고 임시 및 리셋 과정에서 모든 조건을 할당했으나 어떻게 내가 원하는지. 그것은 매우 이상합니다. 어떻게 해결할 수 있습니까? 미리 감사드립니다.각각의 카운트 vhdl
귀하의 조합 프로세스가 작동하지 않습니다. 모든 것을 클럭 처리에 적용하지 않는 이유는 무엇입니까? 추신. 테스트 벤치를 작성했다면 이미 작동하지 않는 것을 보았을 것입니다. – JHBonarius