D – триггер
Исследование работы триггера.
Цель работы:
Изучение принципов функционирования простейшего конечного автомата.
RS-триггер
library ieee;
use ieee.std_logic_1164.all;
entity trs is
generic (delay:time:=2 ns);
port(
r,s: in std_logic;
q,nq: out std_logic
);
end trs;
architecture arch of trs is
signal p,np: std_logic;
begin
process (r,s)
begin
if r='0' and s='0' then p<='1' after delay;
np<='1' after delay;
elsif r='0' and s='1' then p<='0' after 2*delay;
np<='1' after delay;
elsif r='1' and s='0' then p<='1' after delay;
np<='0' after 2*delay;
elsif r='1' and s='1'then p<='X'; np<='X';
end if;
end process;
q<=p;
nq<=np;
end arch;
D – триггер
library ieee;
use ieee.std_logic_1164.all;
entity tr is
port(
data_i: in std_logic;
clk_i: in std_logic;
s : in std_logic;
r : in std_logic;
data_out: out std_logic
);
end tr;
architecture arch of tr is
begin
process (clk_i,s,r)
begin
if r='0' then
data_out<='0';
elsif s='0' then
data_out<='1';
elsif(rising_edge(clk_i)) then
data_out <= data_i;
end if;
end process;
end arch;