0
我正在使用VHDL的紅外解碼器,我知道IR 1位的寬度爲1.2毫秒,IR 0位爲0.6毫秒,起始位爲2.5毫秒。我正試圖製作一個計數器,它能夠接收50MHz時鐘並轉換爲十分之一毫秒。我怎樣才能做到這一點?你如何使vhdl計數器以十分之一毫秒計數?
entity counter is
Port (EN : in STD_LOGIC;
RESET : in STD_LOGIC;
CLK : in STD_LOGIC;
COUNT : out STD_LOGIC_VECTOR (4 downto 0));
end counter;
architecture Behavioral of counter is
constant max_count : integer := (2);
begin
startCounter: process(EN, RESET, CLK)
variable cnt : integer := 0;
variable div_cnt : integer := 0;
begin
if (RESET = '1') then
cnt := 0;
div_cnt := 0;
elsif (EN = '1' and rising_edge(CLK)) then
if (cnt = max_count) then
cnt := 0;
div_cnt:= div_cnt + 1;
else
cnt := cnt + 1;
end if;
end if;
COUNT <= conv_std_logic_vector(cnt, 5);
-- COUNT <= temp_count(16 downto 13);
end process startCounter;
end Behavioral;
請參閱相關鏈接:http://electronics.stackexchange.com/questions/144800/design-up-counter-in-vhdl-using-generate-statement – Barnstokkr 2015-03-13 08:29:39
我瞭解如何進行計數,但我需要幫助轉換從系統時鐘到十分之幾毫秒。 – chanceofthat 2015-03-13 09:07:36
請參閱其他相關信息:http://stackoverflow.com/questions/19708301/making-a-clock-divider – Barnstokkr 2015-03-13 09:28:22