⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 texi.doc

📁 基于FPGA的出租车计价器
💻 DOC
📖 第 1 页 / 共 2 页
字号:
      控制模块       
      ----描述计价器整个工作过程,系统的核心。                
      *************************************
      taxi_time:process(clr,sec,st)
      variable c : integer range 0 to 180;
      begin
      if clr='1' or st='1'then c:=0;
      elsif rising_edge(sec) then
      if c<180 then c:=c+1;
      else c:=121;
      end if;
      end if;   
      if c=120 then M_20<='1';M_15<='0'; 
      elsif c=180 then M_20<='0';M_15<='1';
      else M_20<='0';M_15<='0';
      end if;
      end process;
       
      road:process(clr,d_in,sec,st)
      variable c : integer range 0 to 7;
      begin
      if clr='1' then c:=0;
      elsif rising_edge(sec) then
      if st='1' then
      if d_in='1' then
      if c<8 then c:=c+1;
      else c:=7;
      end if;
      end if;
      end if;
      end if;
      if c=8 then d_xx<='1';
      else d_xx<='0';
      end if;
      end process;
      *************************************
      计量模块       
      ----计程车计价器系统多功能实现的保证。可以分为计价部分、计时部分和计程部分。                  
      *************************************
      --------------------------------------------------------                   
                    ----               计价             ----
      --------------------------------------------------------
      money:process(d_xx,M_15,M_20,clr,sec)
      variable a,b,c : integer range 0 to 3000;
      begin
      if clr='1' then a:=0;b:=0;c:=0;
      elsif rising_edge(sec) then
      if d_xx='1' then a:=a+16; 
      elsif m_15='1' then b:=b+15; 
      elsif m_20='1' then c:=c+20; 
      end if;
      end if;
      d<=a+b+c+100;          --10元起步费
      end process;
       
      money_led:process(clr,d,clk,sec) 
      -- 价格换算
      variable c : integer range 0 to 9100;
      variable i,t,j,k : integer range 0 to 10;
      begin
      if clr='1' then i:=0;t:=0;j:=0;k:=0;c:=0;
      elsif rising_edge(clk) then
      if sec='1' then c:=d;i:=0;t:=0;j:=0;k:=0;
      elsif  c>999 then c:=c-1000; i:=i+1;
      --对百元计数
      elsif c<=999 and c>99  then
       c:=c-100; j:=j+1;            
      --对十元计数
      elsif c<=99 and c>9 then c:=c-10; k:=k+1; --对元计数
      else t:=c ;              --对角计数
      l1<=t ; l4<=I ; l3<=j ; l2<=k;
      end if;
      end if; 
      end process;
      --------------------------------------------------------
      ----             计时               ----
      --------------------------------------------------------
      ALL_time_m:process(clr,sec)
      variable m,mm : integer range 0 to 10;
      --mm表示秒计数的十位
      -- m表示秒计数的个位
      begin
      if clr='1' then m:=0;mm:=0;
      elsif  rising_edge(sec) then
      if mm<6 then
      if m<9 then m:=m+1;
      else m:=0;mm:=mm+1;
      end if;
      else mm:=0;
      end if;
      end if;
      if mm=6 then mm:=0;m:=0;fen<='1';
      else fen<='0'; 
      end if;
      Ll1<=m ; Ll2<=mm;
      end process;
       
      ALL_time_f:process(clr,fen)
      variable f,ff : integer range 0 to 10;
      begin
      if clr='1' then f:=9;ff:=3;
      elsif rising_edge(fen) then
      if ff<6 then 
      if f<9 then f:=f+1;
      else f:=0;ff:=ff+1;
      end if;
      else ff:=0;
      end if;
      end if;
      if ff=6 then ff:=0;f:=0;
      end if;
      Ll3<=f;Ll4<=ff;
      end process;
      --------------------------------------------------------                   
             -----             计程              ----
      --------------------------------------------------------
      process(clr,d_in,sec,st)
      variable f,ff : integer range 0 to 10;
      begin
      if clr='1' then f:=0;ff:=0;
      elsif rising_edge(sec) then
      if st='1' then
      if d_in='1' then
      if ff<10 then 
      if f<9 then f:=f+1;
      else ff:=ff+1;f:=0;
      end if;
      else ff:=0;
      end if;
      end if;
      end if;
      end if;
      if ff=10 then ff:=0; end if;
      Lll2<=f;Lll3<=ff;
      end process;
       
       
       
      *************************************
      译码显示模块       
      ----用四个七段译码显示管实现系统功能显示。                  
      *************************************
      process(sec,clr,choose,L1,L2,L3,L4,LL1,LL2,LL3,LL4,LLL2,LLL3)
      variable c : std_logic_vector (1 downto 0);
      --译码显示;
      --“01”:总价格;
      --“10”:总路程;
      --“11”:总乘车时间;
      begin
      if clr='1' then c:="01";
      elsif rising_edge(sec) then
      if choose='1' then
      if c<"11" then c:=c+1;
      else c:="01"; end if;
      else null;
      end if;
      end if;
      if  c="01"  then   led1<=L1;led2<=L2;
      led3<=L3;led4<=L4;
      elsif  c="10" then  led1<=10;led2<=LLL2;
      led3<=LLL3;led4<=10;
      else              led1<=LL1;led2<=LL2;
      led3<=LL3;led4<=LL4;
      end if;
      end process;
       
      LED_1:process(Led1)
      begin
      case Led1 is
      when 0=> L_1 <="0000001";
      when 5=> L_1 <="0100100";
      when 1=> L_1 <="1001111";
      when 6=> L_1 <="1100000";
      when 2=> L_1 <="0010010";
      when 7=> L_1 <="0001111";
      when 3=> L_1 <="0000110";
      when 8=> L_1 <="0000000";
      when 4=> L_1 <="1001100";
      when 9=> L_1 <="0001100";
      when others => L_1 <="1111111";
      end case;
      end process;
       
      LED_2:process(Led2)
      begin
      case Led2 is
      when 0=> L_2 <="0000001";
      when 5=> L_2 <="0100100";
      when 1=> L_2 <="1001111";
      when 6=> L_2 <="1100000";
      when 2=> L_2 <="0010010";
      when 7=> L_2 <="0001111";
      when 3=> L_2 <="0000110";
      when 8=> L_2 <="0000000";
      when 4=> L_2 <="1001100";
      when 9=> L_2 <="0001100";
      when others => L_2 <="1111111";
      end case;
      end process;
       
      LED_3:process(Led3)
      begin
      case Led3 is
      when 0=> L_3 <="0000001";
      when 5=> L_3 <="0100100";
      when 1=> L_3 <="1001111";
      when 7=> L_3 <="0001111";
      when 2=> L_3 <="0010010";
      when 6=> L_3 <="1100000";
      when 3=> L_3 <="0000110";
      when 8=> L_3 <="0000000";
      when 4=> L_3 <="1001100";
      when 9=> L_3 <="0001100";
      when others => L_3 <="1111111";
      end case;
      end process;
       
       
       
       
       
       
       
       
      LED_4:process(Led4)
        begin
      case Led4 is
      when 0=> L_4 <="0000001";
      when 5=> L_4 <="0100100";
      when 1=> L_4 <="1001111";
      when 6=> L_4 <="1100000";
      when 2=> L_4 <="0010010";
      when 7=> L_4 <="0001111";
      when 3=> L_4 <="0000110";
      when 8=> L_4 <="0000000";
      when 4=> L_4 <="1001100";
      when 9=> L_4 <="0001100";
      when others => L_4 <="1111111";
      end case;
      end process;    
      end Behavioral;
      

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -