library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity counter is
port(rst,clk,clk1: in std_logic;
con : std_logic_vector(1 downto 0);
output : out std_logic_vector(7 downto 0));
end entity counter;
architecture behave of counter is
begin
process(rst,con,clk,clk1)
variable temp1 : std_logic_vector(7 downto 0);
begin
if rst = '1' then temp1 := (others => '0');
else
case con is
when "10" =>--手动顺记数
if clk'event and (clk='1') and (clk'last_value='0') then
if temp1 < 255 then temp1 := temp1 + 1;
else temp1 := (others => '0');
end if;
end if;
when "11" =>--手动逆记数
if clk'event and (clk='1') and (clk'last_value='0') then
if temp1 > 0 then temp1 := temp1 - 1;
else temp1 := (others => '1');
end if;
end if;
when "00" =>--连续顺记数
if clk1'event and (clk1='1') and (clk1'last_value='0') then --------------这个比较重要
if temp1 < 255 then temp1 := temp1 + 1;
else temp1 := (others => '0');
end if;
end if;
when "01" =>--连续逆记数
if clk1'event and (clk1='1') and (clk1'last_value='0') then
if temp1 > 0 then temp1 := temp1 - 1;
else temp1 := (others => '1');
end if;
end if;
end case;
end if;
output <= temp1;
end process;
end architecture behave;
jishuqi.zip_脉冲计数vhdl
版权申诉
81 浏览量
2022-09-21
08:48:11
上传
评论
收藏 624B ZIP 举报
寒泊
- 粉丝: 75
- 资源: 1万+
最新资源
- WS2-32.lib,在编译程序中可以链接使用
- 秒懂傅里叶变换matlab程序实现过程
- ZEND解密dezender12
- sony 索尼IMX334摄像头模组电路板AD版硬件PCB图(6层板).zip
- 基于flask和echarts融合交易策略的bitfinex可视化微服务.zip
- 包含了wvp-assist.tar wvp-talk.tar zlmediakit.tar .
- 3r4efgh53wgrf43tw
- 2024新版Java基础从入门到精通全套视频+资料下载
- Spring AI大模型视频教程+ChatGPT视频教程+OpenAI大模型视频教程(资料+视频教程)
- ABB工业机器人教程PDF版本
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