當前位置:首頁 » 課程大全 » 計程車自動計費器eda課程設計

計程車自動計費器eda課程設計

發布時間: 2021-02-09 08:29:35

1. 您好,你可以把EDA課程設計 計程車計價器設計和實現給我發下么我重賞,謝謝您

這個不能貼圖
給個郵箱地址,我發DOC你

2. 計程車計費器的設計 1. 設計任務 設計並製作一台計程車計費器。 2. 設計要求 ① 用EDA實訓儀的I/O設備和PL

process (clk ,start ,stop ,pause ,js)
variable a ,b : std logic ;
variable aa :integer range 0 to 100 ;
variable chf ,lc :integer range 0 to 8000 ;
variable num:integer range 0 to 9 ;
begin
if clk′ and clk =『1』 then
if stop =『0』 then
chf : = 0 ;
num: = 0 ;
b : =『1』;
aa : = 0 ;
lc : = 0 ;
elsif start =′0′ then
b : =′0′;
chf : = 700 ;
lc : = 0 ;
elsif start =′1′and js =′1′and pause =′1′ then
if b =′0′)then
num: = num + 1 ;
end if ;
if num = 9)then
lc : = lc + 5 ;
num: = 0 ;
aa : = aa + 5 ;
end if ;
elsif start =′1′and js =′0′and pause =′1′then
lc : = lc + 1 ;
aa : = aa + 1 ;
end if ;
if aa > = 100 then
a : =′1′;
aa : = 0 ;
else
a : =′0′;
end if ;
if lc < 300 then
null ;
elsif chf < 2000 and a =′1′ then
chf : = chf + 220 ;
elsif chf > = 2000 and a =′1′ then
chf : = chf + 330 ;
end if ;
end if ;
chefei < = chf ;
luc < = lc ;
end process ;
把if後的括弧都去了,不需要的,你再試試,如果不行再聯系。

3. 計程車計費器課程設計

................................

4. EDA課程設計,用VHDL編程做計程車計費器

課程設計內容與要求
1,用開關按鍵表示脈沖,每個脈沖代表100米,10個脈沖1公里,每公里1.4元,能同步顯示里程和費用;
2,低於2公里5元計費,高於2公里總費用=起步費用+(里程-2公里)*里程單價+
等候時間*等後單價;
3,等候時間大於2分鍾,按每分鍾1.3元計費;
4,可以設定起步價和里程單價。
一、設計原理與技術方法:
包括:電路工作原理分析與原理圖、元器件選擇與參數計算、電路調試方法與結果說明;
軟體設計說明書與流程圖、軟體源程序代碼、軟體調試方法與運行結果說明。
根據設計要求,系統的輸入信號clk,計價開始信號start,等待信號stop,里程脈沖信號fin。系統的輸出信號有:總費用數C0—c3,行駛距離k0—k1,等待時間m0—m1等。系統有兩個脈沖輸入信號clk_750k,fin,其中clk_750k將根據設計要求分頻成14hz,15hz和1hz分別作為公里計費和超時計費的脈沖。兩個控制輸入開關start,stop;控制過程為:start作為計費開始的開關,當start為高電平時,系統開始根據輸入的情況計費。當有乘客上車並開始行駛時,fin脈沖到來,進行行駛計費,此時的stop需要置為0;如需停車等待,就把stop變為高電平,
並去除fin輸入脈沖,進行等待計費;當乘客下車且不等待時,直接將start置為0,系統停止工作;價格開始歸為起步價5.0元。
整個設計由分頻模塊,計量模塊,計費模塊,控制模塊和顯示模塊五個部分組成。
其中計量模塊是整個系統實現里程計數和時間計數的重要部分;控制模塊是實現不同計費方式的選擇部分,根據所設計的使能端選擇是根據里程計費還是根據等待時間計費,同時設計通過分頻模塊產生不同頻率的脈沖信號來實現系統的計費。計量模塊採用1hz的驅動信號,計費模塊採用14hz,13hz的驅動信號;計量模塊每計數一次,計量模塊就實現14次或者13次計數,即為實現計時的1.3元/min,計程時的1.4元/km的收費。組成框圖如下所示:

1.百進制模塊:
實現百米脈沖的驅動信號,元件框圖如圖3所示:

