Professional Documents
Culture Documents
Exa
Exa
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity tb is
generic(
n: integer:=5 -- n bits
);
port (
clk,rst: in std_logic;
);
end TB;
architecture algoritmo of TB is
signal c: std_logic;
begin
algoritmo:process (qp,c)
begin
if (c='0') then
qn<=qp+1;
else
end if;
end process;
com9:process (qp)
begin
if (qp=25) then
c<= '1';
BT<='1';
else
c<= '0';
BT<='0';
end if;
end process;
secuencial:process (rst,clk)
begin
if(rst='0') then
qp<= qn;
end if;
end process;
end algoritmo;
maquina de estados
library IEEE;
use IEEE.std_logic_1164.all;
entity fsm_contador is
port(
CLK,RST: in std_logic;
BT,X: in std_logic;
);
end fsm_contador;
begin
begin
case Qp is
when "000"=>
Qn<="001";
Qn<="111";
else
Qn<=Qp;
end if;
CTD<="000";
when "001"=>
Qn<="000";
else
Qn<=Qp;
end if;
CTD<="001";
when "010"=>
Qn<="011";
Qn<="001";
else
Qn<=Qp;
end if;
CTD<="010";
when "011"=>
Qn<="100";
Qn<="010";
else
Qn<=Qp;
end if;
CTD<="011";
when "100"=>
if(X='1' and BT='1') then
Qn<="101";
Qn<="011";
else
Qn<=Qp;
end if;
CTD<="100";
when "101"=>
Qn<="110";
Qn<="100";
else
Qn<=Qp;
end if;
CTD<="101";
when "110"=>
Qn<="111";
Qn<="101";
else
Qn<=Qp;
end if;
CTD<="110";
when others=>
Qn<="000";
Qn<="110";
else
Qn<=Qp;
end if;
CTD<="111";
end case;
secuencial:process (RST,CLK)
begin
if(RST='0') then
Qp<="000";
then
Qp<=Qn;
end if;
end process;
end algoritmo;
top
library IEEE;
use IEEE.std_logic_1164.all;
entity top_contador is
port (
CLK,RST: in std_logic;
X: in std_logic;
);
end top_contador;
component fsm_contador is
port(
CLK,RST: in std_logic;
BT,X: in std_logic;
);
end component;
component tb is
port (
clk,rst: in std_logic;
);
end component;
begin
CTD<=SY;
end topcontador;