ПЦУСБ/Лабораторная работа 4 — различия между версиями
Материал из Wiki
< ПЦУСБ
ANA (обсуждение | вклад) м |
ANA (обсуждение | вклад) м (→Варианты заданий) |
||
Строка 79: | Строка 79: | ||
== Варианты заданий == | == Варианты заданий == | ||
− | + | === Преобразователь из кода Грея в двоичный код 8-разрядного числа === | |
− | + | ||
− | + | * входы подключить к переключателям | |
− | + | * выходы подключить к линейке светодиодов | |
− | + | ||
− | + | {{Hider|Листинг VHDL-модели}}{{Файл|gray_to_binary.vhd|<big><source lang="vhdl"> | |
+ | library ieee; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | |||
+ | entity gray_to_binary is | ||
+ | |||
+ | port ( | ||
+ | x : in std_logic_vector(7 downto 0); | ||
+ | y : out std_logic_vector(7 downto 0)); | ||
+ | |||
+ | end entity gray_to_binary; | ||
+ | |||
+ | architecture beh of gray_to_binary is | ||
+ | signal a : std_logic_vector (7 downto 0); | ||
+ | begin | ||
+ | a(7) <= X(7); | ||
+ | a(6) <= X(6) xor X(7); | ||
+ | gen : for i in 6 downto 1 generate | ||
+ | a(i-1) <= a(i) xor X(i-1); | ||
+ | end generate; | ||
+ | y <= a; | ||
+ | |||
+ | end beh; | ||
+ | </source> | ||
+ | </big>}}{{Hider|end}} | ||
+ | |||
+ | |||
+ | === Преобразователь из двоичного кода в код Грея 8-разрядного числа=== | ||
+ | |||
+ | * входы подключить к переключателям | ||
+ | * выходы подключить к линейке светодиодов | ||
+ | |||
+ | {{Hider|Листинг VHDL-модели}}{{Файл|binary_to_gray.vhd|<big><source lang="vhdl"> | ||
+ | library ieee; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | |||
+ | entity binary_to_gray is | ||
+ | |||
+ | port( | ||
+ | x : in std_logic_vector(7 downto 0); | ||
+ | y : out std_logic_vector(7 downto 0)); | ||
+ | |||
+ | end binary_to_gray; | ||
+ | |||
+ | architecture beh of binary_to_gray is | ||
+ | |||
+ | begin -- beh | ||
+ | |||
+ | y(7) <= x(7); | ||
+ | y(6) <= x(7) xor x(6); | ||
+ | y(5) <= x(6) xor x(5); | ||
+ | y(4) <= x(5) xor x(4); | ||
+ | y(3) <= x(4) xor x(3); | ||
+ | y(2) <= x(3) xor x(2); | ||
+ | y(1) <= x(2) xor x(1); | ||
+ | y(0) <= x(1) xor x(0); | ||
+ | |||
+ | end beh; | ||
+ | </source> | ||
+ | </big>}}{{Hider|end}} | ||
+ | |||
+ | |||
+ | === Счетчик числа единиц и определение четности N-разрядного числа=== | ||
+ | <!-- | ||
+ | {{Hider|Листинг VHDL-модели}}{{Файл|Имя файла|<big><source lang="vhdl"> | ||
+ | |||
+ | </source> | ||
+ | </big>}}{{Hider|end}}--> | ||
+ | |||
+ | |||
+ | === Умножитель (4-разрядное число × 4-разрядное число)=== | ||
+ | |||
+ | * входы подключить к переключателям | ||
+ | * выходы подключить к линейке светодиодов | ||
+ | |||
+ | {{Hider|Листинг VHDL-модели}}{{Файл|Имя файла|<big><source lang="vhdl"> | ||
+ | library ieee; | ||
+ | use ieee.numeric_std.all; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | |||
+ | entity mult_4_4 is | ||
+ | |||
+ | port ( | ||
+ | a : in std_logic_vector(3 downto 0); | ||
+ | b : in std_logic_vector(3 downto 0); | ||
+ | c : out std_logic_vector(7 downto 0)); | ||
+ | |||
+ | end entity mult_4_4; | ||
+ | |||
+ | architecture beh of mult_4_4 is | ||
+ | |||
+ | begin -- architecture beh | ||
+ | |||
+ | c <= std_logic_vector(unsigned(a) * unsigned(b)); | ||
+ | |||
+ | end architecture beh; | ||
+ | </source> | ||
+ | </big>}}{{Hider|end}} | ||
+ | |||
+ | |||
+ | === Сумматор (4-разрядное число + 4-разрядное число)=== | ||
+ | |||
+ | * входы подключить к переключателям | ||
+ | * выходы подключить к линейке светодиодов | ||
+ | |||
+ | {{Hider|Листинг VHDL-модели}}{{Файл|Имя файла|<big><source lang="vhdl"> | ||
+ | library ieee; | ||
+ | use ieee.numeric_std.all; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | |||
+ | entity sum_4_4 is | ||
+ | |||
+ | port ( | ||
+ | a : in std_logic_vector(3 downto 0); | ||
+ | b : in std_logic_vector(3 downto 0); | ||
+ | c : out std_logic_vector(4 downto 0)); | ||
+ | |||
+ | end entity sum_4_4; | ||
+ | |||
+ | architecture beh of sum_4_4 is | ||
+ | |||
+ | begin -- architecture beh | ||
+ | |||
+ | c <= std_logic_vector(unsigned(a) + ('0' & unsigned(b))); | ||
+ | |||
+ | end architecture beh; | ||
+ | </source> | ||
+ | </big>}}{{Hider|end}} | ||
+ | |||
+ | |||
+ | === Дешифратор из 3 в 8 === | ||
+ | |||
+ | * входы подключить к кнопкам | ||
+ | * выходы подключить к линейке светодиодов | ||
+ | |||
+ | {{Hider|Листинг VHDL-модели}}{{Файл|decoder_3_in_8.vhd|<big><source lang="vhdl"> | ||
+ | library ieee; | ||
+ | use ieee.std_logic_1164.all; | ||
+ | use ieee.numeric_std.all; | ||
+ | |||
+ | entity decoder_3_in_8 is | ||
+ | port ( | ||
+ | x : in std_logic_vector(2 downto 0); | ||
+ | y : out std_logic_vector(7 downto 0)); | ||
+ | end decoder_3_in_8; | ||
+ | |||
+ | architecture beh of decoder_3_in_8 is | ||
+ | begin | ||
+ | gen : for i in 0 to 7 generate | ||
+ | Y(i) <= '1' when i = unsigned(x) else '0'; | ||
+ | end generate; | ||
+ | end beh; | ||
+ | </source> | ||
+ | </big>}}{{Hider|end}} | ||
<!-- | <!-- |
Версия 16:53, 27 ноября 2013
Лекции ПЦУСБ
Лекции
Практические
Тесты
Лабораторные
- Лабораторная работа 1
- Лабораторная работа 2
- Лабораторная работа 3
- Лабораторная работа 4
Доп. материалы
Цель работы
Получить базовые навыки работы в программе ISE (создание проекта, подключение файла конфигурации, синтез схемы, сохранение синтезированной схемы в VHDL формате, программирование ПЛИС).
Задание
Реализовать заданный VHDL-моделью цифровой блок в ПЛИС, используя отладочную плату Spartan-3 Starter Kit, общий вид которой представлен на рисунке 1.
Порядок выполнения работы
Описание доступных ресурсов ПЛИС
Описание интерфейса блока верхнего уровня (TOP-модуль)
library ieee; use ieee.std_logic_1164.all; entity top is port( CLK : in std_logic; -- синхросигнал 50 МГц (T9) BTN : in std_logic_vector(3 downto 0); -- кнопки (L14 L13 M14 M13) SW : in std_logic_vector(7 downto 0); -- переключатели (K13 K14 J13 J14 H13 H14 G12 F12) -- полоска светодиодов LED : out std_logic_vector(7 downto 0); -- P11 P12 N12 P13 N14 L12 P14 K12 -- семисегментный индикатор SEG : out std_logic_vector(7 downto 0); -- P16 N16 F13 R16 P15 N15 G13 E14 AN : out std_logic_vector(3 downto 0); -- E13 F14 G14 D14 -- выводы интерфейса RS232 RXD : in std_logic_vector(1 downto 0); -- N10 T13 TXD : out std_logic_vector(1 downto 0); -- T14 R13 -- выводы интерфейса VGA GRB : out std_logic_vector(2 downto 0); -- T12 R12 R11 VH : out std_logic_vector(1 downto 0); -- T10 R9 -- выводы интерфейса PS2 PS2 : inout std_logic_vector(1 downto 0); -- M16 M15 -- выводы подключения внешнего ОЗУ ADDR : out std_logic_vector(17 downto 0); -- L3 K5 K3 J3 J4 H4 H3 G5 E4 E3 F4 F3 G4 L4 M3 M4 N3 L5 DATA : inout std_logic_vector(31 downto 0); -- N1 M1 K2 C3 F5 G1 E2 D2 D1 E1 G2 J1 K1 M2 N2 P2 R1 P1 L2 J2 H1 F2 P8 D3 B1 C1 C2 R5 T5 R6 T8 N7 CE : out std_logic_vector(1 downto 0); -- N5 P7 OE : out std_logic; -- K4 WE : out std_logic; -- G3 BSEL : out std_logic_vector(3 downto 0)); -- R4 P5 T4 P6 end; architecture beh of top is begin -- отключение неиспользуемых выводов ADDR <= "000000000000000000"; DATA <= "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"; CE <= "11"; OE <= '1'; WE <= '1'; BSEL <= x"0"; TXD <= "11"; PS2 <= "ZZ"; GRB <= "000"; VH <= "00"; LED <= x"00"; SEG <= x"00"; AN <= x"F"; end architecture beh;

