集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 1511|回复: 0

车租车拼车计价器 求救!!!

[复制链接]
talent1019 发表于 2012-6-3 12:19:58 | 显示全部楼层 |阅读模式
求vhdl 车租车拼车计价器 或者在原代码基础上增加时钟和拼车功能 小弟急用啊! 775395807@qq.com


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity taxi is
port ( clk_180  :in std_logic;                                            
       start :in std_logic;                           
       stop:in std_logic;                              
       fin:in std_logic;                                                        
       clks:in std_logic;
       km1,km0ut std_logic_vector(3 downto 0);                     
       min1,min0: out std_logic_vector(3 downto 0));      
end taxi;
architecture behav of taxi is
signal f_18,f_10,f_1:std_logic;                        
signal q_18:integer range 0 to 9;                       
signal q_10:integer range 0 to 17;                       
signal q_1:integer range 0 to 179;                     
signal w:integer range 0 to 59;                        
signal c3,c2,c1,c0:std_logic_vector(3 downto 0);         
signal k1,k0:std_logic_vector(3 downto 0);               
signal m1:std_logic_vector(2 downto 0);               
signal m0:std_logic_vector(3 downto 0);               
signal en1,en0,f:std_logic;                           
begin

feipin:process(clk_180,start)
begin
  if clk_180'event and clk_180='1' then
     if start='0' then q_18<=0;q_10<=0;f_18<='0';f_10<='0';f_1<='0';f<='0';
     else
        if q_18=9 then q_18<=0;f_15<='1';         
        else q_18<=q_18+1;f_18<='0';
        end if;
        if q_10=17 then q_10<=0;f_10<='1';         
        else q_10<=q_10+1;f_10<='0';
        end if;
        if q_1=179 then q_1<=0;f_1<='1';           
        else q_1<=q_1+1;f_1<='0';
        end if;
        if en1='1' then f<=f_18;                    
        elsif en0='1' then f<=f_10;
        else f<='0';
        end if;
     end if;
  end if;
end process;

process(f_1)
begin
  if f_1'event and f_1='1' then
     if start='0' then
w<=0;en1<='0';en0<='0';m1<="000";m0<="0000";k1<="0000";k0<="0000";
     elsif stop='1' then
        if w=59 then w<=0;                             
           if m0="1001" then m0<="0000";               
              if m1<="101" then m1<="000";
              else m1<=m1+1;
              end if;
           else m0<=m0+1;
           end if;
           if m1&m0>"0000010"then en1<='1';            
           else en1<='0';
           end if;
        else w<=w+1;en1<='0';
        end if;
     elsif fin='1' then
        if k0="1001" then k0<="0000";                    
           if k1="1001" then k1<="0000";
           else k1<=k1+1;
           end if;
        else k0<=k0+1;
        end if;
        if k1&k0>"00000010" then en0<='1';               
        else en0<='0';
        end if;        
     else en1<='0';en0<='0';
     end if;
cha3<=c3;cha2<=c2;cha1<=c1;cha0<=c0;                  
km1<=k1;km0<=k0;min1<='0'&m1;min0<=m0;              
  end if;
end process;
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-6-24 02:54 , Processed in 0.069437 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表