圖3 百進制模塊框圖
源程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity jin is
port(start,clk2: in std_logic; --秒脈沖
a: out std_logic_vector(3 downto 0));
end jin;
architecture rt1 of jin is
signal count_1:std_logic_vector(3 downto 0);
begin
a<=count_1;
process(start,clk2)
begin
if(start='0')then
count_1<="0000";
elsif(clk2'event and clk2='1')then
if(count_1="0111")then
count_1<="0000";
else
count_1<=count_1+'1';
end if;
end if;
end process;
end rt1

2.計費模塊
; 實現里程和等候時間的計費並輸出到顯示,元件框圖4如下:

圖4 計費模塊框圖

源程序如下:
Library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity jifei is
port(clk2:in std_logic; --計費驅動信號
start:in std_logic; --計費開始信號
c0,c1,c2,c3:buffer std_logic_vector(3 downto 0));
end jifei;
architecture rt1 of jifei is
begin
process(clk2,start)
begin
if start='0'then c3<="0000";c2<="0000";c1<="0101";c0<="0000"; --起步價5元
elsif clk2'event and clk2='1'then
if c0="1001" then c0<="0000";
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 rt1;

3.公里模塊
實現歷程的計數和輸出計費脈沖,元件框圖5如下:

圖5 公里模塊框圖
源程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity gongli is
port(clk1,start: in std_logic; --百米脈沖
k1,k2,k3,k4: out std_logic_vector(3 downto 0); --里程顯示
temp2 : out std_logic);
end gongli;

architecture rt1 of gongli is
signal count_1: std_logic_vector(3 downto 0);
signal count_2: std_logic_vector(3 downto 0);
signal count_3: std_logic_vector(3 downto 0);
signal count_4: std_logic_vector(3 downto 0);
begin
k1<=count_1;
k2<=count_2;
k3<=count_3;
k4<=count_4;
process(start,clk1)
begin
if(start='0')then
count_1<="0000";
count_2<="0000";
count_3<="0000";
count_4<="0000"; ---公里清零
elsif(clk1'event and clk1='1')then
if(count_1="1001")then --公里計數器
count_1<="0000";count_2<=count_2+1;temp2<='1';
if(count_2="1001")then
count_2<="0000";count_3<=count_3+'1';
if(count_3="1001")then
count_3<="0000";count_4<=count_4+'1';
end if;
end if;
else
count_1<=count_1+'1';temp2<='0';
end if;
end if;
end process;
end rt1;

4.輸出模塊
實現所有數據的輸出,元件框圖6如下:

圖6 輸出模塊框圖
源程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity shuchu is
port(y: in std_logic_vector(3 downto 0);
e: out std_logic_vector(6 downto 0));
end shuchu;

architecture rt1of shuchu is
begin
process
begin
case y is
when"0000"=>e<="0111111";
when"0001"=>e<="0000110";
when"0010"=>e<="1011011";
when"0011"=>e<="1001111";
when"0100"=>e<="1100110";
when"0101"=>e<="1101101";
when"0110"=>e<="1111101";
when"0111"=>e<="0000111";
when"1000"=>e<="1111111";
when"1001"=>e<="1100111";
when others=>e<="0000000";
end case;
end process;
end rt1;

5.顯示模塊
實現所有數據的顯示,元件框圖7如下:

圖7 顯示模塊框圖
源程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity xianshi is
port(start: in std_logic;
a:in std_logic_vector(3 downto 0); --選擇信號
c1,c2,c3,c4,out1,out2,out3,out4:in std_logic_vector(3 downto 0); --里程顯示,時間顯示輸入
y:out std_logic_vector(3 downto 0)); --里程顯示,時間顯示輸出
end xianshi;
architecture rt1 of xianshi is
begin
process
begin
if(start='0')then
y<="0000";
else case a is
when "0000"=> y<=c1 ;
when "0001"=> y<=c2 ;
when "0010"=> y<=c3 ;
when "0011"=> y<=c4 ;
when "0100"=> y<=out1 ;
when "0101"=> y<=out2;
when "0110"=> y<=out3 ;
when "0111"=> y<=out4;
when others =>y<= "0000";
end case;
end if;
end process;
end rt1;

6.dian模塊

圖8 dian模塊框圖
源程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity dian is
port(a: in std_logic_vector(3 downto 0);
e: out std_logic);
end dian;
architecture rt1 of dian is
begin
process
begin
case a is
when "0001"=>e<='1';
when "0101"=>e<='1';
when others=>e<='0';
end case;
end process;
end rt1;

三、中各個模塊設計分析
系統總體頂層框圖如下:

系統總體頂層框圖

程序最終功能實現波形模擬

1. 分頻模塊
由於實驗箱上沒有14hz和13hz的整數倍時鍾信號,因此採用頻率較大的750khz進行分頻,以近似得到14hz,13hz和1hz的時鍾頻率。通過以上三種不同頻率的脈沖信號實行計程車行駛,等待兩種情況下的不同計費。模塊元件如下:

分頻模塊框圖
源程序如下:
Library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity fenpin is
port(clk_750k:in std_logic; --系統時鍾
clk_14:buffer std_logic; --14分頻
clk_13:buffer std_logic; --13分頻
clk_1 : buffer std_logic); --1分頻
end fenpin ;
architecture rt1 of fenpin is
signal q_14:integer range 0 to 53570; --定義中間信號量
signal q_13:integer range 0 to 57691;
signal q_1:integer range 0 to 749999;
begin
process(clk_750k)
begin
If(clk_750k' event and clk_750k='1')then
If q_14=53570 then q_14<=0;clk_14<=not clk_14;
else q_14<=q_14+1;
end if; --得14hz頻率信號
If q_13=57691 then q_13<=0;clk_13<=not clk_13;
else q_13<=q_13+1;
end if; --得13hz頻率信號
If q_1=749999 then q_1<=0;clk_1<=not clk_1;
else q_1<=q_1+1;
end if; --得1hz頻率信號
end if;
end process;
end rt1;

2. 計量模塊
計量模塊主要完成計時和計程功能。
計時部分:計算乘客的等待累積時間,當等待時間大於2min時,本模塊中en1使能信號變為1;當clk1每來一個上升沿,計時器就自增1,計時器的量程為59min,滿量程後自動歸零。
計程部分:計算乘客所行駛的公里數,當行駛里程大於2km時,本模塊中en0使能信號變為1;當clk每來一個上升沿,計程器就自增1,計程器的量程為99km,滿量程後自動歸零。
元件框圖為:

計量模塊框圖

計量模塊模擬波形為:

源程序如下:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity jiliang is
port(start:in std_logic; --計費開始信號
fin:in std_logic; --里程脈沖信號
stop:in std_logic; --行駛中途等待信號
clk1:in std_logic; --驅動脈沖
en1,en0:buffer std_logic; --計費單價使能信號
k1,k0:buffer std_logic_vector(3 downto 0); --行駛公里計數
m1,m0:buffer std_logic_vector(3 downto 0)); --等待時間計數
end jiliang;
architecture rt2 of jiliang is
signal w:integer range 0 to 59; --計時范圍0~59
begin
process(clk1)
begin
if(clk1'event and clk1='1')then
if start='0' then
w<=0;en1<='0';en0<='0';m1<="0000";
m0<="0000";k1<="0000";k0<="0000";
elsif stop='1' then --計時開始信號
if w=59 then
w<=0;
else w<=w+1;
end if;
if m0="1001" then
m0<="0000";
if m1="0101" then
m1<="0000";
else m1<=m1+1;
end if;
else m0<=m0+1;
end if;
if stop='1' then en0<='0';
if m1&m0>"00000001" then en1<='1'; --若等待時間大於2min則en1置1
else en1<='0';
end if;
end if;
elsif fin='1' then --里程計數開始
if k0="1001" then k0<="0000";
if k1="1001" then k1<="0000"; --計程范圍0~99
else k1<=k1+1;
end if;
else k0<=k0+1;
end if;
if stop='0' then
en1<='0';
if k1&k0>"00000001" then
en0<='1'; --若行使里程大於2km,則en0置1
else en0<='0';
end if;
end if;
end if;
end if;
end process;
end rt2;

3. 控制模塊
本模塊主要是通過計量模塊產生的兩個不同的輸入使能信號en0,en1,對每個分頻模塊輸出的14hz,13hz的脈沖進行選擇輸出的過程;本模塊實現了雙脈沖的二選一;最終目的為了計費模塊中對行駛過程中不同的時段進行計價。
模塊元件如下:

控制模塊框圖
控制模塊模擬波形為:

源程序如下:
Library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity kong is
port(en0,en1:in std_logic; --使能選擇信號
clk_in1:in std_logic; --14分頻輸入信號
clk_in2:in std_logic; --13分頻輸入信號
clk_out:out std_logic); --輸出信號
end kong;
architecture rt3 of kong is
begin
process(en0,en1)
begin
if en0='1' then --實現二選一功能
clk_out<=clk_in1;
elsif en1='1' then
clk_out<=clk_in2;
end if;
end process;
end rt3;

4.計費模塊
當計費信號start一直處於高電平即計費狀態時,本模塊根據控制模塊選擇出的信號從而對不同的單價時段進行計費。即行程在2km內,而且等待累計時間小於2min則為起步價5元;2km外以每公里1.4.元計費,等待累積時間超過2min則按每分鍾1.3元計費。c0,c1,c2,c3分別表示費用的顯示。
模塊元件為:

計費模塊框圖

計費模塊模擬波形為:

源程序如下:

Library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity jifei is
port(clk2:in std_logic; --計費驅動信號
start:in std_logic; --計費開始信號
c0,c1,c2,c3:buffer std_logic_vector(3 downto 0));
end jifei;
architecture rt4 of jifei is
begin
process(clk2,start)
begin
if start='0'then c3<="0000";c2<="0000";c1<="0101";c0<="0000"; --起步價5元
elsif clk2'event and clk2='1'then
if c0="1001" then c0<="0000";
if c1="1001" then c1<="0000";
if c2="1001" then c2<="0000";
if c3="1001" then c3<="0000"; --計價范圍0~999.9
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 rt4;

5.顯示模塊
顯示模塊完成計價,計時和計程數據顯示。計費數據送入顯示模塊進行解碼,最後送至以百元,十元,元,角為單位對應的數碼管上顯示。計時數據送入顯示模塊進行解碼,最後送至以分為單位對應的數碼管上顯示。計程數據送入顯示模塊進行解碼,最後送至以km為單位的數碼管上顯示。
模塊元件為:

顯示模塊框圖
源程序如下:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all; --定義庫包

entity xianshi is --定義實體
port(
clk_scan:in std_logic; --掃描時鍾信號埠設置
c3,c2,c1,c0:in std_logic_vector(3 downto 0); --總費用輸入埠
k0,k1:in std_logic_vector(3 downto 0); --里程輸入埠
m0,m1:in std_logic_vector(3 downto 0); --等待時間輸入埠
sel:out std_logic_vector(2 downto 0); --控制數碼管位選信號的掃描信號輸出埠
led:out std_logic_vector(6 downto 0); --數碼管的控制埠
led_dp:out std_logic --數碼管的小數點輸出埠
);
end xianshi;
architecture rt5 of xianshi is
signal an:std_logic_vector(6 downto 0); --數碼顯示管中間變數
signal shuju:std_logic_vector(3 downto 0); --選擇輸入端的中間變數
signal cnt:std_logic_vector(2 downto 0); --控制數碼管的中間變數
signal xiaodian:std_logic; --小數點的中間變數
begin
process(clk_scan) --開始進程
begin
if clk_scan'event and clk_scan='1' then
cnt<=cnt+1; --每有一個掃描信號上升沿實現加1掃描
end if;
end process; --結束進程

process(cnt) --開始進程(選擇掃描顯示數碼管)
begin
case cnt is --掃描時給每個數碼管賦值
when "000"=>shuju<=c0;
when "001"=>shuju<=c1;
when "010"=>shuju<=c2;
when "011"=>shuju<=c3;
when "100"=>shuju<=k0;
when "101"=>shuju<=k1;
when "110"=>shuju<=m0;
when "111"=>shuju<=m1;
when others=> null;
end case;
if (cnt="001" or cnt="110")
then xiaodian<='1'; --在里程和總費用的個位處顯示小數點
else xiaodian<='0';
end if;
end process; --結束進程

process(shuju) --開始進程(解碼顯示)
begin
case shuju is
when "0000"=>an<="0111111"; --0
when "0001"=>an<="0000110"; --1
when "0010"=>an<="1011011"; --2
when "0011"=>an<="1001111"; --3
when "0100"=>an<="1100110"; --4
when "0101"=>an<="1101101"; --5
when "0110"=>an<="1111101"; --6
when "0111"=>an<="0000111"; --7
when "1000"=>an<="1111111"; --8
when "1001"=>an<="1101111"; --9
when others=>null;
end case;
end process;
sel<=cnt;
led<=an;
led_dp<=xiaodian;
end rt5;
二、課程設計工作記錄:
包括:設計步驟與時間安排、調試步驟與時間安排、課題完成結果說明
2.課題完成結果說明:
此計費器能實現起步價是5元;實現實驗要求的1公里計費一次單價,行駛公里大於2km時每公里按1.4元計費並能顯示里程和總共的費用。當行駛了6公里,等待了4分鍾時,費用顯示為15.8元。與計算公式總費用=起步費用+(里程-2公里)*里程單價+等候時間*等後單價;即15.8=5+(6-2)*1.4+4*1.3。實驗結果與理論結果完全一致,實驗設計成功。

5. EDA計程車設計課程設計

計程車計價器,要求顯示里程和金額
給做好

6. 計程車計價器eda 設計報告

你沒,這個你怎麼理解

7. eda課程設計計程車計價器

要實物嗎

我做電子設計的

8. EDA 計程車計費器 求大神幫忙 謝謝了 很急啊!!!

以前做的設計,參考一下,記得給分啊
粘過來時圖形好像沒顯示啊

一、設計目的
1、 熟悉和增強對VHDL語言的基本知識,熟悉利用VHDL語言對常用的的組合邏輯電路和時序邏輯電路編程,把編程和實際結合起來。
2、加深對編制和調試程序的技巧.
3、提高上機動手能力,培養使用設計綜合電路的能力。
二、設計要求
1、計程車啟動和停駛由司機控制;
2、行程小於基本里程時,顯示起步價,基本里程設3公里,起步價設5元;
3、行程大於基本里程時,每多行一公里,在起步價上加2元;
4、當計程車等待時,由司機按下等候鍵,每等待一分鍾加1元,不足一分鍾的按一分鍾計算;
5、此處用脈沖信號模擬輪胎的轉數,設每計一個脈沖汽車前進1米,系統中所需脈沖均由實驗箱的50MHz晶振分頻提供。
三、總體設計原理與內容(四號字、宋體、加粗)
1、設計的總體原理(比如演算法及其流程框圖等)
計程車計價器按功能主要分為:速度模塊、計程模塊、計時模塊、計費模塊。

2、設計內容
首先根據start信號判斷是否開始計費,然後根據sp判斷,確定1米所需要的時鍾數,每前進一米,輸出一個clkout,同時由cnt對clk進行計數。
通過對clkout信號的計數,可計算形式的距離kmcount,一個clkout相當於行駛一米,所以只要記錄clkout的脈沖數,即可確定行駛距離。
通過對sp信號的判斷,確定是否開始計時。Sp= 0時,開始記錄時間。當時間足夠長時,產生timecount脈沖。
計費模塊分為kmmoney1和kmmoney2兩個進程。kmmoney1用於產生enable和price信號。當記錄距離達到3km後,enable信號為1,開始進行每千米的計費。
kmmoney2用於判斷timecount和clkout的值,當其為1時,總費用加1。最終輸出為總費用。
四、EDA設計及模擬(四號字、宋體、加粗)
1、計程車計價器的設計源程序
速度模塊的VHDL代碼如下:
library ieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;

entity speed is
port(
clk : in std_logic;
reset: instd_logic;
start:instd_logic;
stop:in std_logic;
sp:in std_logic;
clkout:out std_logic
);
end speed;
architecture rt1of speed is
begin
process(clk,reset,stop,start) -----敏感信號變化時,啟動進程
type state_typeis(s0,s1); ------枚舉類型
variables_state:state_type;
variablecnt:integer range 0 to 100;

begin

ifreset='1'then ----復位清
s_state:=s0;

elsif clk'eventand clk='1'then
case s_state is
when s0=>
cnt:=0;
clkout<='0';
if start='1'then
s_state:=s1;
else
s_state:=s0;
end if;

when s1=>
clkout<='0';
if stop='1'then
s_state:=s0; ----無客上車
elsif sp='0'then
s_state:=s1;
elsif cnt=100 then
cnt:=0;
clkout<='1';
s_state:=s1;
else
cnt:=cnt+1;
s_state:=s1;
end if;
end case;
end if;
end process;
end rt1;
計程模塊的VHDL代碼如下:
LIBRARY IEEE;
USEIEEE.STD_LOGIC_1164.ALL;
USEIEEE.STD_LOGIC_ARITH.ALL;
USEIEEE.STD_LOGIC_UNSIGNED.ALL;

ENTITY km IS
PORT (
CLKOUT,RESET: IN STD_LOGIC;
kmcnt1:OUT STD_LOGIC_VECTOR (3 DOWNTO0);
kmcnt2:OUT STD_LOGIC_VECTOR (3 DOWNTO0);
kmcnt3:OUT STD_LOGIC_VECTOR (3 DOWNTO0));
END km;

ARCHITECTURE rtlOF km IS
BEGIN
PROCESS(CLKOUT,RESET) ----啟動進程
VARIABLE kM_reg: STD_LOGIC_VECTOR (11DOWNTO 0);
BEGIN
IF RESET ='1' THEN ---復位清零
kM_reg:="000000000000";
ELSIF CLKOUT'EVENT AND CLKOUT='1' THEN ---------時鍾上升沿到達時進行計程
IF kM_reg(3 DOWNTO 0)="1001"THEN ---------對應里程十分位
kM_reg:=kM_reg+"0111"; ---------十分位向個位進位
ELSE
kM_reg(3 DOWNTO 0):=kM_reg(3 DOWNTO0)+"0001";
END IF;
IF kM_reg(7 DOWNTO 4)="1010"THEN
kM_reg:=kM_reg+"01100000"; ---------個位向十位進位
END IF;
END IF;
kmcnt1<=kM_reg(3 DOWNTO 0);
kmcnt2<=kM_reg(7 DOWNTO 4);
kmcnt3<=kM_reg(11 DOWNTO 8);
END PROCESS;
END rtl;

計時模塊的VHDL代碼如下:
library ieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;

entity times is
port(
clk : in std_logic;
reset: in std_logic;
start:in std_logic;
stop:in std_logic;
sp :in std_logic;
timecount:out std_logic
);
end times;

architecture rt1of times is
begin
process(clk,reset,stop,start,sp) -----啟動進程
type state_type is(t0,t1,t2);
variable t_state:state_type;
variable cnt:integer range 0 to 28;
variable waittime:integer range 0 to 255;
begin
if reset='1'then ----復位清零
t_state:=t0;

elsif clk'event and clk='1'then
case t_state is
when t0=>
waittime:=0;
timecount<='0';
if start='1'then
t_state:=t1;
else
t_state:=t0;
end if;

when t1=>
if sp='0'then
t_state:=t2;
else
waittime:=0;
t_state:=t1;
end if;

when t2=>
waittime:=waittime+1;------等待時間加1
timecount<='0';
if waittime=255 then
timecount<='1'; -------產生一個時間計費脈沖
waittime:=0;
elsif stop='1'then
t_state:=t0;

else
timecount<='0';
t_state:=t1;
end if;
end case;
end if;
end process;
end rt1;

計費模塊的VHDL代碼如下:
LIBRARY IEEE;
USEIEEE.STD_LOGIC_1164.ALL;
USEIEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY kmmoney IS
PORT(
CLK :IN STD_LOGIC;
RESET:IN STD_LOGIC;
timecount:IN STD_LOGIC;
clkout:IN STD_LOGIC;
kmcnt2:IN STD_LOGIC_VECTOR(3 DOWNTO 0);
kmcnt3:in STD_LOGIC_VECTOR(3 DOWNTO 0);
COUNT1:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
COUNT2:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
COUNT3:OUT STD_LOGIC_VECTOR(3 DOWNTO 0)
);
END kmmoney ;

ARCHITECTURE rtlOF kmmoney IS
SIGNAL cash :STD_LOGIC_VECTOR(11 DOWNTO 0);
SIGNAL price :STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL enable :STD_LOGIC;
BEGIN
kmmoney1:process(cash,kmcnt2) -------------此進程產生下一進程的敏感信號
BEGIN
price<="0010";
if kmcnt2>="0010" then
enable<='1';
else
enable<='0';

END IF;
END PROCESS;

kmmoney2:process(reset,clkout,clk,enable,price,kmcnt2)
variablereg2:std_logic_vector(11 DOWNTO 0);
variableclkout_cnt:integer range 0 to 10;
begin
if reset='1'then

cash<="000000000101";
-------起步費用設為5元

elsif clk'eventand clk='1'then
----判斷是否需要時間計費,每60s加1元
if timecount='1'then
reg2:=cash;
if (reg2(3 downto
0)+"0001")>"1001" then
------產生進位------
reg2(7 downto 0):=reg2(7 downto0)+"00000111";
if reg2(7 downto4)>"1001"then
cash<=reg2+"000001100000";
else
cash<=reg2;

END IF;
else
cash<=reg2+"0001";

END IF;
---里程計費

elsif clkout='1'and enable='1'then

if clkout_cnt=10 then
clkout_cnt:=0;
reg2:=cash;
if
"0000"®2(3 downto 0)+price(3 downto 0)
>"00001001"then
reg2(7 downto 0):=reg2(7downto 0)+"00000110"+price; ----十位進位
if reg2(7 downto4)>"1001"then ----百位進位
cash<=reg2+"000001100000";
else
cash<=reg2;
END IF;
else
cash<=reg2+price;

END IF;
else -----------------------對時鍾計數
clkout_cnt:=clkout_cnt+1;
END IF;
END IF;
END IF;
END process;
COUNT1<=cash(3 DOWNTO 0); -----總費用的個位
COUNT2<=cash(7 DOWNTO 4); -----總費用的十位
COUNT3<=cash(11 DOWNTO 8); -----總費用的百位
END rtl;
頂層模塊的VHDL代碼如下:
library ieee;
use ieee.std_logic_1164.all;
entity top is
port(
clk : in std_logic;
reset: in std_logic;
start:in std_logic;
stop:in std_logic;
sp :in std_logic;
kmcnt1:OUTSTD_LOGIC_VECTOR (3 DOWNTO 0);
kmcnt2:OUTSTD_LOGIC_VECTOR (3 DOWNTO 0);
kmcnt3:OUTSTD_LOGIC_VECTOR (3 DOWNTO 0);
COUNT1:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
COUNT2:OUTSTD_LOGIC_VECTOR(3 DOWNTO 0);
COUNT3:OUTSTD_LOGIC_VECTOR(3 DOWNTO 0)
);
end top;

ARCHITECTURE rtl OF top IS
------- 對上述電路模塊進行元件定義--------
COMPONENT SPEED IS------------定義速度模塊
port(
clk : in std_logic;
reset: in std_logic;
stop:in std_logic;
start:in std_logic;
sp :in std_logic;
clkout:out std_logic
);
end COMPONENT speed;
COMPONENT km is ---定義計程模塊
PORT (
CLKOUT,RESET: INSTD_LOGIC;
kmcnt1:OUTSTD_LOGIC_VECTOR (3 DOWNTO 0);
kmcnt2:OUTSTD_LOGIC_VECTOR (3 DOWNTO 0);
kmcnt3:OUTSTD_LOGIC_VECTOR (3 DOWNTO 0)
);
end COMPONENT km;
COMPONENT kmmoney is--------定義計費模?------
PORT(
CLK :IN STD_LOGIC;
RESET:IN STD_LOGIC;
timecount:INSTD_LOGIC;
clkout:IN STD_LOGIC;
kmcnt2:INSTD_LOGIC_VECTOR(3 DOWNTO 0);
kmcnt3:inSTD_LOGIC_VECTOR(3 DOWNTO 0);
COUNT1:OUTSTD_LOGIC_VECTOR(3 DOWNTO 0);
COUNT2:OUTSTD_LOGIC_VECTOR(3 DOWNTO 0);
COUNT3:OUTSTD_LOGIC_VECTOR(3 DOWNTO 0)
);

end COMPONENT kmmoney;

component times is
port( clk:in std_logic;
reset:instd_logic;
stop:in std_logic;
start:instd_logic;
sp:in std_logic;
timecount:outstd_logic
);
end component times;

signal clktmp:STD_LOGIC;
signal timetmp:STD_LOGIC;
signal kmtmp2:STD_LOGIC_VECTOR (3 DOWNTO 0);
signal kmtmp3:STD_LOGIC_VECTOR (3 DOWNTO 0);
begin

U1:speed PORTMAP(clk,reset,stop,start,sp,clktmp);
U2: times PORTMAP(clk,reset,stop,start,sp,timetmp);
U3:km PORTMAP(clktmp,reset,kmcnt1,kmtmp2,kmtmp3);
U4:kmmoney PORTMAP(clk,reset,timetmp,clktmp,kmtmp2,kmtmp3,COUNT1,COUNT2,COUNT3);
kmcnt2<=kmtmp2;
kmcnt3<=kmtmp3;
end rtl;
2、計程車計價器的設計
模擬結果及數據分析
計程車計費器的電路圖如圖:
上圖中當reset為高電平時,系統所有寄存器、計數器都清零;當開始記費信號start信號有效時,計費器開始計費,根據計程車行駛的速度sp的取值計算所用花費和行駛里程;當停止計費信號有效時,計費器停止工作。

對上圖構成的系統進行模擬,得到的模擬波形為:

五、硬體實現
1、給出硬體實現(步驟及引腳鎖定等說明等)
主要模塊中包括輸入時鍾脈沖clk,時鍾上升沿有效;復位信號reset,開始計費信號start,停止計費信號stop,均為高電平有效;計程車狀態sp。

2、硬體實現照片
該照片為超過基本行程的的照片,顯示為行駛5.5公里,費用為11元。等待1分鍾,共計12元。
該照片為基本行程內的的照片,顯示為行駛2.6公里,收費5元,顯示正確。

該圖片顯示,行駛7.9公里,費用為15元,顯示正確。
等待計費,行駛5.5公里,攻擊11元,等待8分鍾,共計19元。
六、設計總結
1、設計過程中遇到的問題及解決方法
設計中遇到了數碼管無法正常顯示,計費不按要求等問題。通過的對源代碼的修改,發現易忽略了一些細節。
2、設計體會
從挑選課設題目,查閱資料,到研究出總體設計,詳細設計,然後分工合作,再到最後的編程上機調試,修改程序,完善程序,收獲頗多。計程車計費器系統的設計已全部完成,能按預期的效果進行模擬汽車啟動,停止、暫停等功能,並設計動態掃描電路顯示車費數目。車暫停時停止計費。若停止清零,等待下一次計費的開始。由於時間有限,經驗欠缺,還存在很多不足之處。
在這一周里我們再次熟悉和增強了對VHDL語言的基本知識,熟悉利用VHDL語言對常用的的組合邏輯電路和時序邏輯電路編程,把編程和實際結合起來。加深了對編制和調試程序的技巧,進一步提高了上機動手能力,培養了使用設計綜合電路的能力,養成了提供文檔資料的習慣和規范編程的思想。
本次的課程設計將各個單一的模塊實現其功能後,學會通過原理圖或頂層文件把各模塊連接,從而實現對計程車自動計費。課程設計注重的不僅是把理論知識鞏固,而且應把理論和實際相結合,把知識應用到生活中。在課程設計過程中,遇到了不少問題,數碼管無法正常顯示,計費不按要求等。通過的對源代碼的修改,發現了一些易忽略的細節。課程設計考驗的是思維邏輯能力,對知識的靈活應用,當然,合作精神是不可或缺的。
在設計程序時,反復修改、不斷改進是程序設計的必經之路;要養成注釋程序的好習慣,一個程序的完美與否不僅僅是實現功能,而應該讓人一看就能明白你的思路,這樣也為資料的保存和交流提供了方便;在設計課程過程中遇到問題是很正常的,但應該將每次遇到的問題記錄下來,並分析清楚,以免下次再碰到同樣的問題。發現、提出、分析、解決問題和實踐能力的提高都會受益於我在以後的學習、工作和生活中。在設計的過程中發現了自己的不足之處,對以前所學過的知識理解得不夠深刻,掌握得不夠牢固。
3、對設計的建議
本設計為計程車計費器的VHDL設計,利用軟體模擬和硬體測試實現了其計費功能、預制功能、模擬功能等,建議時間延長,不拘於用VHDL一種語言,而且要求創造出實物。這樣可以讓學生自由發揮,拓寬思路,提高動手能力。
七、設計生成的電路圖

9. EDA課程設計計程車計價器的VHDL語言設計的程序

給我具體的要求,不出意外2天後給你,不會耽誤你吧,但是希望在加點分 ,我們一般都用的QuartusII5模擬的,不好意思,我這一陣子有點忙,這是我同學以前做的,我還沒來的急看了,你看看符合你的要求嗎?如果那裡不符合,告訴我,我再改。這個肯定不能自動滿足你上訴的要求的,這些事是要求你自己加信號的,你自己該也可以,比如你沒有要求半道停車的,在模擬時就屏蔽stop埠就行了,至於缺少什麼功能,你在告訴我。
計程車計價器VHDL程序與模擬

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_240 :in std_logic; --頻率為240Hz的時鍾
start :in std_logic; --計價使能信號
stop:in std_logic; --等待信號
fin:in std_logic; --公里脈沖信號
cha3,cha2,cha1,cha0:out std_logic_vector(3 downto 0); --費用數據
km1,km0:out std_logic_vector(3 downto 0); --公里數據
min1,min0: out std_logic_vector(3 downto 0)); --等待時間
end taxi;
architecture behav of taxi is
signal f_15,f_16,f_1:std_logic; --頻率為15Hz,16Hz,1Hz的信號
signal q_15:integer range 0 to 15; --分頻器
signal q_16:integer range 0 to 14; --分頻器
signal q_1:integer range 0 to 239; --分頻器
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_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'; --此IF語句得到頻率為15Hz的信號
else q_15<=q_15+1;f_15<='0';
end if;
if q_16=14 then q_16<=0;f_16<='1'; --此IF語句得到頻率為16Hz的信號
else q_16<=q_16+1;f_16<='0';
end if;
if q_1=239 then q_1<=0;f_1<='1'; --此IF語句得到頻率為1Hz的信號
else q_1<=q_1+1;f_1<='0';
end if;
if en1='1' then f<=f_15; --此IF語句得到計費脈沖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; --此IF語句完成等待計時
if m0="1001" then m0<="0000"; --此IF語句完成分計數
if m1<="101" then m1<="000";
else m1<=m1+1;
end if;
else m0<=m0+1;
end if;
if m1&m0>"0000001"then en1<='1'; --此IF語句得到en1使能信號
else en1<='0';
end if;
else w<=w+1;en1<='0';
end if;
elsif fin='1' then
if k0="1001" then k0<="0000"; --此IF語句完成公里脈沖計數
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'; --此IF語句得到en0使能信號
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;

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"; --此IF語句完成對費用的計數
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;

熱點內容
武漢大學學生會輔導員寄語 發布:2021-03-16 21:44:16 瀏覽:612
七年級學生作文輔導學案 發布:2021-03-16 21:42:09 瀏覽:1
不屑弟高考成績 發布:2021-03-16 21:40:59 瀏覽:754
大學畢業證會有成績單 發布:2021-03-16 21:40:07 瀏覽:756
2017信陽學院輔導員招聘名單 發布:2021-03-16 21:40:02 瀏覽:800
查詢重慶2018中考成績查詢 發布:2021-03-16 21:39:58 瀏覽:21
結業考試成績怎麼查詢 發布:2021-03-16 21:28:40 瀏覽:679
14中醫醫師資格筆試考試成績查分 發布:2021-03-16 21:28:39 瀏覽:655
名著賞析課程標准 發布:2021-03-16 21:27:57 瀏覽:881
北京大學商業領袖高端培訓課程 發布:2021-03-16 21:27:41 瀏覽:919