基于vhdl出租车计价器设计说明书内容摘要:

0]c lk _s c anSE G[ 7. .0]D IP[ 7. .0]BC D 7ins t18 12 2. 各个模块的作用 ( 1) BCD7 模块: 输入 licheng信号和 money 信号转换成相应的七段数码管数据信号和地址信号输出 ( 2) C47 模块: 输入 second 数据信号、 minute 数据信号和 hour 数据信号转换成相应的七段数码管数据信号和地址信号输出 ; 当 hour 输入为 23~6 时, hourout 输出为 1,当 hour输入为 7~22 时, hourout 输出为 0。 3. 各个模块的程序 ( 1) BCD7 模块的程序及仿真: library ieee。 use。 use。 use。 entity BCD7 is port( Din1:in std_logic_vector(12 downto 0)。 显示 13 位里程数 Din2:in std_logic_vector(12 downto 0)。 13 位费用 clk_scan:in std_logic。 SEG:out std_logic_vector(7 downto 0)。 数码管显示 DIP:out std_logic_vector(7 downto 0))。 数码管地址 end BCD7。 architecture Arch of BCD7 is signal q : std_logic_vector(2 downto 0)。 signal Dq,Db,Ds,Dg,Dq2,Db2,Ds2,Dg2 : std_logic_vector(3 downto 0)。 signal data : std_logic_vector(3 downto 0)。 signal sel : std_logic_vector(2 downto 0)。 signal Din : std_logic_vector(12 downto 0)。 signal D2in : std_logic_vector(12 downto 0)。 signal i : std_logic。 begin P1: process(clk_scan) begin if(rising_edge(clk_scan)) then q=q+1。 end if。 end process P1。 P2: process(Din1) 进程 p2,里程显示 variable Din_int:integer range 0 to 9999。 variable rb:integer range 0 to 1000。 variable rs:integer range 0 to 100。 begin Din=Din1。 Din_int:=conv_integer(Din)。 把 din 变成整型变量 Dq=conv_std_logic_vector(Din_int/1000,4)。 里程的千位等于 Din_int 除以 1000 取整,并转换成 BCD rb:=Din_int rem 1000。 除以 1000后的 余数存放在 rb 13 Db=conv_std_logic_vector(rb/100,4)。 rb 除以 100,转换成 BCD存放在 Db中 rs:=rb rem 100。 Ds=conv_std_logic_vector(rs/10,4)。 Dg=conv_std_logic_vector(rs rem 10,4)。 end process P2。 P3:process(Din2) – 进程 p3,费用设置 variable Din_int2:integer range 0 to 9999。 variable rb2:integer range 0 to 1000。 variable rs2:integer range 0 to 100。 begin D2in=Din2。 Din_int2:=conv_integer(D2in)。 Dq2=conv_std_logic_vector(Din_int2/1000,4)。 rb2:=Din_int2 rem 1000。 Db2=conv_std_logic_vector(rb2/100,4)。 rs2:=rb2 rem 100。 Ds2=conv_std_logic_vector(rs2/10,4)。 Dg2=conv_std_logic_vector(rs2 rem 10,4)。 end process P3。 P4:process(q) 进程 P4,里程与费用的显示 begin sel=q(2)amp。 q(1)amp。 q(0)。 数码管地址 case sel is when 000=data= Dq。 DIP=10000000。 i=39。 139。 当 000 时,把数据存放在数码管的 10000000位,也就是最高位 when 001=data= Db。 DIP=01000000。 i=39。 139。 when 010=data= Ds。 DIP=00100000。 i=39。 139。 when 011=data= Dg。 DIP=00010000。 i=39。 139。 when 100=data= Dq2。 DIP=00001000。 i=39。 139。 when 101=data= Db2。 DIP=00000100。 i=39。 139。 when 110=data= Ds2。 DIP=00000010。 i=39。 139。 when 111=data= Dg2。 DIP=00000001。 i=39。 139。 when others=data=1111。 DIP=00000000。 i=39。 039。 end case。 end process P4。 P5:process(data,sel) 进程 p5,是否显示小数点 begin if((sel=010or sel=110) and i=39。 139。 )then 在 010 及 110时显示小数点 case data is when0000=SEG=11111101。 when0001=SEG=01100001。 when0010=SEG=11011011。 when0011=SEG=11110011。 when0100=SEG=01100111。 14 when0101=SEG=10110111。 when0110=SEG=10111111。 when0111=SEG=11100001。 when1000=SEG=11111111。 when1001=SEG=11100111。 when others=SEG=00000001。 end case。 else 否则不显示小数 点 case data is when0000=SEG=11111100。 when0001=SEG=01100000。 when0010=SEG=11011010。 when0011=SEG=11110010。 when0100=SEG=01100110。 when0101=SEG=10110110。 when0110=SEG=10111110。 when0111=SEG=11100000。 when1000=SEG=11111110。 when1001=SEG=11100110。 when others=SEG=00000000。 end case。 end if。 end process P5。 end Arch。 仿真波形如图 11: 图 11 ( 2) c47 模块的程序及仿真: library ieee。 use。 use。 use。 entity c47 is port( sec,min:in std_logic_vector(6 downto 0)。 hour:in std_logic_vector(5 downto 0)。 clk_scan:in std_logic。 SEG:out std_logic_vector(7 downto 0)。 DIP:out std_logic_vector(7 downto 0)。 15 hourout:out std_logic)。 end。 architecture one of c47 is signal q:std_logic_vector(2 downto 0)。 signal dig1,dig2,dig3,dig4:std_logic_vector(3 downto 0)。 signal dig5,dig6,dig7,dig8:std_logic_vector(3 downto 0)。 signal data: std_logic_vector(3 downto 0)。 signal sel:std_logic_vector(2 downto 0)。 begin P1: process(clk_scan) 进程 p1, 输入脉冲 Begin if(rising_edge(clk_scan)) then q=q+1。 上升沿加 1 end if。 end process P1。 P2: process(hour,min,sec) 进程 P2,时,分,秒的设置 begin dig1=00amp。 hour(5 downto 4)。 dia1 定义 4位,进行定义 dig2=hour(3 downto 0)。 dig3=1111。 dig4=39。 039。 amp。 min(6 downto 4)。 dig5=min(3 downto 0)。 dig6=1111。 dig7=39。 039。 amp。 sec(6 downto 4)。 dig8=sec(3 downto 0)。 end process P2。 P4:process(q) 进程 p4,显示时,分,秒 begin sel=q(2)amp。 q(1)amp。 q(0)。 case sel is when 000=data= dig1。 DIP=10000000。 当 000 时,数据放入地址 10000000 when 001=data= dig2。 DIP=01000000。 when 010=data= dig3。 DIP=00100000。 when 011=data= dig4。 DIP=00010000。 when 100=data= dig5。 DIP=00001000。 when 101=data= dig6。 DIP=00000100。 when 110=data= dig7。 DIP=00000010。 when 111=data= dig8。 DIP=00000001。 when others=data=1111。 DIP=00000000。 end case。 end process P4。 P5:process(data,sel) 进程 5,小数点是否显示 begin if(sel=001or sel=100)then 在 001 及 100时显示小数点 case data is 16 when0000=SEG=11111101。 when0001=SEG=01100001。 when0010=SEG=11011011。 when0011=SEG=11110011。 when0100=SEG=01100111。 when0101=SEG=10110111。 when0110=SEG=10111111。 when0111=SEG=11100001。 when1000=SEG=11111111。 when1001=SEG=11100111。 when others=SE。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。