You are on page 1of 6

Горбань Ю. В.

, КІ-18
Лабораторна робота № 4
Описання та моделювання тригерів та кінцевих автоматів

Завдання
1. З використанням дев’ятизначного алфавіту STD_LOGIC скласти VHDL-
модель і провести моделювання тригера двома способами:
 за логічною схемою(структурне описання);
 за таблицею функціонування тригера(алгоритмічне описання).
2. З використанням перелічених типів скласти VHDL-модель кінцевого
автомата і провести моделювання двома способами:
 за допомогою моделюючої програми;
 за допомогою скрипта (в цьому випадку передбачається використання
системи моделювання ActiveHDL).

Хід роботи

1. Структурне описання тригера


Тригер складається з логічних елементів, тому для створення моделі
тригеру необхідно створити моделі відповідних логічних елементів.

Модель логічного елементу AND:

library IEEE;
use IEEE.std_logic_1164.all;

entity and2 is
port(
A : in STD_LOGIC;
B : in STD_LOGIC;
Y : out STD_LOGIC
);
end and2;

architecture and2 of and2 is


begin

Y <= A and B after 2 ns;

end and2;

Модель логічного елементу NOR:


library IEEE;
use IEEE.std_logic_1164.all;

entity nor2 is
port(
A : in STD_LOGIC;
B : in STD_LOGIC;
Горбань Ю. В., КІ-18
Y : out STD_LOGIC
);
end nor2;

architecture nor2 of nor2 is


begin

Y <= not(A or B) after 3 ns;

end nor2;

Модель елементу NOT:


library IEEE;
use IEEE.std_logic_1164.all;

entity not_gate is
port(
A : in STD_LOGIC;
Y : out STD_LOGIC
);
end not_gate;

architecture not_gate of not_gate is


begin

Y <= not A after 2 ns;

end not_gate;

Структурний опис тригера:


library IEEE;
use IEEE.std_logic_1164.all;

entity DLatch is
port(
D : in std_logic;
C : in std_logic;
Q : out std_logic);

end DLatch;

architecture rtl of DLatch is


signal s1 : std_logic;
signal s2 : std_logic;
signal s3 : std_logic;
signal s4 : std_logic;
signal s5 : std_logic;
begin
not_1 : entity work.not_gate port map(
A => C,
Y => s1);
Горбань Ю. В., КІ-18
and2_1 : entity work.and2 port map(
A => D,
B => s1,
Y => s2);

and2_2 : entity work.and2 port map(


A => C,
B => s3,
Y => s4);

nor_1 : entity work.nor2 port map(


A => s2,
B => s4,
Y => s5);

not_2 : entity work.not_gate port map(


A => s5,
Y => s3);

Q <= s3;

end rtl;

Програма тестування тригера:


library IEEE;
use IEEE.std_logic_1164.all;

entity DLatch_Test is
end DLatch_Test;

architecture DLatch_Test of DLatch_Test is


signal D : std_logic;
signal C : std_logic;
signal Q : std_logic;
begin
latch : entity work.DLatch port map(
D => D,
C => C,
Q => Q);

process is
begin
wait for 10 ns;
D <= '0';
C <= '0';
wait for 10 ns;
D <= '0';
C <= '1';
wait for 10 ns;
D <= '1';
C <= '0';
wait for 10 ns;
Горбань Ю. В., КІ-18
D <= '1';
C <= '1';
wait for 10 ns;
D <= '0';
wait for 10 ns;
C <= '0';
wait for 10 ns;
wait;
end process;

end DLatch_Test;

Рисунок 4.1 – Часова діаграма роботи тригера

Алгоритмічне описання тригера:


library IEEE;
use IEEE.std_logic_1164.all;

entity DLatch1 is
port(
D : in std_logic;
C : in std_logic;
Q : out std_logic);
end DLatch1;

architecture rtl of DLatch1 is


signal Q_prev : std_logic;
begin
process(D, C) is
begin
if C = '0' then
Q <= D after 2 ns;
Q_prev <= D;
else
if C = '0' then
Q <= Q_prev;
end if;
end if;
end process;

end rtl;
Горбань Ю. В., КІ-18
Програма тестування:
entity DLatch1_test is
end DLatch1_test;

architecture DLatch1_test of DLatch1_test is


signal D : std_logic;
signal C : std_logic;
signal Q : std_logic;
begin

d_latch : entity work.DLatch1 port map(


D => D,
C => C,
Q => Q);

process is
begin
D <= '0';
C <= '0';
wait for 10 ns;
D <= '0';
C <= '1';
wait for 10 ns;
D <= '1';
wait for 3 ns;
C <= '0';
wait for 10 ns;
D <= '1';
C <= '1';
wait for 10 ns;
D <= '0';
wait for 10 ns;
C <= '0';
wait for 10 ns;
wait;
end process;

end DLatch1_test;

Рисунок 4.2 – Часова діаграма


Горбань Ю. В., КІ-18
2.
Таблиця функціонування автомата Мура
Вхідні Стани
сигнал а1 а2 а3
и
z1 а3 а2 а1
z2 а1 а2 а3
z3 а3 а1 а3
Вихідні w3 w1 w2
сигнал
и

Рисунок 4.3 – Діаграма станів автомата

Рисунок 4.4 – Часова діаграма роботи автомата

Висновок: в ході лабораторної роботи було засвоєно структурний та


алгоритмічний методи моделювання; з використанням обох методів створено
тригер та перевірено його роботу; з використанням засобів середовища
розробки ActiveHDL створено цифровий автомат.

You might also like