Escolar Documentos
Profissional Documentos
Cultura Documentos
use IEEE.std_logic_1164.all;
entity and2 is
F: out std_logic);
end and2;
architecture primitive of and2 is
begin
F <= a and b;
end primitive;
library IEEE;
use IEEE.std_logic_1164.all;
entity and3 is
F: out std_logic);
end and3;
begin
end primitive;
library IEEE;
use IEEE.std_logic_1164.all;
entity automat is
port(ck,a,b,rn:in std_logic;
Q2,Q1,Q0:out std_logic);
end automat;
component clc is
port(Q2,Q1,Q0,a,b:in std_logic;
JK2,JK1,JK0:out std_logic);
end component;
begin
U1:cls port map
(D2=>netJK2,D1=>netJK1,D0=>netJK0,ck=>net_ck,Rn=>rn,Q2=>netQ2,Q1=>netQ1,Q0=>netQ0);
U2:clc port map
(JK2=>netJK2,JK1=>netJK1,JK0=>netJK0,a=>a,b=>b,Q2=>netQ2,Q1=>netQ1,Q0=>netQ0);
U3:divizor port map (clk=>ck, clk_out=>net_ck);
Q2 <= netQ2;
Q1 <= netQ1;
Q0 <= netQ0;
end;
library IEEE;
use IEEE.std_logic_1164.all;
entity clc is
port (Q2, Q1, Q0, a,b: in std_logic;
Y,JK2,JK1,JK0: out std_logic);
end clc;
component and2
port (a: in std_logic;
b: in std_logic;
F: out std_logic);
end component;
component and3
port (a: in std_logic;
b: in std_logic;
c: in std_logic;
F: out std_logic);
end component;
component or2
port (a: in std_logic;
b: in std_logic;
F: out std_logic;
Y: out std_logic);
end component;
component or3
port (a: in std_logic;
b: in std_logic;
c: in std_logic;
F: out std_logic;
Y: out std_logic);
end component;
signal net1 : std_logic;
signal net2 : std_logic;
signal net3 : std_logic;
signal net4 : std_logic;
signal net5 : std_logic;
signal net6 : std_logic;
signal net7 : std_logic;
signal net8 : std_logic;
signal an :std_logic;
signal Q2n :std_logic;
signal Q1n :std_logic;
signal Q0n :std_logic;
begin
an <= not a;
Q2n <= not Q2;
Q1n <= not Q1;
Q0n <= not Q0;
U1: and3 port map (a => an, b => Q2n, c => Q0n, F => net1);
U2: and3 port map (a => b, b => Q2n, c => Q0, F => net2);
U3: and3 port map (a => a, b => Q1, c => Q0, F => net3);
U4: or3 port map (a => net1, b => net2, c => net3, F => Y, Y => JK2);
U5: and3 port map (a => an, b => Q2n, c => Q0, F => net4);
U6: and3 port map (a => an, b => Q2, c => Q1n, F => net5);
U7: and3 port map (a => a, b => Q2, c => Q0, F => net6);
U8: or3 port map (a => net4, b => net5, c => net6, F => Y, Y => JK1);
U9: and2 port map (a => a, b => Q1n, F => net7);
U10: and2 port map (a => Q2, b => Q1, F => net8);
U11: or2 port map (a => net7, b => net8, F => Y, Y => JK0);
end structural;
library ieee;
use ieee.std_logic_1164.all;
entity cls is
port(D2,D1,D0,ck,rn: in std_logic;
Q2,Q1,Q0: out std_logic);
end entity;
component JK is
port ( J,K, ck, Rn : in std_logic;
Q, Qn: out std_logic);
end component;
begin
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
library IEEE;
use IEEE.std_logic_1164.all;
entity JK is
architecture behavior of JK is
begin
if Rn = '0' then
Qint <= D;
end if;
end process;
Q <= Qint;
end behavior;
library IEEE;
use IEEE.std_logic_1164.all;
entity or2 is
library IEEE;
use IEEE.std_logic_1164.all;
entity or3 is
port (a,b,c: in std_logic;
Y,F: out std_logic);
end or3;
architecture primitive of or3 is
begin
F <= a or b or c;
end primitive;
library IEEE;
use IEEE.std_logic_1164.all;
entity test_automat is
end test_automat;
begin
UUT:automat port map (ck => ck, a => a, b => b,rn => rn, Q2 => Q2, Q1 => Q1, Q0 =>
Q0);
gen_ck: process
begin
ck <= '0';
wait for 0.5 ns;
ck <= '1';
wait for 0.5 ns;
end process;
gen_a: process
begin
a <= '0' after 0 ns, '1' after 500 ns, '0' after 900 ns;
wait;
end process;
gen_b: process
begin
b <= '0' after 0 ns, '1' after 600 ns, '0' after 1000 ns;
wait;
end process;
gen_rn: process
begin
rn <= '1';
wait for 5 ns;
rn <= '0';
wait for 5 ns;
rn <= '1';
wait;
end process;
end testbench;
library ieee;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity test_divizor is
end test_divizor;
signal clk,clk_out:std_logic;
begin
UUT : divizor port map (clk => clk, clk_out => clk_out );
gen_clk: process
begin
clk <= '1';
wait for period/2;
clk <= '0';
wait for period/2;
end process;
end testbench;