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
我要赚赏金打赏帖 |
|
|---|---|
| 基于MCP23S17的输入输出功能模块控制被打赏¥20元 | |
| 【S32K3XX】SPD 软件包使用Link文件修改被打赏¥22元 | |
| Switch-Case局部变量定义问题被打赏¥23元 | |
| 基于米尔TIAM62L开发板的串口通信及应用被打赏¥20元 | |
| PCF8574功能模块及其使用被打赏¥20元 | |
| 传感器LSM6DSO及LIS3MDL的功能检测被打赏¥18元 | |
| LPS25HB气压传感器及其检测被打赏¥18元 | |
| HTS221温湿度传感器及其检测被打赏¥18元 | |
| 【S32K3XX】HSE FW 版本更新被打赏¥21元 | |
| 基于ArduinoUNO开发板的AT24C02读写测试被打赏¥16元 | |
我要赚赏金
