这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » DIY与开源设计 » 电子DIY » zwsheng的进程贴--出租车制动收费器

共61条 5/7 |‹ 2 3 4 5 6 7 跳转至
工程师
2012-11-17 20:02:42     打赏
41楼
嘿嘿.....

工程师
2012-11-21 23:09:35     打赏
42楼



基本要求:
1、主持人按下抢答开关松起后,数码管10秒倒计时,期间哪位选手抢答成功就显示选手号码。
2、如果主持人按下抢答开关还没松起就有人抢答即为违规,对于的LED亮。
3、主持人按键可以对数码管清零。

基本模块:1、倒计时 2、抢答模块 3、led警告违规 4、显示模块

总图:
1、倒计时:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY COUNT IS
PORT (CLK, Enable_Flag: IN STD_LOGIC;                    
H,L: OUT STD_LOGIC_VECTOR (3 DOWNTO 0);
 G:OUT STD_LOGIC);  --声音报警
END COUNT;
ARCHITECTURE behave OF COUNT IS
signal  HH, LL: STD_LOGIC_VECTOR (3 DOWNTO 0);
BEGIN
PROCESS (CLK, Enable_Flag)
--VARIABLE HH, LL: STD_LOGIC_VECTOR (3 DOWNTO 0);

BEGIN

IF CLK'EVENT AND CLK='1'THEN ---允许抢答
IF Enable_Flag='0'THEN
      HH<="0001";
      LL<="0000";
    else
IF LL=0 AND HH=0 THEN             
  G<='0';
ELSe
          IF LL=0 THEN
          LL<="1001";
          HH<=HH-1;                 
ELSE
          LL<=LL-1;
END IF;
end if;
--ELSE                         
--G<='1';
 --     HH<="0010";
  --    LL<="0000";
END IF;
END IF;
H<=HH;
L<=LL;
END PROCESS;
END behave;

 2、抢答模块 
 library ieee;
use ieee.std_logic_1164.all;
use ieee. std_logic_arith.all;
use ieee. std_logic_unsigned.all;
-------------------------------------------------------------------
entity qiangda is
    port( S1,s2,s3,s4 :  in   std_logic;   --输入:表示4个人,为0表示有抢答
        K :  in   std_logic;   --主持人抢答开始键
        G :  out  std_logic;              --报警信号
         
        Dout :  out  std_logic_vector(3 downto 0)  );   --抢答结果显示
    end qiangda;
--------------------------------------------------------------------
architecture behave of qiangda is

   signal D : std_logic_vector(3 downto 0);
  
    begin
    process(S1,s2,s3,s4,K)       --抢答结果显示
      begin
        if(K='0') then
             D<="0000";
        else
       
        if(S1='0') then
             D<="0001";
             G<='0';
             else
             G<='1';
             end if;
            
          if(S2='0') then
             D<="0010";
             G<='0';
             ELSE G<='1';
             end if;
            
          if(S3='0') then
             D<="0011";
             G<='0';
             ELSE G<='1';
             end if;
          if(S4='0') then
             D<="0100";
             G<='0';
            
             --S1<='1';
            -- S2<='1';
            -- S3<='1';
             ELSE G<='1';
          end if;
        
      
     end if;    
    end process;
      dout<=d;
     

end behave;


3、led警告违规
 LIBRARY ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
ENTITY wg IS
PORT(K: IN std_logic;
S1, S2, S3, S4: IN std_logic;
R1, R2, R3, R4: OUT std_logic);   --红色灯指示超前抢答台号
END wg;
ARCHITECTURE a OF wg IS

BEGIN
process(k,s1,s2,s3,s4)
begin
if(K='0') then
if(S1='0') then
          R1<='0';
         
           
          elsif(S2='0') then
          R2<='0';
         
          elsif(S3='0') then
          R3<='0';
         
          
          elsif (S4='0') then
          R4<='0';
         
          end if;
          end if;
  if k='1' then
    r1<='1';
    r2<='1';
    r3<='1';
    r4<='1';
    end if;
      end process;
END a;


助工
2012-11-21 23:46:10     打赏
43楼
谢谢楼主的 QuartusII警告

工程师
2012-11-23 13:10:53     打赏
44楼
共同学习,加油!

工程师
2012-11-26 12:43:00     打赏
45楼

用8个按键弹出1、2、3、4、5、6、7、1音符
程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity fenping is
port(clk_50m:   in std_logic;
fmq :   out std_logic;
key1: in std_logic;
key2: in std_logic;
key3: in std_logic;
key4: in std_logic;
key5: in std_logic;
key6: in std_logic;
key7: in std_logic;
key8: in std_logic

);
end;

