5-1,在VHDL设计中,给时序电路清0(复位)有两种不同方法,它们是什么?如何实现?
同步清零和异步清零。
同步清零是指与时钟同步,即时钟触发条件满足时检测清零信号是否有效,有效则在下一个时间周期的触发条件下,执行清零。
异步清零是清零信号有效时,无视触发脉冲,立即清零。
5-7用VHDL设计一个功能类似74LS160的计数器。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity counter is
port(
allow,reset,clk :in bit;
o:out integer range 0 to 10;
c:out bit);
end counter;
architecture behaver of counter is
begin
p1: process (clk,reset,allow)
variable ot:integer range 0 to 10:=0;
variable t:bit ;
begin
if(reset='1')then o<=0;
elsif (allow='1') then
if(clk'event and clk='1')then
ot:=ot+1;t:='0';
if(ot>9) then ot:=0;t:='1';
end if;
end if;
o<=ot;
c<=t;
end if;
end process p1;
end architecture behaver;
5-8给出含有异步清0和计数使能的16位二进制加减可控计数器的VHDL描述。
代码如下。clr为1异步清零。k为1时执行加法计数器,为0时执行减法计数器。仿真图如下:
library IEEE;use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity cnt_16 is
port (
clk: in STD_LOGIC;
k: in STD_LOGIC;
clr: in STD_LOGIC;
q: out STD_LOGIC_VECTOR (15 downto 0)
);
end cnt_16;
architecture cnt_16_arch of cnt_16 is
signal qq:std_logic_vector(15 downto 0);
begin
process(clk,clr,k)
begin
if clr='1' then
qq<="0000000000000000";
elsif clk'event and clk='1' then
if k='1' then
qq<=qq+'1';
else
qq<=qq-'1';
end if;
end if;
end process;
process(qq)
begin
q<=qq;
end process;
end cnt_16_arch
我要赚赏金打赏帖 |
|
|---|---|
| 【FreeRtos】FreeRtos + MPU模块的配置使用被打赏¥32元 | |
| 【分享开发笔记,赚取电动螺丝刀】墨水屏文本显示器被打赏¥25元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX读取磁力计iis2mdc被打赏¥19元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX读取LPS22HH气压、温度被打赏¥19元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX读取STTS751温度被打赏¥17元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX软件读取HTS221温湿度被打赏¥22元 | |
| M5PAPERESP32EINKDEVKIT评测|使用MicroPython开发M5Paper被打赏¥15元 | |
| OK1126B-S开发板下以导航按键控制云台/机械臂姿态调整被打赏¥29元 | |
| 【树莓派5】便携热成像仪被打赏¥36元 | |
| 【树莓派5】环境监测仪被打赏¥35元 | |
我要赚赏金
