vhdl秒表

作者&投稿:竹生 (若有异议请与网页底部的电邮联系)
vhdl秒表~

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_ARITH.ALL;

use IEEE.STD_LOGIC_UNSIGNED.ALL;


---- Uncomment the following library declaration if instantiating

---- any Xilinx primitives in this code.

--library UNISIM;

--use UNISIM.VComponents.all;


entity minutes is

Port ( rst3,selector2,ky_2j : in STD_LOGIC;

B10 : in std_logic;

C : out std_logic;

dat30 : out std_logic_vector(7 downto 0));

end minutes;

architecture Behavioral of minutes is

signal dat31,dat32 : std_logic_vector(7 downto 0):=(others =>'0');

begin


process(rst3,B10,ky_2j)

begin

case selector2 is

when '1' =>dat32<=dat31; if ky_2j'event and ky_2j='1' then

if dat31(7 downto 4)="0101" and dat31(3 downto 0)="1001"

then dat31(7 downto 0)<="00000000";

elsif dat31(3 downto 0)<"1001" then dat31(3 downto 0)<=dat31(3 downto 0)+1;

else dat31(3 downto 0)<="0000";

if dat31(7 downto 4)<"0101" then dat31(7 downto 4)<=dat31(7 downto 4)+1;

else dat31(7 downto 4)<="0000";

end if ;

end if ;

end if ;

dat30<=dat31;


when '0' =>dat31'0');

elsif B10'event and B10='1' then

if dat32(7 downto 4)="0101" and dat32(3 downto 0)="1001"

then C<='1'; dat32(7 downto 0)<="00000000";

else C<='0';

if dat32(3 downto 0)<"1001" then dat32(3 downto 0)<=dat32(3 downto 0)+1;

else dat32(3 downto 0)<="0000";

if dat32(7 downto 4)<"0101" then dat32(7 downto 4)<=dat32(7 downto 4)+1;

else dat32(7 downto 4)<="0000";

end if;

end if;

end if;

end if;

dat30<=dat32;

when others =>null;


end case;

end process;


end Behavioral;

用vhdl设计秒表全功略!
根据要求, 秒表的设计要有三个输入端:runstop,rst和clk. runstop是开关, 按一下开始计时, 再按一下停止计时, 显示时间. 可以使用一个T触发器来实现. 当我们把T触发器的T端接高电平时, 它将实现翻转功能. 然后用输入端口runstop 来控制, 当runstop 被按一下, 一个时钟到来, T触发器就进行一次翻转. 我们也可以用D触发器来代替T触发器, 需要用一个反馈信号, 将输出的信号反馈到D端口. Rst 是复位, 当按下rst 时, 秒表的显示变为0. Clk是时钟, 实验中的时钟信号是250KHZ,为了实现秒表的正确计时功能, 需要进行2500分频. 所以clk首先就应该接到一个分频器, 然后再为其他模块提供时钟. 接着我们把秒表划分为以下几个模块:分频器, 计数器, T触发器, 扫描器, 八选一选择器, 七段译码器, 另外还有一个模块要在分, 秒和毫秒之间做一个划分(BAR). 计数器的功能是要实现毫秒,秒,分的计数,比较麻烦.我们再将它分成几个模块, 可以是六进制的计数器和十进制的计数器进行级联来实现.也可以是用100进制的计数器和60进制的计数器进行级联. 我两种方法都尝试了一下.发现后一种方法编程要复杂的多, 级联的时候可以稍微简单一些. 因为D触发器,八选一选择器是程序包里有的,所以可以不编. 把这些模块都编好了以后要做的就是把他们连在一起. 有两种方法. 一是用画图的方法, 二是用编程的方法, 用port map语句. 同样, 这两种方法我也都尝试了. 我觉得用画图的方法要简单一些.

1程序如下:分频器: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity df is port(clkin:in std_logic; dout:out std_logic);

