process (clk,mode)
begin
   if (clk'event and clk='1') then
    if mode='0' then mode_out_bak<=mode_out_bak+1;   
    end if;
   end if;
end process;
process (mode_out_bak)
begin
  case mode_out_bak is 
 WHEN "000" =>
  da_1_sel<='1';--"灭灯"
   da_2_sel<='0';
  da_3_sel<='0';
   da_4_sel<='0';
   WHEN "001" =>
  da_1_sel<='0';
   da_2_sel<='1';--"灭灯"
  da_3_sel<='0';
   da_4_sel<='0';
 WHEN "010" =>
  da_1_sel<='0';
   da_2_sel<='0';
  da_3_sel<='1';--"灭灯"
   da_4_sel<='0';
   WHEN "011" =>
  da_1_sel<='0';
   da_2_sel<='0';
  da_3_sel<='0';
   da_4_sel<='1';--"灭灯"
 WHEN OTHERS =>
   da_1_sel<='0';
   da_2_sel<='0';
  da_3_sel<='0';
   da_4_sel<='0';
END CASE;
end process;
---------------------------------------------------------------
process (clk,add,sub,da_1_sel)
begin
if (clk'event and clk='1' ) then
   if (add<='0' and da_1_sel='1') then    --加100HZ
      if da_1="1001" then da_1<="0000";
      else
          da_1<=da_1+1;
       end if ;
    end if;
   if (sub<='0' and da_1_sel='1') then    
      if da_1="0000" then da_1<="1001";
      else
          da_1<=da_1-1;
       end if ;
    end if;
end if;
end process;
process (clk,add,sub,da_2_sel)     
begin
if (clk'event and clk='1' ) then
     if (add<='0' and da_2_sel='1') then    --加1KHZ
      if da_2="1001" then da_2<="0000";
      else
          da_2<=da_2+1;
       end if ;
    end if;
   if (sub<='0' and da_2_sel='1') then
      if da_2="0000" then da_2<="1001";
      else
          da_2<=da_2-1;
       end if ;
    end if;
end if; 
end process;
process (clk,add,sub,da_3_sel)
begin   
www.751com.cn       end if ;
    end if;
   if (sub<='0' and da_3_sel='1') then
      if da_3="0000" then da_3<="1001";
      else
          da_3<=da_3-1;
       end if ;
    end if;
end if;
end process;
process (clk,add,sub,da_4_sel)
begin
if (clk'event and clk='1' ) then
     if (add<='0' and da_4_sel='1') then  --加100KHZ  
      if da_4="1001" then da_4<="0000";
      else
          da_4<=da_4+1;
       end if ;
    end if;
   if (sub<='0' and da_4_sel='1') then
      if da_4="0000" then da_4<="1001";
      else
          da_4<=da_4-1;
       end if ;
    end if;
end if;
end process;
--------------------------------------------------------------
PROCESS (CLK)
  BEGIN
   IF (DA_1_SEL='1' AND CLK='1')  THEN
       DA_1B<="1110";
   ELSE DA_1B<=DA_1;