реклама на сайте
подробности

 
 
> XC9572 Binary Counter, Простой счетчик чудит
shell_inspector
сообщение Jan 11 2006, 15:15
Сообщение #1





Группа: Новичок
Сообщений: 3
Регистрация: 11-01-06
Пользователь №: 13 061



Мужики, делаю элементарный 8-и битовый двоичный счетчик на ISE7.1 для XC9572-PC44 CPLD. Сигналы счетчика вывожу через IO выходы. По идее, частота каждого следущего бита досжна делиться на два. У меня же частота всех равна половине CLK (CLK/2) плюс некоторые биты "дергаются" словно шум по фазе. Не могу понять в чем дело. Вроде нет ни ошибок с компиляцией ни с загрузкой.
С сигналом CLEAR и CLK Все нормально. Исходник взят из справочника на инете:
--------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;


entity counter is
Port (
CLEAR: in std_logic;
Q5: out std_logic_vector(7 downto 0);
CLK : in std_logic);
end counter;

architecture Behavioral of counter is

signal Q5_IN : std_logic_vector(7 downto 0); -- Defines internal signals
begin
Q5 <= Q5_IN; -- Set output
process(CLEAR, CLK) begin
if CLEAR='1' then -- Clear counter ?
Q5_IN <= "00000000"; -- Yes. Clear counter
elsif CLK='1' and CLK'event then -- Clock rising edge ?

if Q5_IN=128 then -- Yes. Count = 4 ?
Q5_IN <= "00000000"; -- Yes. Clear counter
else -- No
Q5_IN <= Q5_IN + '1'; -- Count-up
end if;

end if;
end process;
end Behavioral;
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
Elresearch
сообщение Jan 11 2006, 15:56
Сообщение #2


Местный
***

Группа: Свой
Сообщений: 214
Регистрация: 29-12-04
Пользователь №: 1 730



Вот два примера из Active-HDL. попробуйте их.

--library IEEE;
--use IEEE.std_logic_1164.all;
--use IEEE.STD_LOGIC_UNSIGNED.all;
-- CLK: in STD_LOGIC;
-- RESET: in STD_LOGIC;
-- CE: in STD_LOGIC;
-- LOAD: in STD_LOGIC;
-- DIR: in STD_LOGIC;
-- DIN: in STD_LOGIC_VECTOR (3 downto 0);
-- COUNT: out STD_LOGIC_VECTOR (3 downto 0)
signal COUNT_INT: STD_LOGIC_VECTOR(3 downto 0);
begin
process (CLK, RESET)
begin
if RESET = '1' then
COUNT_INT <= (others => '0');
elsif CLK'event and CLK='1' then
-- elsif rising_edge(CLK) then
if LOAD = '1' then
COUNT_INT <= DIN;
else
if CE = '1' then
if DIR = '1' then --count up
COUNT_INT <= COUNT_INT + 1;
else --count down
COUNT_INT <= COUNT_INT - 1;
end if;
end if;
end if;
end if;
end process;
COUNT <= COUNT_INT;

=========================


-- 0 to 15 Synchronous Counter (for INTEGERS)
-- CLK: in STD_LOGIC;
-- RESET: in STD_LOGIC;
-- CE, LOAD, DIR: in STD_LOGIC;
-- DIN: in INTEGER range 0 to 15;
-- COUNT: out INTEGER range 0 to 15;

--auxiliary signal COUNTER declaration
--the output port "COUNT" cannot appear on the right side of assignment
--statements
signal COUNTER: INTEGER range 0 to 15;

begin
process (CLK, RESET)
begin
if RESET='1' then
COUNTER <= 0;
elsif CLK='1' and CLK'event then
if LOAD='1' then
COUNTER <= DIN;
else
if CE='1' then
if DIR='1' then
if COUNTER = 15 then
COUNTER <= 0;
else
COUNTER <= COUNTER + 1;
end if;
else
if COUNTER = 0 then
COUNTER <= 15;
else
COUNTER <= COUNTER - 1;
end if;
end if;
end if;
end if;
end if;
end process;
COUNT <= COUNTER;
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 11th August 2025 - 16:55
Рейтинг@Mail.ru


Страница сгенерированна за 0.01513 секунд с 7
ELECTRONIX ©2004-2016