architecture behave of fenping is
signal clk_262_r: std_logic;
signal clk_294_r: std_logic;
signal clk_330_r: std_logic;
signal clk_349_r: std_logic;
signal clk_392_r: std_logic;
signal clk_440_r: std_logic;
signal clk_494_r: std_logic;
signal clk_523_r: std_logic;
begin
u1: process (clk_50m)
variable count1:     std_logic_vector(16 downto 0);
variable count2:     std_logic_vector(16 downto 0);
variable count3:     std_logic_vector(16 downto 0);
variable count4:     std_logic_vector(16 downto 0);
variable count5:     std_logic_vector(16 downto 0);
variable count6:     std_logic_vector(16 downto 0);
variable count7:     std_logic_vector(16 downto 0);
variable count8:     std_logic_vector(16 downto 0);
begin
if clk_50m'event and clk_50m='1' then
   if count1=95419 then
   count1:=(others=>'0');
   clk_262_r<=not clk_262_r;
   else
   count1:=count1+1;
   end if;
   end if;
  
if clk_50m'event and clk_50m='1' then  
   if count2=84459 then
   count2:=(others=>'0');
   clk_294_r<=not clk_294_r;
   else
      count2:=count2+1;
   end if;
end if;

if clk_50m'event and clk_50m='1' then  
   if count3=75757 then
   count3:=(others=>'0');
   clk_330_r<=not clk_330_r;
   else
      count3:=count3+1;
   end if;
end if;

if clk_50m'event and clk_50m='1' then  
   if count4=71633 then
   count4:=(others=>'0');
   clk_349_r<=not clk_349_r;
   else
      count4:=count4+1;
   end if;
end if;

if clk_50m'event and clk_50m='1' then  
   if count5=63776 then
   count5:=(others=>'0');
   clk_392_r<=not clk_392_r;
   else
      count5:=count5+1;
   end if;
end if;

if clk_50m'event and clk_50m='1' then  
   if count6=56818 then
   count6:=(others=>'0');
   clk_440_r<=not clk_440_r;
   else
      count6:=count6+1;
   end if;
end if;

if clk_50m'event and clk_50m='1' then  
   if count7=50607 then
   count7:=(others=>'0');
   clk_494_r<=not clk_494_r;
   else
      count7:=count7+1;
   end if;
end if;

if clk_50m'event and clk_50m='1' then  
   if count8=47801 then
   count8:=(others=>'0');
   clk_523_r<=not clk_523_r;
   else
      count8:=count8+1;
   end if;
end if;
end process;

u2:process(key1,key2,key3,key4,key5,key6,key7,key8)
   begin
   if key1='0'then
      fmq<=clk_262_r;
   end if;  
   if key2='0'then 
      fmq<=clk_294_r;
   end if;
   if key3='0'then 
      fmq<=clk_330_r;
   end if;
    if key4='0'then 
      fmq<=clk_349_r;
   end if;
    if key5='0'then 
      fmq<=clk_392_r;
   end if;
    if key6='0'then 
      fmq<=clk_440_r;
   end if;
    if key7='0'then 
      fmq<=clk_494_r;
   end if;
   if key8='0'then 
      fmq<=clk_523_r;
   end if;
   end process;  
 end;
.SOF文件http://share.eepw.com.cn/share/download/id/79562


高工
2012-11-26 14:05:33     打赏
46楼
温故而知新,总结得很好~!

工程师
2012-11-26 16:56:59     打赏
47楼
   用的是VHDL,可以在这次的活动的板子上用,用的晶振是Y2。

工程师
2012-11-26 17:15:06     打赏
48楼
把代码生成原理图模块是为了方面调用,操作如下:鼠标放在左上方的.VHD文件上,单击右键选择“create symbol files for current files"原理图模块就可以在原理图中找到,这样就可以调用!

工程师
2012-11-27 18:29:28     打赏
49楼
    努力就有收获,加油!

工程师
2012-12-08 14:08:31     打赏
50楼
   

                             lcd1602滚动
