毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 嵌入式 >> 正文

VHDL四人抢答器代码

更新时间:2013-9-16:  来源:毕业论文

VHDL四人抢答器代码

library ieee;

use ieee.std_logic_1164.all;


entity qiangdaqi is

port
(

        clk ,rest,allow             : in std_logic;

     answer                     : in std_logic_vector(3 downto 0);

stop_lamp,allow_lamp,co,q : out std_logic;
    answer_success,answer_foul  : out std_logic_vector(3 downto 0)

);


end entity;


architecture rtl of qiangdaqi is
signal alamp : std_logic;
signal foul : std_logic_vector(3 downto 0);

begin


nclk:process (clk,allow) is

      begin
    if(rest='1')then  
      q<="0000";  
      co<='0';  
    else

      if(allow_lamp='1')then  
    if(clk'event and clk='1') and (answer_success="0000")then 
        if(q="1111")then    
           q<="0000";     
           co<='1';    
        else    
           q<=q+'1';  
           co<='0';   
        end if;   
    end if; 
     end if; 
    end if;
     end process;
   
    lemp_rest_allow:process(rest,allow,co)is  
      begin    
        if(rest='1')then   
            stop_lamp<='1';     
            allow_lamp<='0'
lemp_answer:
        process(allow_lamp,answer,rest,alamp)is  
         begin   
           if(rest='1')then    
             answer_success<="0000";--抢答成功灯的清零设置 
    lemp_foul:process(stop_lamp,answer)is  
        begin   
          if(rest='1')then    
             answer_foul<="0000";--抢答犯规灯的清零设置
           if(allow='1')then    
             allow_lamp<='1';     
             stop_lamp<='0';    
           end if;   
          end if;  
          if(co='1')then    
             allow_lamp<='0';   
             stop_lamp<='1';   
          end if;
    lemp_answer:process(allow_lamp,answer,rest,alamp)is
        begin   
          if(rest='1')then   
            answer_success<="0000";   
            alamp<='0';      --  清零部分
          else    
            if(allow_lamp='1')then    
              if((alamp='0')and (answer(0)='1')and(foul(0)='0'))then    
                answer_success(0)<='1';  
                alamp<='1';     
              elsif((alamp='0') and (answer(1)='1')and(foul(1)='0'))then     
                 answer_success(1)<='1';     
                 alamp<='1';             
              elsif((alamp='0') and( answer(2)='1')and(foul(2)='0'))then    
                 answer_success(2)<='1';     
                 alamp<='1';            
              elsif((alamp='0') and (answer(3)='1')and(foul(3)='0'))then   
                 answer_success(3)<='1';      
                 alamp<='1';             
             end if;     
           end if;   
          end if;   
      end process; 
     lemp_foul:process(stop_lamp,answer)is 
        begin   
           if(rest='1')then    
             answer_foul<="0000";    
             foul<="0000";   
           else    
              if(stop_lamp='1')then    
                if(answer(0)='1')and(alamp='0')then    
                  answer_foul(0)<='1';    
                  foul(0)<='1';    
                --end if;     
                elsif(answer(1)='1')and(alamp='0')then
                  answer_foul(1)<='1';    
                  foul(1)<='1';     
                 --end if;     
                elsif(answer(2)='1')and(alamp='0')then    
                  answer_foul(2)<='1';       
                  foul(2)<='1';     
                --end if;     
                elsif(answer(3)='1')and(alamp='0')then     
                  answer_foul(3)<='1';     
                  foul(3)<='1';    
                --end if;     
                end if;   
              end if; 
            end if;
      end process;
end rtl;


process (clk,allow) is
后面怎么会有is

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。