Рисунок 1 — Spartan-3 Starter Kit

Рисунок 2 — Spartan-3 Starter Kit
Варианты заданий
Преобразователь из кода Грея в двоичный код 8-разрядного числа
- входы подключить к переключателям
- выходы подключить к линейке светодиодов
Листинг VHDL-модели
Файл: gray_to_binary.vhd |
library ieee; use ieee.std_logic_1164.all; entity gray_to_binary is port ( x : in std_logic_vector(7 downto 0); y : out std_logic_vector(7 downto 0)); end entity gray_to_binary; architecture beh of gray_to_binary is signal a : std_logic_vector (7 downto 0); begin a(7) <= X(7); a(6) <= X(6) xor X(7); gen : for i in 6 downto 1 generate a(i-1) <= a(i) xor X(i-1); end generate; y <= a; end beh; |
Преобразователь из двоичного кода в код Грея 8-разрядного числа
- входы подключить к переключателям
- выходы подключить к линейке светодиодов
Листинг VHDL-модели
Файл: binary_to_gray.vhd |
library ieee; use ieee.std_logic_1164.all; entity binary_to_gray is port( x : in std_logic_vector(7 downto 0); y : out std_logic_vector(7 downto 0)); end binary_to_gray; architecture beh of binary_to_gray is begin -- beh y(7) <= x(7); y(6) <= x(7) xor x(6); y(5) <= x(6) xor x(5); y(4) <= x(5) xor x(4); y(3) <= x(4) xor x(3); y(2) <= x(3) xor x(2); y(1) <= x(2) xor x(1); y(0) <= x(1) xor x(0); end beh; |
Счетчик числа единиц и определение четности N-разрядного числа
Умножитель (4-разрядное число × 4-разрядное число)
- входы подключить к переключателям
- выходы подключить к линейке светодиодов
Листинг VHDL-модели
Файл: Имя файла |
library ieee; use ieee.numeric_std.all; use ieee.std_logic_1164.all; entity mult_4_4 is port ( a : in std_logic_vector(3 downto 0); b : in std_logic_vector(3 downto 0); c : out std_logic_vector(7 downto 0)); end entity mult_4_4; architecture beh of mult_4_4 is begin -- architecture beh c <= std_logic_vector(unsigned(a) * unsigned(b)); end architecture beh; |
Сумматор (4-разрядное число + 4-разрядное число)
- входы подключить к переключателям
- выходы подключить к линейке светодиодов
Листинг VHDL-модели
Файл: Имя файла |
library ieee; use ieee.numeric_std.all; use ieee.std_logic_1164.all; entity sum_4_4 is port ( a : in std_logic_vector(3 downto 0); b : in std_logic_vector(3 downto 0); c : out std_logic_vector(4 downto 0)); end entity sum_4_4; architecture beh of sum_4_4 is begin -- architecture beh c <= std_logic_vector(unsigned(a) + ('0' & unsigned(b))); end architecture beh; |
Дешифратор из 3 в 8
- входы подключить к кнопкам
- выходы подключить к линейке светодиодов
Листинг VHDL-модели
Файл: decoder_3_in_8.vhd |
library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity decoder_3_in_8 is port ( x : in std_logic_vector(2 downto 0); y : out std_logic_vector(7 downto 0)); end decoder_3_in_8; architecture beh of decoder_3_in_8 is begin gen : for i in 0 to 7 generate Y(i) <= '1' when i = unsigned(x) else '0'; end generate; end beh; |