Вы находитесь на странице: 1из 6

ibrary IEEE;

use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;

entity practica7 is
port (

clk50mhz: in STD_LOGIC;
reset: in STD_LOGIC;
s: inout std_logic_vector(5 downto 0);
jf,kf,ss: in std_logic;
salida: out std_logic_vector (5 downto 0);
Y: out std_logic_vector (13 downto 0);

clk: out STD_LOGIC


);
end practica7;

architecture rtl of practica7 is


constant max_count: INTEGER := 10000000;
signal count: INTEGER range 0 to max_count;
signal clk_state: STD_LOGIC := '0';
signal ja,ka,jb,kb,jc,kc,jd,kd,je,ke: std_logic := '0';
signal qa,qb,qc,qd,qe,qf: std_logic := '0';
signal led: std_logic_vector (5 downto 0);
signal vcd: std_logic_vector (6 downto 0);
signal vcdd: std_logic_vector (6 downto 0);

begin
ja<= qb and qc and qd and qe and qf;
ka<= qb and qc and qd and qe and qf;
jb<= qc and qd and qe and qf;
kb<= qc and qd and qe and qf;
jc<= qd and qe and qf;
kc<= qd and qe and qf;
jd<= qe and qf;
kd<= qe and qf;
je<= qf;
ke<= qf;

gen_clock: process(clk50mhz, clk_state, count)


begin
if clk50mhz'event and clk50mhz='1' then
if count < max_count then
count <= count+1;
else
clk_state <= not clk_state;
count <= 0;
end if;
end if;
end process;

flipa: process(ja,ka,clk_state)
begin
if(reset='1')then
qa<='0';
elsif(clk_state'event and clk_state='1')then
if(ja='0' and ka='0')then
qa<=qa;
elsif(ja='0' and ka='1')then
qa<='0';
elsif(ja='1' and ka='0')then
qa<='1';
elsif(ja='1' and ka='1')then
qa<=not qa;
end if;
end if;
end process;

flipb: process(jb,kb,clk_state)
begin
if(reset='1')then
qb<='0';
elsif(clk_state'event and clk_state='1')then
if(jb='0' and kb='0')then
qb<=qb;
elsif(jb='0' and kb='1')then
qb<='0';
elsif(jb='1' and kb='0')then
qb<='1';
elsif(jb='1' and kb='1')then
qb<=not qb;
end if;
end if;
end process;

flipc: process(jc,kc,clk_state)
begin
if(reset='1')then
qc<='0';
elsif(clk_state'event and clk_state='1')then
if(jc='0' and kc='0')then
qc<=qc;
elsif(jc='0' and kc='1')then
qc<='0';
elsif(jc='1' and kc='0')then
qc<='1';
elsif(jc='1' and kc='1')then
qc<=not qc;
end if;
end if;
end process;

flipd: process(jd,kd,clk_state)
begin
if(reset='1')then
qd<='0';
elsif(clk_state'event and clk_state='1')then
if(jd='0' and kd='0')then
qd<=qd;
elsif(jd='0' and kd='1')then
qd<='0';
elsif(jd='1' and kd='0')then
qd<='1';
elsif(jd='1' and kd='1')then
qd<=not qd;
end if;
end if;
end process;

flipe: process(je,ke,clk_state)
begin
if(reset='1')then
qe<='0';
elsif(clk_state'event and clk_state='1')then
if(je='0' and ke='0')then
qe<=qe;
elsif(je='0' and ke='1')then
qe<='0';
elsif(je='1' and ke='0')then
qe<='1';
elsif(je='1' and ke='1')then
qe<=not qe;
end if;
end if;
end process;

flipf: process(jf,kf,clk_state)
begin
if(reset='1')then
qf<='0';
elsif(clk_state'event and clk_state='1')then
if(jf='0' and kf='0')then
qf<=qf;
elsif(jf='0' and kf='1')then
qf<='0';
elsif(jf='1' and kf='0')then
qf<='1';
elsif(jf='1' and kf='1')then
qf<=not qf;
end if;
end if;
end process;

clk <= clk_state;

s(0)<= qa;
s(1)<= qb;
s(2)<= qc;
s(3)<= qd;
s(4)<= qe;
s(5)<= qf;

led(5)<=not qa;
led(4)<=not qb;
led(3)<=not qc;
led(2)<=not qd;
led(1)<=not qe;
led(0)<=not qf;

process(ss)
begin
if(ss='1') then

case led is
when"000000"=>Y<="00000010000001";--0
when"000001"=>Y<="00000011001111";--1
when"000010"=>Y<="00000010010010";--2
when"000011"=>Y<="00000010000110";--3
when"000100"=>Y<="00000011001100";--4
when"000101"=>Y<="00000010100100";--5
when"000110"=>Y<="00000010100000";--6
when"000111"=>Y<="00000010001111";--7
when"001000"=>Y<="00000010000000";--8
when"001001"=>Y<="00000010001100";--9
when"001010"=>Y<="10011110000001";--10
when"001011"=>Y<="10011111001111";--11
when"001100"=>Y<="10011110010010";--12
when"001101"=>Y<="10011110000110";--13
when"001110"=>Y<="10011111001100";--14
when"001111"=>Y<="10011110100100";--15
when"010000"=>Y<="10011110100000";--16
when"010001"=>Y<="10011110001111";--17
when"010010"=>Y<="10011110000000";--18
when"010011"=>Y<="10011110001100";--19
when"010100"=>Y<="00100100000001";--20
when"010101"=>Y<="00100101001111";--21
when"010110"=>Y<="00100100010010";--22
when"010111"=>Y<="00100100000110";--23
when"011000"=>Y<="00100101001100";--24
when"011001"=>Y<="00100100100100";--25
when"011010"=>Y<="00100100100000";--26
when"011011"=>Y<="00100100001111";--27
when"011100"=>Y<="00100100000000";--28
when"011101"=>Y<="00100100001100";--29
when"011110"=>Y<="00001100000001";--30
when"011111"=>Y<="00001101001111";--31
when"100000"=>Y<="00001100010010";--32
when"100001"=>Y<="00001100000110";--33
when"100010"=>Y<="00001101001100";--34
when"100011"=>Y<="00001100100100";--35
when"100100"=>Y<="00001100100000";--36
when"100101"=>Y<="00001100001111";--37
when"100110"=>Y<="00001100000000";--38
when"100111"=>Y<="00001100001100";--39
when"101000"=>Y<="10011000000001";--40
when"101001"=>Y<="10011001001111";--41
when"101010"=>Y<="10011000010010";--42
when"101011"=>Y<="10011000000110";--43
when"101100"=>Y<="10011001001100";--44
when"101101"=>Y<="10011000100100";--45
when"101110"=>Y<="10011000100000";--46
when"101111"=>Y<="10011000001111";--47
when"110000"=>Y<="10011000000000";--48
when"110001"=>Y<="10011000001100";--49
when"110010"=>Y<="01001000000001";--50
when"110011"=>Y<="01001001001111";--51
when"110100"=>Y<="01001000010010";--52
when"110101"=>Y<="01001000000110";--53
when"110110"=>Y<="01001001001100";--54
when"110111"=>Y<="01001000100100";--55
when"111000"=>Y<="01001000100000";--56
when"111001"=>Y<="01001000001111";--57
when"111010"=>Y<="01001000000000";--58
when"111011"=>Y<="01001000001100";--59
when"111100"=>Y<="01000000000001";--60
when"111101"=>Y<="01000001001111";--61
when"111110"=>Y<="01000000010010";--62
when"111111"=>Y<="01000000000110";--63
end case;
else

case not led is


when"000000"=>Y<="00000010000001";--0
when"000001"=>Y<="00000011001111";--1
when"000010"=>Y<="00000010010010";--2
when"000011"=>Y<="00000010000110";--3
when"000100"=>Y<="00000011001100";--4
when"000101"=>Y<="00000010100100";--5
when"000110"=>Y<="00000010100000";--6
when"000111"=>Y<="00000010001111";--7
when"001000"=>Y<="00000010000000";--8
when"001001"=>Y<="00000010001100";--9
when"001010"=>Y<="10011110000001";--10
when"001011"=>Y<="10011111001111";--11
when"001100"=>Y<="10011110010010";--12
when"001101"=>Y<="10011110000110";--13
when"001110"=>Y<="10011111001100";--14
when"001111"=>Y<="10011110100100";--15
when"010000"=>Y<="10011110100000";--16
when"010001"=>Y<="10011110001111";--17
when"010010"=>Y<="10011110000000";--18
when"010011"=>Y<="10011110001100";--19
when"010100"=>Y<="00100100000001";--20
when"010101"=>Y<="00100101001111";--21
when"010110"=>Y<="00100100010010";--22
when"010111"=>Y<="00100100000110";--23
when"011000"=>Y<="00100101001100";--24
when"011001"=>Y<="00100100100100";--25
when"011010"=>Y<="00100100100000";--26
when"011011"=>Y<="00100100001111";--27
when"011100"=>Y<="00100100000000";--28
when"011101"=>Y<="00100100001100";--29
when"011110"=>Y<="00001100000001";--30
when"011111"=>Y<="00001101001111";--31
when"100000"=>Y<="00001100010010";--32
when"100001"=>Y<="00001100000110";--33
when"100010"=>Y<="00001101001100";--34
when"100011"=>Y<="00001100100100";--35
when"100100"=>Y<="00001100100000";--36
when"100101"=>Y<="00001100001111";--37
when"100110"=>Y<="00001100000000";--38
when"100111"=>Y<="00001100001100";--39
when"101000"=>Y<="10011000000001";--40
when"101001"=>Y<="10011001001111";--41
when"101010"=>Y<="10011000010010";--42
when"101011"=>Y<="10011000000110";--43
when"101100"=>Y<="10011001001100";--44
when"101101"=>Y<="10011000100100";--45
when"101110"=>Y<="10011000100000";--46
when"101111"=>Y<="10011000001111";--47
when"110000"=>Y<="10011000000000";--48
when"110001"=>Y<="10011000001100";--49
when"110010"=>Y<="01001000000001";--50
when"110011"=>Y<="01001001001111";--51
when"110100"=>Y<="01001000010010";--52
when"110101"=>Y<="01001000000110";--53
when"110110"=>Y<="01001001001100";--54
when"110111"=>Y<="01001000100100";--55
when"111000"=>Y<="01001000100000";--56
when"111001"=>Y<="01001000001111";--57
when"111010"=>Y<="01001000000000";--58
when"111011"=>Y<="01001000001100";--59
when"111100"=>Y<="01000000000001";--60
when"111101"=>Y<="01000001001111";--61
when"111110"=>Y<="01000000010010";--62
when"111111"=>Y<="01000000000110";--63
end case;
end if;

end process;

end rtl;

Вам также может понравиться