Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Автоматизация проектирования радиоэлектронных устройств связи..pdf
Скачиваний:
12
Добавлен:
15.11.2022
Размер:
5.53 Mб
Скачать

по

1. Описание на языке VHDL шифратора единичного кода в двоичный (длина единичного кода = 7)

library ieee;

use ieee.std_logic_1164.all;

entity shifr is port (

d:in std_logic_vector(6 downto 0);

q: out integer range 0 to 6

) ; end shifr;

architecture behaviour of shifr is begin

process begin

for j in 0 to 6 loop if d(j)='l' then

q <= j; end if;

end loop; end process;

end behaviour;

2. Описание на языке VHDL шифратора единичного кода в двоичный (длина единичного кода = 10)

library ieee;

use ieee.std_logic_1164.all;

entity shifr is port (

d: in std_logic_vector(9 downto 0); q: out integer range 0 to 9

); end shifr;

architecture behaviour of shifr is begin

process begin

for j in 0 to 9 loop if d (j)= ’1 * then

q <- j; end if;

end loop; end process;

end behaviour;

Описание на языке VHDL дешифратора двоичного кода в единичный

entity deshifr is port (

d:in integer range 0 to 6;

q:out std_logic_vector(6 downto 0)

);

end deshifr;

architecture behaviour of deshifr is begin

process begin

for j in 0 to 6 loop if j = d then

q (j ) <= eI е;

else

q (j ) <= 'O'; end if;

end loop; end process;

end behaviour;

library ieee;

use ieee.std_logic_1164.all; use ieee. std__logic_arith.all;

entity mx is port (

— информационные входы:

d: in std_logic_vector (6 downto 0) ;

— адресные входы:

a:in integer range 0 to 6;

q:out std_logic

) ; end mx;

architecture behaviour of mx is begin

q <= d (a); end behaviour;

2. Описание на языке VHDL мультиплексора 10x1

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_arith.all;

entity mx is port (

--информационные входы:

d:in std_logic__vector (9 downto 0);

— адресные входы:

a: in integer range 0 to 9; q: out std_logic

); end mx;

architecture behaviour of mx is begin

q <= d(a); end behaviour;

LIBRARY ieee;

USE ieee.std_logic_1164.all;

— описание интерфейса

кодера:

 

 

ENTITY coder_g IS

 

 

 

 

 

PORT (

 

u:

 

 

 

IN

STD_LOGIC;

 

elk,

 

reset:

 

control,

IN

STD_LOGIC;

 

v:

 

 

 

 

 

OUT

STD_LOGIC);

 

END coder_g;

 

 

 

 

 

 

 

— поведенческое описание архитектуры кодера:

ARCHITECTURE behaviour OF coder_g IS

 

— внутренние сигналы:

 

 

 

signal

kl,k2,k:

std_logic;

 

D-триггеры:

std_logic_vector(0 to

4);

signal

d:

 

begin

 

 

 

 

 

 

 

 

 

— ключи

 

xor

u;

 

 

 

 

k

<=

d (4)

 

 

 

 

kl

<=

k when control='l' else ’O';

 

k2 <= k when control='0' else 'O';

 

process

 

(elk,reset)

 

 

 

begin

if

reset='0'

then

— асинхронный

сброс

 

elsif

d <=

"ООООО”;

 

 

 

falling_edge(elk) then

 

 

 

 

 

— делитель на базе РЛЛОС:

 

 

 

 

 

d (0)

<=

kl;

 

 

 

 

 

 

 

d(l)

<=

d (0);

kl;

 

 

 

 

 

d (2)

<=

d (1)

xor

 

 

 

 

 

d (3)

<=

d (2);

xor

kl;

 

 

 

 

 

d(4)

<=

d(3)

 

выходной сигнал:

v<= k2 or u;

end if; end process;

end behaviour;