视频:

  原理图:

  代码如下:代码虽然比较长,但是大多是一样的,比较容易写!分频程序没有呈上,相信大家都回来了!
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
entity LCD1602 is
port ( clk :in std_logic;
      reset:in std_logic;
      lcd_rs:out std_logic;
      lcd_rw:out std_logic;
      lcd_e: out std_logic;
      data:out std_logic_vector(7 downto 0)
);
end LCD1602;
architecture one of LCD1602 is
signal bcd: std_logic_vector(5 downto 0);
signal cnt: std_logic_vector(9 downto 0);
begin
process(clk,reset)
begin
if clk'event and clk='1' then
   bcd<=bcd+1;
   cnt<=cnt+1;
   case bcd is
   when "000000"=>
         lcd_rs<='0';
         lcd_e<='1';
         data<="00111000";
   when "000001"=>
         lcd_rs<='0';
         lcd_e<='0';
        
   when "000010"=>
         lcd_rs<='0';
         lcd_e<='1';
         data<="00001100";
   when "000011"=>
         lcd_rs<='0';
         lcd_e<='0';
        
   when "000100"=>
         lcd_rs<='0';
         lcd_e<='1';
         data<="10000001";
   when "000101"=>
         lcd_rs<='0';
         lcd_e<='0';      
   when "000110"=>      --xian e
         lcd_rs<='1';
         lcd_e<='1';
         data<="01100101";
   when "000111"=>
         lcd_rs<='1';
         lcd_e<='0'; 
     
   when "001000"=>
         lcd_rs<='0';
         lcd_e<='1';
         data<="10000010";
   when "001001"=>
         lcd_rs<='0';
         lcd_e<='0';     
   when "001010"=>        --xian  e
         lcd_rs<='1';
         lcd_e<='1';
         data<="01100101"; 
   when "001011"=>
         lcd_rs<='1';
         lcd_e<='0';   
    
   when "001100"=>          
         lcd_rs<='0';
         lcd_e<='1';
         data<="10000011";
   when "001101"=>
         lcd_rs<='0';
         lcd_e<='0';     
   when "001110"=>       --xian p
         lcd_rs<='1';
         lcd_e<='1';
         data<="01110000"; 
   when "001111"=>
         lcd_rs<='1';
         lcd_e<='0';
   
   when "010000"=>          
         lcd_rs<='0';
         lcd_e<='1';
         data<="10000100";
   when "010001"=>
         lcd_rs<='0';
         lcd_e<='0';    
   when "010010"=>       --xian w
         lcd_rs<='1';
         lcd_e<='1';
         data<="01110111"; 
   when "010011"=>
         lcd_rs<='1';
         lcd_e<='0'; 
        
        
   when "010100"=>          
         lcd_rs<='0';
         lcd_e<='1';
         data<="10000110";
   when "010101"=>
         lcd_rs<='0';
         lcd_e<='0';    
   when "010110"=>       --xian z
         lcd_rs<='1';
         lcd_e<='1';
         data<="01111010"; 
   when "010111"=>
         lcd_rs<='1';
         lcd_e<='0'; 
   
    when "011000"=>          
         lcd_rs<='0';
         lcd_e<='1';
         data<="10000111";
   when "011001"=>
         lcd_rs<='0';
         lcd_e<='0';    
   when "011010"=>       --xian h
         lcd_rs<='1';
         lcd_e<='1';
         data<="01101000"; 
   when "011011"=>
         lcd_rs<='1';
         lcd_e<='0';   
        
   when "011100"=>          
         lcd_rs<='0';
         lcd_e<='1';
         data<="10001000";
   when "011101"=>
         lcd_rs<='0';
         lcd_e<='0';    
   when "011110"=>       --xian w
         lcd_rs<='1';
         lcd_e<='1';
         data<="01110111"; 
   when "011111"=>
         lcd_rs<='1';
         lcd_e<='0';   
        
    when "100000"=>          
         lcd_rs<='0';
         lcd_e<='1';
         data<="10001001";
   when "100001"=>
         lcd_rs<='0';
         lcd_e<='0';    
   when "100010"=>       --xian e
         lcd_rs<='1';
         lcd_e<='1';
         data<="01100101"; 
   when "100011"=>
         lcd_rs<='1';
         lcd_e<='0';   
        
    when "100100"=>          
         lcd_rs<='0';
         lcd_e<='1';
         data<="10001010";
   when "100101"=>
         lcd_rs<='0';
         lcd_e<='0';    
   when "100110"=>       --xian  n
         lcd_rs<='1';
         lcd_e<='1';
         data<="01101110"; 
   when "100111"=>
         lcd_rs<='1';
         lcd_e<='0';   
   
   when "101000"=>          
         lcd_rs<='0';
         lcd_e<='1';
         data<="10001011";
   when "101001"=>
         lcd_rs<='0';
         lcd_e<='0';    
   when "101010"=>       --xian g
         lcd_rs<='1';
         lcd_e<='1';
         data<="01100111"; 
   when "101011"=>
         lcd_rs<='1';
         lcd_e<='0';                                                                    
   when others=>null;           
   end case;
  
   case cnt is
   when "1111111110" =>
         lcd_rs<='0';
         lcd_e<='1';
         data<="00011000";
   when "1111111111"=>
         lcd_rs<='0';
         lcd_e<='0';
       --  data<="00111000"; 
    when others=>null;
    end case;  
   end if;
end process;  
end ;     
    
.SOF文件下载:http://share.eepw.com.cn/share/download/id/81240

共61条 5/7 |‹ 2 3 4 5 6 7 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]