Professional Documents
Culture Documents
2.
3.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Celu_mod is
end Celu_mod;
architecture Behavioral of Celu_mod is
signal ep:estados;
signal clk_4Hz_S:std_logic;
begin
process(clk)
begin
if (rising_edge(clk)) then
t:=t+1;
if (t<=1) then
clk_4Hz_s<='1';
clk_4Hz_s<='0';
else
t:=0;
end if;
end if;
end process;
process(clk_4Hz,B2,B3)
begin
if (rising_edge(clk_4Hz_s)) then
case ep is
when START=>
ep<=A_E;
ST<=’1’;
ep<=D_E;
ST<=’1’;
end if;
when A_E=>
ti<=ti+1;
ep<=A_E;
ep<=DOS_E;
ST<=’1’;
ep<=D_E;
ep<=START; A_out<=’1’;
A_out<=1;ST<=’1’;
end if;
when DOS_E=>
ti<=ti+1;
ep<=DOS_E;
ep<=A_E;
ST<=’1’;
DOS_out<=’1’; ST<=’1’;
ep<=D_E;
ti<=0;
end if;
when TRES_E=>
ti<=ti+1;
ep<=TRES_e;
ep<=D_E; ST<=’1’;
ep<=START;
TRES_out<=’1’;
ep<=A_E;
TRES_out<=’1’; ST<=’1’;
end if;
when D_E=>
ti<=ti+1;
ep<=D_e;
ep<=START; D_out<=’1’;
ep<=A_E;
ST<=’1’;
ep<=TRES_E;
ST<=’1’;
end if;
end case;
end if;
end process;
process(ep)
begin
case ep is
when START=>
est<="000";
when A_E=>
est<="010";
when DOS_E=>
est<="001";
when TRES_E=>
est<="100";
when D_E=>
est<="011";
end case;
end process;
end Behavioral;
4.
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity ControlUnit is
port (
clk : in std_logic; -- clock
rst_n : in std_logic; -- reset
inicio : in std_logic; -- señal de inicio
otra_carta : in std_logic; -- otra carta
plantarse : in std_logic; -- plantarse
status : in std_logic_vector(1 downto 0);
maquina_lista : out std_logic; -- maquina lista
ctrl : out std_logic_vector(8 downto 0)); -- Control
end ControlUnit;
-- señal estados
type t_st is (s0, s1, s2, s3);
signal current_state, next_state : t_st;
-- señales status
begin
case current_state is
when s0 =>
maquina_lista <= '1';
rst_con <= '1';
rst_acc <= '1';
rst_zer <= '1';
when s1 =>
when s2 =>
ld_acc <= '1';
ld_zero <= '1';
next_state <= s3;
when s3 =>
end arch_ControlUnit;