致 谢
时间过得真快,毕业论文已经接近了尾声,在这短短的几个月的设计时间里,有过太多的欢笑,也有过太多的艰难困苦,但是在老师与同学的帮助之下,我战胜了一次次挫折,从中我学到了很多的东西,有的是以前学不到的东西,所以对于此次对出租车计费器的毕业设计,首先我得最诚挚的感谢我的指导老师——肖亚丽老师。从定题,设计、开题报告,整改以及论文的撰写与成稿过程中,都离不开老师对我的悉心指导与帮助。也许有的时候老师特别的忙,但是只要是我们在设计中遇到了问题,老师都会抽出时间来为我解答,肖老师以她严谨的治学之道、兢兢业业的工作作风为我树立了学习的典范,老师的每一次教导与鞭策都将是我人生中最宝贵的财富。
谢谢大家为我在这个设计提供的所有的帮助,没有你们的帮助和启发,我将很难完成本文的写作。
由于本人水平有限,论文中难免有瑕疵与不足之处,恳请各位老师和同学的批评和指正!
21
附 录
VHDL语言程序代码:
速度模块: library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity sd is //实体表达
port(
clk :in std_logic; //端口名称 reset:in std_logic; start:in std_logic; stop :in std_logic;
sp :in std_logic_vector(2 downto 0); clkout:out std_logic );
end sd;
architecture rtl of sd is //结构体表达 Begin //程序主体
process(clk,reset,start,stop,sp) type state_type is(s0,s1); variable s_state:state_type; variable cnt:integer range 0 to 28; variable kinside:integer range 0 to 30;
begin
case sp is
//赋值
when\ when\ when\
22
when\ when\ when\ when\ when\
end case;
if reset='1'then
s_state:=s0;
elsif clk'event and 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=\
s_state:=s1;
elsif cnt=kinside then
cnt:=0; clkout<='1'; s_state:=s1;
else
cnt:=cnt+1; s_state:=s1;
23
end if;
end case;
end if;
end process; end rtl;
计时模块: library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;
entity js is
port(
clk :in std_logic; reset:in std_logic; start:in std_logic; stop :in std_logic;
sp :in std_logic_vector(2 downto 0); timecount:out std_logic );
end js;
architecture rtl of js is begin
process(reset,clk,sp,stop,start)
type state_type is(t0,t1,t2); variable t_state:state_type;
variable waittime:integer range 0 to 10000;
begin
if reset='1'then
t_state:=t0;
24
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=\
t_state:=t2;
else
waittime:=0; t_state:=t1;
end if;
when t2=>
waittime:=waittime+1; timecount<='0'; if waittime=10000 then
timecount<='1'; waittime:=0;
elsif stop='1'then
t_state:=t0;
elsif sp=\
t_state:=t2;
else
25