1、EDA 技术课程设计报告 一、设计题目及要求: 出租车计费器 (1)具有行车里程计费、等待时间计费、起价三部分,最大显示金额 99.99 元 (2)起价:三公里内 8 元,等待时间超过 10 分钟 1 元/10 分钟,行车里程单价 1 元,价格 数值可修改。 二、设计思路: 首先用分频模块产生三个分频, 一个用来计算等到时间超过 10 分钟时的价格, 一个用来 计算行车里程超过三公里时的价格, 还有一个用于计算等待时间以及行车里程。 用计量模块 计算等待时间,若超过十分钟,则使 en1 为 1,否则为 0,若行车里程超过 3 公里,则使 en0 为 1,否则为 0。用控制模块根据 en1 和
2、en0 的值选择计费时钟。用计费模块进行计费。最 后用显示模块进行 8 个数码管的依次显示。 三、各个模块的具体实现: 分频模块分频模块思路: 输入 400HZ 的时钟,产生一个 20 分频的时钟(即 20HZ)用来计算等待时间超过 10 分钟 时的 0.1 元/min;再产生一个 2 分频的时钟(即 200HZ)用来计算行车里程超过三公里时的 1 元/公里。最后产生一个 1HZ 的时钟,用做几个子模块的时钟。 1、分频模块的源程序: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use iee
3、e.std_logic_unsigned.all; entity fp is -分频模块 port( clk_400:in std_logic; -输入 400HZ 的时钟 q2:out std_logic; -二分频时钟,用来计算里程超过 3 公里的价钱 q20:out std_logic; -二十分频时钟, 用来计算等待时间超过 10 分钟的价钱 q1:out std_logic); -几个子模块的时钟 end fp; architecture behav of fp is begin process(clk_400) variable count2:integer range 0 to
4、199; variable count20:integer range 0 to 19; variable count1 :integer range 0 to 399; begin if clk_400event and clk_400=1 then -上升沿检测 if count2=199 -产生 2 分频的时钟 then count2:=0;q2=1; else count2:=count2+1;q2=0; end if; if count20=19 -产生 20 分频的时钟 then count20:=0;q20=1; else count20:=count20+1;q20=0; en
5、d if; if count1=399 -产生子模块的时钟 then count1:=0;q1=1; else count1:=count1+1;q1=0; end if; end if; end process; end behav; 分频模块波形仿真图: clk_400 是产生 400HZ 的脉冲,q1 产生的是 1HZ 的脉冲,当等待时用来累计等待时间,当行 驶时用来累计行驶的路程;q2 是一个两分频的脉冲,产生 200HZ 的脉冲,相当于是 1 元, 用来计算超出 3 公里时的价钱,每公里 1 一元;q20 是一个 20 分频的脉冲,产生的是 20HZ 的脉冲,相当于是 0.1 元,用
6、来计算等待时间超过十分钟时的价钱,每分钟是 0.1 元。 分频模块封装形式: 控制模块控制模块思路: 如果 en1 为 1,则表示等待时间超过 10 分钟,选择 20 分频的时钟, clk_20;如果 en0 等于 1, 表示行车里程超过 3 公里,选择 2 分频的时钟,clk_2。 2、控制模块的源程序: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity kongzhi1 is port( en0,en1:in std_logic; clk_in20:in std_logic; clk_in2:in std_logic; clk_out:out std_logic