EDA数字秒表的设计(2)

2019-04-15 15:14

co:out std_logic);-------输出/进位信号 end count10;

architecture behave of count10 is begin process(clr,clk) begin if clr='0' then dout<=\

elsif(rising_edge(clk)) then if dout=\ co<='1';

else dout<=dout+1;co<='0'; end if; end if; end process; end behave;

图3.十进制计数器模块封装图

3.4 记录模块

记录模块的功能是实现当有一个记录脉冲过来时,所记录的使能输出加一,第一个使能输出对应的是第一个寄存器模块,往后以此类推。

实现的程序:

5

LIBRARY IEEE;

USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; entity RECORD1 is --------记录模块 port( clr:in std_logic; RST:in STD_LOGIC;

en:BUFFER std_logic_vector(2 downto 0)); ---使能输出 end;

architecture behave of record1 is begin

process(clr,RST) begin

if clr='0' then en<=\ elsif(RISING_edge(RST)) then en<=en+1; end if; end process; end;

图4.记录模块封装图

3.5 寄存器模块

寄存器模块主要是由4组16个D触发器构成的,当使能信号EN来临时,对应EN的一组触发器记录一个时间,并且将每一组的时间信号从输出端口输送到选择模块

6

的输入端口。

其中一组寄存器的程序为: LIBRARY IEEE;

use ieee.std_logic_1164.all;

ENTITY DFF1 IS ------4位D触发器 PORT(

clr:in std_logic;

en:in std_logic_vector(2 downto 0);-----使能信号 clk:in std_logic;

d1:in std_logic_vector(3 downto 0);------输入信号 q1:out std_logic_vector(3 downto 0)); END;

architecture behave of dff1 is

signal Q:std_logic_VECTOR(3 DOWNTO 0); BEGIN

PROCESS(CLR,CLK,EN) BEGIN

IF en=\ IF CLR='0' THEN Q<=\

ELSIF RISING_EDGE(CLK) THEN Q<=d1; END IF; END IF; END PROCESS; Q1<=Q; END;

7

图5.寄存器模块封装图

3.6 回放模块

回放模块输入是回放按钮的一个脉冲信号,来一个脉冲,使能信号PN加一,然后将使能信号输入到选择模块中作为判断信号。

程序为: LIBRARY IEEE;

USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; entity REPLAY is -----------回放模块 port(clr:in std_logic; rsh:in std_logic;

pn:buffer std_logic_vector(2 downto 0)); ---使能输出 end;

architecture behave of replay is begin process(clr,rsh) begin

if clr='0' then pn<=\

ELSif (RISING_EDGE(RSH)) then pn<=pn+1; end if;

8

end process; end;

图6.回放模块封装图

3.7 选择模块

选择模块的功能是:当PN=”000”时,输出的只是计数器数据,即当时时间; 当PN=”001”时,输出的是存储在第一组寄存器中的时间; 当PN=”010”时,输出的是存储在第二组寄存器中的时间; 当PN=”011”时,输出的是存储在第三组寄存器中的时间; 当PN=”100”时,输出的是存储在第四组寄存器中的时间。

实现程序为:

LIBRARY IEEE;

USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENTITY select1 IS ------------------选择模块 PORT( pn:in std_logic_vector(2 downto 0);

din0,din1,din2,din3:in std_logic_vector(3 downto 0);

q00,q01,q02,q03,q10,q11,q12,q13,q20,q21,q22,q23,q30,q31,q32,q33:in std_logic_vector(3 downto 0);

dout0,dout1,dout2,dout3:out STD_LOGIC_VECTOR(3 DOWNTO 0)); end;

architecture behave of select1 is

9


EDA数字秒表的设计(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:选修1

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: