EDA课程设计专题实践_eda课程设计专题实践

2020-02-28 其他范文 下载本文

EDA课程设计专题实践由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“eda课程设计专题实践”。

EDA课程设计专题实践

结课论文

题目:出租车自动计费器

专业:电子信息工程

班级:电子z1301 姓名:阳家昆 学号:1310910422

一、设计题目:出租车自动计费器

二、设计目标:

1、掌握出租车的计费功能

2、进一步熟悉用VHDL语言编写出租车计费程序

三、设计要求:

1、设计一个出租车自动计费器,具有行车里程计费、等候时间计费、及起价三部分,用三位数码管显示总金额,最大值为99.9元;

2、行车里程单价1.7元/公里,等候时间单价1元/5分钟,起价8元(3公里起价)。

3、行车里程的计费电路将汽车行驶的里程数转换成与之成正比的脉冲数,然后由计数译码电路转换成收费金额,以一个脉冲模拟汽车前进十米,则每100个脉冲表示1公里。

4、用两个数码管显示行驶公里数;两个数码管显示等待时间;三个数码管显示收费金额。

5、设置一个复位清零按键,可将计程公里数、计时数、应付费用清零;

6、设置一个刹车按键,当松开按键时公里数开始计程,按下时停止计程,开始计时;

四、设计原理:

根据设计要求,系统的输入信号clk,计价开始信号start,等待信号stop,里程脉冲信号fin。系统的输出信号有:总费用数C0—c3,行驶距离k0—k1,等待时间m0—m1等。系统有两个脉冲输入信号clk_48m,fin,其中clk_48m将根据设计要求分频成17hz,2hz和1hz分别作为公里计费和时间计费的脉冲。两个控制输入开关start,stop;控制过程为:start作为计费开始的开关,当start为高电平时,系统开始根据输入的情况计费。当有乘客上车并开始行驶时,fin脉冲到来,进行行驶计费,此时的stop需要置为0;如需停车等待,就把stop变为高电平,并去除fin输入脉冲,进行等待计费;当乘客下车且不等待时,直接将start置为0,系统停止工作;价格开始归为起步价8.0元。整个设计由分频模块,计量模块,计费模块,控制模块和显示模块五个部分组成。其中计量模块是整个系统实现里程计数和时间计数的重要部分;控制模块是实现不同计费方式的选择部分,根据所设计的使能端选择是根据里程计费还是根据等待时间计费,同时设计通过分频模块产生不同频率的脉冲信号来实现系统的计费。计量模块采用1hz的驱动信号,计费模块采用17hz,2hz的驱动信号;计量模块每计数一次,计量模块就实现17次或者2次计数,即为实现计时的0.2元/min,计程时的1.7元/km的收费。

三、设计内容: 1.分频模块

由于实验箱上没有17hz和2hz的整数倍时钟信号,因此采用频率 较大的48mhz进行分频,以近似得到17hz,2hz和1hz的时钟频率。通过以上三种不同频率的脉冲信号实行出租车行驶,等待两种情况下的不同计费。模块元件如下:

图1分频模块实体图 Library IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_arith.all;use IEEE.std_logic_unsigned.all;entity pulse is port(clk_48m:in std_logic;

clk_17:buffer std_logic;

clk_2:buffer std_logic;

clk_1 : buffer std_logic);

end pulse;architecture one of pulse is signal q_17:integer range 0 to 2823528;

signal q_2:integer range 0 to 23999999;signal q_1:integer range 0 to 47999999;begin

proce(clk_48m)begin If(clk_48m' event and clk_48m='1')then If q_17=2823528 then q_17

else q_17

end if;

If q_2=23999999 then q_2

else q_2

end if;

If q_1=47999999 then q_1

else q_1

end if;

end if;end proce;end;2.计量模块

计量模块主要完成计时和计程功能。计时部分:计算乘客的等待累积时间,本模块中en1使能信号变为1;当clk1每来一个上升沿,计时器就自增1,计时器的量程为59min,满量程后自动归零。计程部分:计算乘客所行驶的公里数,当行驶里程大于3km时。本模块中en0使能信号变为1;当clk每来一个上升沿,计程器就自增1,计程器的量程为

99km,满量程后自动归零。

图2计量模块实物图 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;

begin

proce(clk1)begin if clk1'event and clk1='1' then

if start='1' then

w

m0

if w=59 then

w

else w

m0

m1

else en1

if k0=“1001” then k0

else k1“00000010” then

en0

else en0

本模块主要是通过计量模块产生的两个不同的输入使能信号en0,en1,对每个分频模块输出的17hz,2hz的脉冲进行选择输出的过程;本模块实现了双脉冲的二选一;最终目的为了计费模块中对行驶过程中不同的时段进行计价。

图3控制模块实物图 Library IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_arith.all;use IEEE.std_logic_unsigned.all;entity kongzhi is port(en0,en1:in std_logic;

clk_in1:in std_logic;

clk_in2:in std_logic;

clk_out:out std_logic);

end kongzhi;architecture rt3 of kongzhi is begin proce(en0,en1)begin

if en0='1' then

clk_out

elsif en1='1' then

clk_out

end if;end proce;end rt3;4.计费模块

当计费信号start一直处于高电平即计费状态时,本模块根据控制模块选择出的信号从而对不同的单价时段进行计费。即行程在3km内,起步价8元;3km外以每公里1.7元计费,等待时间则按每分钟1.3元计费。c0,c1,c2分别表示费用的显示。

图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:buffer std_logic_vector(3 downto 0));end jifei;architecture rt4 of jifei is begin proce(clk2,start)begin if start='1'then c2

elsif clk2'event and clk2='1'then

if c0=“1001” then c0

if c1=“1001” then c1

if c2=“1001” then c2

else c2

end if;

else c1

end if;

else c0

end if;end if;end proce;end rt4;5.显示模块

显示模块完成计价,计时和计程数据显示。计费数据送入显示模块进行译码,最后送至以十元,元,角为单位对应的数码管上显示。计时数据送入显示模块进行译码,最后送至以分为单位对应的数码管上显示。计程数据送入显示模块进行译码,最后送至以km为单位的数码管上显示。

图五显示模块实物图 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity xianshi is

port(clk:in std_logic;

b,c,d,e,f,g,h:in std_logic_vector(3 downto 0);

sg:out std_logic_vector(6 downto 0);

dian:out std_logic;

bt:out std_logic_vector(7 downto 0));

end;architecture one of xianshi is signal cnt8 : std_logic_vector(2 downto 0);signal a : std_logic_vector(3 downto 0);signal xiao:std_logic;begin p1:proce(cnt8)

begin

case cnt8 is

when “000”=>bt

when “001”=>bt

when “010”=>bt

when “011”=>bt

when “100”=>bt

when “101”=>bt

when “110”=>bt

when others=>null;

end case;

if cnt8=“001” then xiao

else xiao

begin

if clk'event and clk='1' then

if cnt8

else cnt8

end if;

end if;

end proce p2;p3:proce(a)

begin

case a is

when “0000”=>sgsg

when “0010”=>sgsg

when “0100”=>sgsg

when “0110”=>sgsg

when “1000”=>sgsg

when others=>null;

end case;

end proce p3;

dian

end;

6.频率计模块

频率计模块为扫描电路提供高频率的时钟脉冲,是扫描电路正常工作。

图6频率计模块

library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity pulse1 is

port(clk: in std_logic;

--d:

in std_logic_vector(7 DOWNTO 0);

Fout: out std_logic);end;architecture one of pulse1 is signal full:std_logic;begin

p_reg:proce(clk)

variable cnt8:integer range 48000000 downto 0;

begin

if clk'event and clk='1'then

if cnt8 =2399 then

cnt8:=0;

full

else cnt8:=cnt8+1;

full

end if;

end if;end proce p_reg;p_div:proce(full)

variable cnt2:std_logic;

begin

if full'event and full='1' then

cnt2:=not cnt2;

If cnt2='1'then fout

else fout

end if;

end if;end proce p_div;end;

7、总结构图

四、实验现象

当start为按下时里程数开始计数,当里程数小于3时总金额恒为8元钱,当里程数大于3时总金额以17hz的频率加1。当按下stop时,里程数停止计数,时间开始计数,同时总金额以2hz的频率加1。当松开stop里程数又开始计数,当start松开时,总金额变为8元,里程数和时间都变为0.五、实验感想 经历这次实验是我对EDA编程有了新的认识,在自己编写出程序之后运行没有报错并不代表你的程序就对了。因为结果不一样那么程序还是存在着问题,那么这时应该一个模块一个模块的检查。在检查的时应该对相应模块做出波形图没看时候和自己的功能一样,是否达到所要的结果。在实在不知道哪里错了没我们可以请教老师,或者自己查询网络。我觉的编程时构思是相当重要的,这决定你的程序的复杂程度,越复杂的的程序出错的几率越大,当你修改的时候将会越困难,当然一个好的构思并不是你想的那么简单,这必须是多次编程累计的经验。当变得程序越多,你对程序了解的也就越深,自然而然你对编程的熟练度也就有很大的提升。这也就告诉我们,应盖在学习的时候好好学习才对,别老想着滥竽充数。

《EDA课程设计专题实践.docx》
将本文的Word文档下载,方便收藏和打印
推荐度:
EDA课程设计专题实践
点击下载文档
相关专题 eda课程设计专题实践 课程设计 专题 EDA eda课程设计专题实践 课程设计 专题 EDA
[其他范文]相关推荐
    [其他范文]热门文章
      下载全文