Professional Documents
Culture Documents
PRCTICA VHDL
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.std_logic_1164.all;
entity EJ_2 is
Port ( clk : in STD_LOGIC;
rstn : in STD_LOGIC;
a : in STD_LOGIC;
b : in STD_LOGIC;
x : in STD_LOGIC;
q : out STD_LOGIC);
end EJ_2;
architecture Behavioral of EJ_2 is
signal qt: std_logic;
begin
process (rstn, clk, a, b, x)
begin
if rstn= '0' then
qt <= '0';
elsif (clk'event and clk = '1') then
if x = '1' then
qt <= not(qt);
else
qt <= a and b;
end if;
end if;
end process;
q <= qt;
2
b : IN std_logic;
x : IN std_logic;
q : OUT std_logic
);
END COMPONENT;
signal clk : std_logic := '0';
signal rstn : std_logic := '0';
signal a : std_logic := '0';
signal b : std_logic := '0';
signal x : std_logic := '0';
signal q : std_logic;
constant clk_period : time := 10 ns;
BEGIN
uut: EJ_2 PORT MAP (
clk => clk,
rstn => rstn,
a => a,
b => b,
x => x,
q => q
);
rstn<= '1';
wait for 10 ns;
a <=
'1';
b <=
'1';
x <=
'0';
rstn<= '1';
wait for 10 ns;
a <=
'0';
b <=
'0';
x <=
'0';
rstn<= '1';
wait for 10 ns;
a <=
'0';
b <=
'0';
x <=
'1';
rstn<= '1';
wait for 10 ns;
wait;
end process;
END;
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
stim_proc: process
begin
a <=
'0';
b <=
'0';
x <=
'0';
rstn<= '0';
wait for 10 ns;
a <=
'1';
b <=
'1';
x <=
'1';
rstn<= '1';
wait for 10 ns;
a <=
'1';
b <=
'0';
x <=
'0';
rstn<= '1';
wait for 10 ns;
a <=
'0';
b <=
'0';
x <=
'0';
rstn<= '1';
wait for 10 ns;
a <=
'1';
b <=
'0';
x <=
'1';