当前位置:首页 >> 行业知识库 >> 电话计费器行业知识库 >> 我想用vhdl设计一个电话计费器

我想用vhdl设计一个电话计费器

电话接通后,计时器开始计时,计价表也同时计价,起步价为0.2元.然后每过1分钟,计价表就增加0.2元.直到电话断开.计时停止,计价表也同时停止.
clk:时间的时钟信号:每60个clk为1min;
Reset:复位信号,将计费设置初值为0.2元,时间设置成初值0;
Phone:状态标志输出:phone=0为通话状态,phone=1为断开状态;
c1,c2,c3:计费输出显示信号;
m4,m3,m2,m1为时间显示信号;
最佳答案:
出租车计费器的程序供你参考:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
--------------------------------------------------------------------
entity exp14 is
port( Clk : in std_logic; --时钟输入
Rst : in std_logic; --复位输入
Motor : in std_logic; --电机脉冲输入
Display : out std_logic_vector(7 downto 0); --七段码管显示输出
SEG_SEL : buffer std_logic_vector(2 downto 0) --七段码管扫描驱动
);
end exp14;
--------------------------------------------------------------------
architecture behave of exp14 is
signal Disp_Temp : integer range 0 to 15;
signal Disp_Decode: std_logic_vector(7 downto 0);
signal Meter1,Meter10,Meter100,Meter1K : integer range 0 to 9;
signal Money1,Money10,Money100 : integer range 0 to 9;
signal Old_Money1 : integer range 0 to 9;
begin
process(Motor)
begin
if(Rst='0') then
Meter1<=0;
Meter10<=0;
Meter100<=0;
Meter1K<=0;
elsif(Motor'event and Motor='1') then
if(Meter1=9) then
Meter1<=0;
if(Meter10=9) then
Meter10<=0;
if(Meter100=9) then
Meter100<=0;
if(Meter1K=9) then
Meter1K<=0;
else
Meter1K<=Meter1K+1;
end if;
else
Meter100<=Meter100+1;
end if;
else
Meter10<=Meter10+1;
end if;
else
Meter1<=Meter1+1;
end if;
end if;
end process;
process(Clk)
begin
if(Rst='0') then
Money1<=0;
Money10<=0;
Money100<=0;
elsif(Clk'event and Clk='1') then
if(Meter1K<1) then --里程小于1Km是显示基价
Money100<=0;
Money10<=3; --起步价3元
Money1<=0;
Old_Money1<=0;
else
Money1<=Meter100;
Old_Money1<=Money1;
if(Old_Money1=9 and Money1=0) then
if(Money10=9) then
Money10<=0;
if(Money100=9) then
Money100<=0;
else
Money100<=Money100+1;
end if;
else
Money10<=Money10+1;
end if;
end if;
end if;
end if;
end process;
process(SEG_SEL)
begin
case (SEG_SEL+1) is
when "000"=>Disp_Temp<=Meter1K;
when "001"=>Disp_Temp<=Meter100;
when "010"=>Disp_Temp<=Meter10;
when "011"=>Disp_Temp<=Meter1;
when "100"=>Disp_Temp<=10;
when "101"=>Disp_Temp<=Money100;
when "110"=>Disp_Temp<=Money10;
when "111"=>Disp_Temp<=Money1;
end case;
end process;
process(Clk)
begin
if(Clk'event and Clk='1') then --扫描累加
SEG_SEL<=SEG_SEL+1;
if(SEG_SEL=5) then
Display<=Disp_Decode or "10000000";
else
Display<=Disp_Decode;
end if;
end if;
end process;
process(Disp_Temp) --显示转换
begin
case Disp_Temp is
when 0=>Disp_Decode<="00111111"; --0
when 1=>Disp_Decode<="00000110"; --1
when 2=>Disp_Decode<="01011011"; --2
when 3=>Disp_Decode<="01001111"; --3
when 4=>Disp_Decode<="01100110"; --4
when 5=>Disp_Decode<="01101101"; --5
when 6=>Disp_Decode<="01111101"; --6
when 7=>Disp_Decode<="00000111"; --7
when 8=>Disp_Decode<="01111111"; --8
when 9=>Disp_Decode<="01101111"; --9
when 10=>Disp_Decode<="01000000"; ---
when others=>Disp_Decode<="00000000"; --全灭
end case;
end process;
end behave;
-------------------------------------
可根据这个修改;程序设计还是要自己动手,天下没有免费的午餐^_^祝你好运,兄弟··
其 他 回 答: (共2条)
1楼
这个很简单啊
查看更多相关问题 >>
相关电话计费器行业知识库

友情链接:

首页 | 网站简介 | 采购市场 | 行业分类 | 信息投诉/删除/联系本站

手机版 | 电脑版

Copyright © 商名网

京ICP备17049264号