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

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

Отправлено yes 02 марта 2004 г. 15:51
В ответ на: Очень нужен генератор М-последовательности (VHDL) :( отправлено Ленточка 02 марта 2004 г. 00:39



m_seq.vhd



library IEEE;
use IEEE.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
-- pragma translate_off
library unisim;
use unisim.all;
-- pragma translate_on

entity m_seq
is generic (
LENGTH : integer := 7;
MASK : std_logic_vector := "1000001");
port (
DOUT : out std_logic;
CLK : in std_logic;
ENA : in std_logic
);

end m_seq;


architecture Struct of m_seq is

signal PRN_REG : std_logic_vector(LENGTH-1 downto 0);
signal PRN_REG_next : std_logic_vector(LENGTH-1 downto 0);

signal spi_c : std_logic_vector(2 downto 0);

-- purpose: convolution XOR
function BIT_CONV_XOR (
inp : std_logic_vector)
return std_logic is
variable res : std_logic := '0';
variable cnt : integer;
begin -- BIT_CONV_XOR
for cnt in inp'range loop
res := res xor inp(cnt);
end loop; -- cnt
return res;
end BIT_CONV_XOR;

begin

-- purpose: divide EXT clock (88MHz) by 8.
clk_divide : process (CLK)
begin -- process clk_divide
if CLK'event and CLK = '1' then -- rising clock edge
if ENA = '0' then -- synchronous reset
spi_c <= "000";
else
spi_c <= spi_c+'1';
end if;
end if;
end process clk_divide;

PRN_REG_next <= BIT_CONV_XOR(PRN_REG and MASK) & PRN_REG(PRN_REG'length-1 downto 1);
--DOUT<=PRN_REG_next(PRN_REG'length-1);

m_reg : process (CLK)
begin
if (CLK'event and CLK = '1') then
reg : if ENA = '0' then
PRN_REG <= not conv_std_logic_vector(0, PRN_REG'length);
DOUT <='0';
elsif spi_c = "001" then
PRN_REG <= PRN_REG_next;
DOUT <= PRN_REG(0);
end if reg;
end if;
end process m_reg;

end Struct;





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

Ответы


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

Имя (обязательно): 
Пароль: 
E-mail: 

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

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

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


Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru