library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_ARITH.all;
use IEEE.STD_LOGIC_UNSIGNED.all;
ENTITY LS192 IS
port (clr,set,cp1,cp2 : in STD_LOGIC;
q : in STD_LOGIC_VECTOR(3DOWNTO 0);
d: out STD_LOGIC_VECTOR(3DOWNTO 0);
jinwei:out STD_LOGIC;
jiewei:out STD_LOGIC);
end ENTITY LS192 ;
architecture behav of LS192 is
signal conut1_4 : STD_LOGIC_VECTOR(3DOWNTO 0);
signal conut2_4 : STD_LOGIC_VECTOR(3DOWNTO 0);
signal a1 : STD_LOGIC;
signal a2 : STD_LOGIC;
begin
process( clr,set,cp1,q) --jifaqi
begin
if(clr='1')then --qingling
conut1_4<="0000";
a1<='0';
jinwei<='0';
elsif(set='0')then --zhishu
conut1_4(0)<=q(0);
conut1_4(1)<=q(1);
conut1_4(2)<=q(2);
conut1_4(3)<=q(3);
elsif(cp1'event and cp1 = '1')then --
if(conut1_4="1001")then
conut1_4<="0000";
a1<='1';
else
conut1_4<=conut1_4+1;
if(a1='1')then
a1<='0';
end if;
end if;
end if;
d(0)<=conut1_4(0) ;
d(1)<=conut1_4(1) ;
d(2)<=conut1_4(2) ;
d(3)<=conut1_4(3) ;
jinwei<=a1;
end process;
process( clr,set,cp2,q) --jianfa
begin
if(clr='1')then --qingling
conut2_4<="0000";
a2<='0';
jiewei<='0';
elsif(set='0')then --zhishu
conut2_4(0)<=q(0);
conut2_4(1)<=q(1);
conut2_4(2)<=q(2);
conut2_4(3)<=q(3);
elsif(cp2'event and cp2 = '1')then --
if(conut2_4="0000")then
conut2_4<="1001";
a2<='1';
else
conut2_4<=conut2_4-1;
if(a2='1')then
a2<='0';
end if;
end if;
end if;
d(0)<=conut2_4(0) ;
d(1)<=conut2_4(1) ;
d(2)<=conut2_4(2) ;
d(3)<=conut2_4(3) ;
jiewei<=a2;
end process;
end architecture behav;