end; architecture behavioral of df is begin process(clkin) variable df: std_logic_vector(7 downto 0):="00000000"; begin if (clkin'event and clkin='1')then if df/="11111010" then df:=df+1; else df:="00000001"; end if; end if; dout<=df(7); end process; end behavioral; 扫描器: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;

entity scan is port(clk:in std_logic; s:out std_logic_vector(2 downto 0)); end scan;

architecture behavioral of scan is variable scan:std_logic_vector(2 downto 0); begin process(clk) begin if(clk'event and clk='1')then scan:=scan+1; end if; s<=scan; end process; end behavioral; 七段译码器: library ieee; use ieee.std_logic_1164.all;

entity bcd is port(o:in std_logic_vector(3 downto 0); q:out std_logic_vector(6 downto 0)); end bcd ;

architecture behavioral of bcd is begin process(o) begin case o is when"0000"=>qqqqqqqqqqq<="0000000"; end case; end process; end behavioral; 当然,以上的100进制和60进制计数器的设计过于复杂,可以由六进制和十进制的计数器级联代替,程序如下:六进制: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity c6 is port(count:out std_logic_vector(3 downto 0); cout:out std_logic; cin,rst,clk:in std_logic); end c6; architecture behavioral of c6 is signal counter:std_logic_vector(2 downto 0); begin process(clk,rst) begin if rst='1'then counter<="000";cout<='0'; elsif clk'event and clk='1' then if cin='1' then if counter="101"then counter<="000";cout<='1'; else counter<=counter+"001"; cout<='0'; end if; end if; end if; end process; count(2 downto 0)<=counter; count(3)<='0'; end behavioral;

十进制: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;

entity c10 is port(count:out std_logic_vector(3 downto 0); cout:out std_logic; cin,rst,clk:in std_logic); end c10;

architecture behavioral of c10 is signal counter:std_logic_vector(3 downto 0); begin process(clk,rst) begin if rst='1'then counter<="0000";cout<='0'; elsif clk'event and clk='1' then if cin='1' then if counter="1001"then counter<="0000";cout<='1'; else counter<=counter+"0001"; cout<='0'; end if; end if; end if; end process; count<=counter; end behavioral;

最后用画图讲这些模块连接起来.

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_ARITH.ALL;

use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating

---- any Xilinx primitives in this code.

--library UNISIM;

--use UNISIM.VComponents.all;

entity minutes is

Port ( rst3,selector2,ky_2j : in STD_LOGIC;

B10 : in std_logic;

C : out std_logic;

dat30 : out std_logic_vector(7 downto 0));

end minutes;

architecture Behavioral of minutes is

signal dat31,dat32 : std_logic_vector(7 downto 0):=(others =>'0');

begin

process(rst3,B10,ky_2j)

begin

case selector2 is

when '1' =>dat32<=dat31; if ky_2j'event and ky_2j='1' then

if dat31(7 downto 4)="0101" and dat31(3 downto 0)="1001"

then dat31(7 downto 0)<="00000000";

elsif dat31(3 downto 0)<"1001" then dat31(3 downto 0)<=dat31(3 downto 0)+1;

else dat31(3 downto 0)<="0000";

if dat31(7 downto 4)<"0101" then dat31(7 downto 4)<=dat31(7 downto 4)+1;

else dat31(7 downto 4)<="0000";

end if ;

end if ;

end if ;

dat30<=dat31;

when '0' =>dat31<=dat32; if(rst3 = '0') then dat32<=(others =>'0');

elsif B10'event and B10='1' then

if dat32(7 downto 4)="0101" and dat32(3 downto 0)="1001"

then C<='1'; dat32(7 downto 0)<="00000000";

else C<='0';

if dat32(3 downto 0)<"1001" then dat32(3 downto 0)<=dat32(3 downto 0)+1;

else dat32(3 downto 0)<="0000";

if dat32(7 downto 4)<"0101" then dat32(7 downto 4)<=dat32(7 downto 4)+1;

else dat32(7 downto 4)<="0000";

end if;

end if;

end if;

end if;

dat30<=dat32;

when others =>null;

end case;

end process;

end Behavioral;


煮鸡蛋煮多久合适
煮沸时间过长的鸡蛋,人体内消化要3小时15分。“5分钟鸡蛋”不仅软嫩、蛋香味浓,而且有益人体营养。美国医学界曾发表研究报告(又没有出处),24名成人每日吃两个半熟蛋,6个星期后血脂并没有上升,对人体有益的好胆固醇(HDL)反增加10%。结论:开水煮5分钟的鸡蛋好!

中山区18542306136: 秒表的VHDL语言设计程序! -
夙念门冬: 用vhdl设计秒表全功略!根据要求, 秒表的设计要有三个输入端:runstop,rst和clk. runstop是开关, 按一下开始计时, 再按一下停止计时, 显示时间. 可以使用一个T触发器来实现. 当我们把T触发器的T端接高电平时, 它将实现翻转功能. 然后用...

中山区18542306136: 秒表电路的设计 VHDL语言 -
夙念门冬: 直接用单个VHDL工程实现,会比较复杂,可能刚开始学写起来比较头痛.建议:可以按模块实现,可以分为:计数器模块(写个计数器很简单),控制模块,显示模块 最后把他们用框图文件连接起来就可以啦,试试看.不会可以问我,我以前也是这么学过来的,可以帮你理理思路.站内联系我就可以,一般我都在的.

中山区18542306136: 用VHDL语言写一个秒表,求指正 -
夙念门冬: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity mb is port(clk,clr,stop,djs: in std_logic; buzzer: out std_logic; sel: out std_logic_vector(5 downto 0); dig: out std_logic_vector(7 downto 0 )); end mb; architecture mb1 of ...

中山区18542306136: 用VHDL实现秒表功能,秒表要求实现秒表功能,要求有分、秒显示 -
夙念门冬: 用两个60进制计数器就是了.我以前做了一个24/12小时的电子钟,其counter60如下: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity s_counter60 is port(clk:in std_logic; bcd10,bcd1:buffer std_logic_vector(3 ...

中山区18542306136: 求用 VHDL 语言编写的秒表、计时器的程序
夙念门冬:http://www.icdiy.cn/soft/10/200804/11380.html 到这里有下载

中山区18542306136: 用vhdl设计秒表 ,需要一个保持功能怎么实现?即保持的时候输出不变,内部仍然在计数 -
夙念门冬: 这种设想是无法实现的.电路模块是无法判断哪一个时钟的上升沿是复位上升沿,哪一个上升沿是计数上升沿.你必须增加一个输入信号reset.但可以设计成同步复位,即:当reset有效时,在时钟信号的上升沿才进行复位操作;当reset信号失效后,时钟信号的上升沿进行计数操作.

中山区18542306136: eda秒表程序 -
夙念门冬: 1. “分分:秒秒”计数器设计 我们要实现“分分:秒秒”显示的电子秒表,需要设计计数频率为1Hz 的 计数器.因为“分分:秒秒”的结构对应有4个十进制数字(个位的秒,十位的 秒,个位的分,十位的分),如果采用统一计数再分别求出...

中山区18542306136: vhdl 秒表程序如何用例化语句将各模块连起来 -
夙念门冬: 给你看个例化的例子:三输入 或门例化2输入或门 library ieee; use ieee.std_logic_1164.all; ---2输入或门 entity huo is port(a,b:in std_logic; c:out std_logic); end entity; architecture art of huo is beginc<=a or b; end art; library ieee; use ieee.std_logic...

中山区18542306136: 利用vhdl语言和quartus ii6.0设计一个秒表,要有仿真结果 -
夙念门冬: 分三个部分:分频器,计数器,译码器.分频器:library ieee; use ieee.std_logic_1164.all; entity eproc is port(clkin : in std_logic; clkout : out std_logic ); end eproc; architecture behavior of eproc is signal tmp:std_logic:='0'; signal n:integer range 0 ...

中山区18542306136: 如何将用VHDL语言描述的数字秒表程序的各个模块儿连接起来,编译的时候只需要顶层文件吗? -
夙念门冬: 你可以将每个模块单独用 VHD 文件写好 顶层文件可以用元件例化 的办法把各个模块和输入输出端口联系起来. 或者将每个模块封装为元件, 顶层文件直接用 原理图来画图实现. 所有设计文件都放在同一个工程文件夹里,这样比较方便.

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网