[an error occurred while processing this directive]
не работает uart на vhdl
(«Телесистемы»: Конференция «Языки описания аппаратуры (VHDL и др.))

миниатюрный аудио-видеорекордер mAVR

Отправлено denruss 01 июня 2006 г. 10:01

Написал uart, самый простейший...
передатчик работает отлично, приёмник начинает работать только со 2-й минуты. После недели разбирательств я нашёл в инете другой uart. Работает точно также как и написанный мною. В чём проблема? Вот мой код (приёмник):

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity receiver is
port ( clk: in std_logic;
rxd: in std_logic;
data: out std_logic_vector (0 to 7);
en26d: out std_logic; -- если '1' то идёт приём
priem: out std_logic -- при принятии посылки переходит из '0' -> '1'
);
end receiver;

architecture uart of receiver is

signal clk26div : std_logic;
signal en26div : std_logic :='0';
signal t: integer range 0 to 11;
signal temp: std_logic_vector (0 to 10);
signal tpr : std_logic;


begin

process (rxd, t, clk26div, en26div) -- ловим перепад стартового бита
begin
if (clk26div='0' and t=10) then
en26div<='0';
elsif (rxd'event and rxd='0' and en26div='0') then
en26div<='1';
end if;
en26d<=en26div;
end process;

process (clk26div, en26div) -- принимаем данные
begin
if (en26div='0') then
t<=0;
elsif (clk26div'event and clk26div='1') then
temp(t)<=rxd;
t<=t+1;
end if;
end process;

process(en26div, t, clk)
variable parity: std_logic;

begin
if (t=1 and clk='0') then
tpr <= '0';
elsif (en26div'event and en26div='0') then
parity:='0';
for i in 1 to 8 loop -- считаем бит паритета
parity:=parity xor temp(i);
end loop;
if (parity=temp(9) and temp(0)='0') then -- и если посылка без ошибки, принимаем

-- первый разряд - старший
-- data(0)<=temp(1);
-- data(1)<=temp(2);
-- data(2)<=temp(3);
-- data(3)<=temp(4);
-- data(4)<=temp(5);
-- data(5)<=temp(6);
-- data(6)<=temp(7);
-- data(7)<=temp(8);

-- первый разряд - младший
data(0)<=temp(8);
data(1)<=temp(7);
data(2)<=temp(6);
data(3)<=temp(5);
data(4)<=temp(4);
data(5)<=temp(3);
data(6)<=temp(2);
data(7)<=temp(1);

tpr <= '1';
end if;
end if;
end process;

process (clk) -- задержка установлени сигнала priem на 1 такт
begin
if (clk'event and clk='1') then
priem <= tpr;
end if;
end process;


process (clk, en26div) -- деление, для получения нужной скорости передачи и приёма
-- 6000/(26*2)=115.384
variable temp: integer range 0 to 26;
variable clkdiv: std_logic;

begin
if (en26div='0') then
temp:=0;
elsif (clk'event and clk='1') then
if (temp=26 and en26div='1') then
clkdiv:=not clkdiv;
temp:=0;
end if;
temp:=temp+1;
end if;
clk26div<=clkdiv;
end process;


end uart;

Составить ответ  |||  Конференция  |||  Архив

Ответы


Отправка ответа

Имя (обязательно): 
Пароль: 
E-mail: 
NoIX ключ Запомнить

Тема (обязательно):
Сообщение:

Ссылка на URL: 
Название ссылки: 

URL изображения: 


Rambler's Top100 Рейтинг@Mail.ru
Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание

E-mail: info@telesys.ru