Taxi meter VHDL program

Publisher:科技创新实践者Latest update time:2018-03-11 Source: eefocusKeywords:Taxi Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    Programming and simulation.
1. Taxi meter VHDL program
-- File name: taxi.hd 
-- Function: Taxi meter 
library IEEE;
use IEEE.STD_LOG IC _1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity taxi is
port ( clk_240 :in std_logic; --Clock start with a frequency of 240Hz                        
       :in std_logic; --Pricing enable signal
      stop:in std_logic; --Waiting signal
      fin:in std_logic; --Kilometer pulse signal
      cha3,cha2,cha1,cha0:out std_logic_vector(3 downto 0); --Fee data
      km1,km0:out std_logic_vector(3 downto 0); --Kilometer data            
      min1,min0: out std_logic_vector(3 downto 0)); --Waiting time  
 end taxi;
architecture behav of taxi is
signal f_15,f_16,f_1:std_logic; --Frequency signal of 15Hz, 16Hz, 1Hz
signal q_15:integer range 0 to 15; --Frequency divider
signal q_16:integer range 0 to 14; --Frequency divider signal q_1:integer range 0 to 239; --Frequency divider signal w:integer range 0 to 59; --Second counter  signal c3,c2,c1,c0:std_logic_vector(3 downto 0); --Toll counter signal k1,k0:std_logic_vector(3 downto 0); --Kilometer counter signal m1:std_logic_vector(2 downto 0); --Tens counter  signal m0:std_logic_vector(3 downto 0); --Units counter signal en1,en0,f:std_logic; -- Enable signal  begin fei PIN : process (clk_240,start) begin   if clk_240'event and clk_240='1' then     if start='0' then q_15<=0;q_16<=0;f_15<='0';f_16<='0';f_1<='0';f<='0';     else       if q_15=15 then q_15<=0;f_15<='1'; --This statement gets a signal with a frequency of 15Hzelse       q_15<=q_15+1;f_15<='0';       end if;       if q_16=14 then q_16<=0;f_16<='1'; --This statement gets a signal with a frequency of 16Hzelse       q_16<=q_16+1;f_16<='0';        end if;       if q_1=239 then q_1<=0;f_1<='1'; --This statement gets a signal with a frequency of 1Hz       else q_1<=q_1+1;f_1<='0';       end if;       if en1='1' then f<=f_15; --This statement gets the billing pulse f       elsif en0='1' then f<=f_16;       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; --This statement completes the waiting timingif
        m0="1001" then m0<="0000"; --This statement completes the minute countingif 
          m1<="101" then m1<="000";
          else m1<=m1+1;
          end if;
        else m0<=m0+1;
        end if;
        if m1&m0>"0000001"then en1<='1'; --This statement gets the en1 enable signalelse
        en1<='0';
        end if;
      else w<=w+1;en1<='0';
      end if;
    elsif fin='1' then 
      if k0="1001" then k0<="0000"; --This statement completes the kilometer pulse countingif
        k1="1001" then k1<="0000";
        else k1<=k1+1;
        end if;
      else k0<=k0+1;
      end if;
      if k1&k0>"00000010" then en0<='1'; --This statement gets the en0 enable signal
      else en0<='0';
      end if;        
    else en1<='0';en0<='0';
    end if;
cha3<=c3;cha2<=c2;cha1<=c1;cha0<=c0; --Cost data output
km1<=k1;km0<=k0;min1<='0'&m1;min0<=m0; --Kilometer data, minute data output
  end if;
end process;
process(f,start)
begin
  if start='0' then c3<="0000";c2<="0001";c1<="0000";c0<="0000";
  elsif f'event and f='1' then
    if c0="1001" then c0<="0000"; --This statement completes the cost counting
      if c1="1001" then c1<="0000";
        if c2="1001" then c2<="0000";
          if c3<="1001" then c3<="0000";
          else c3<=c3+1;
          end if;
        else c2<=c2+1;
        end if;
      else c1<=c1+1;
      end if;
    else c0<=c0+1;
    end if;
  end if;
end process;
end behav; 

    2. Program simulation diagram

    18.jpg

    Note: 1. The relationship between seconds and minutes in the simulation diagram is ternary, that is, when w is 2, it returns to 0;

    2. The taxi traveled a total of 5 kilometers, the cumulative waiting time was 4 minutes, and the total fare was 16.2 yuan.

    
Figure 8.22.3 Taxi meter program simulation full picture
 


Keywords:Taxi Reference address:Taxi meter VHDL program

Previous article:Microcontroller C language in application design
Next article:Design of Interface Program between SED1335 and 51 Single Chip Microcomputer

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号