VHDL设计一个带异步清零、同步置位功能的1位十进制同步可逆(加/减)计数器 255
在本实验中,要设计一个带异步清零、同步置位功能的1位十进制同步可逆(加/减)计数器,如下图6.1所示:上图中,RESET为复位控制端;LD为预置数控制端,DIN[3..0...
在本实验中,要设计一个带异步清零、同步置位功能的1位十进制同步可逆(加/减)计数器,如下图6.1所示:上图中,RESET为复位控制端;LD为预置数控制端,DIN[3..0]为计数器的预置值;UPDN为加减控制信号:当UPDN为高电平时,加法计数;当UPDN为低电平时,减法计数。CLK为计数脉冲输入端,CABO 为进位/借位输出端,Q[3..0]为计数结果输出端。计数器的逻辑功能如下表6.1所示:
展开
1个回答
2018-10-22 · 知道合伙人互联网行家
关注
展开全部
我写了一个,k是控制置数的,en是计数使能,clr是清零,下面附上了我的仿真波形图。
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;
entity cnt_16 is
port (
clk: in STD_LOGIC;
qin: in STD_LOGIC_VECTOR (15 downto 0);
clr:in std_logic;
k: in std_logic;
en: in STD_LOGIC;
qout: out STD_LOGIC_VECTOR (15 downto 0);
q: out STD_LOGIC
);
end cnt_16;
architecture cnt_16_arch of cnt_16 is
signal qqout:std_logic_vector(15 downto 0);
signal qq:std_logic;
begin
process(k,qin,en,clk,clr)
begin
if k='1' then
qqout<=qin;
else
if clk'event and clk='1' then
if clr='1' then
qqout<="0000000000000000";
elsif en='1' then
if qqout="1111111111111111" then
qq<='1' ;
qqout<="0000000000000000";
else
qqout<=qqout '1';
end if;
end if;
end if;
end if;
end process;
suocun: process(qqout,qq)
begin
q<=qq;
qout<=qqout;
end process suocun;
end cnt_16_arch;
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;
entity cnt_16 is
port (
clk: in STD_LOGIC;
qin: in STD_LOGIC_VECTOR (15 downto 0);
clr:in std_logic;
k: in std_logic;
en: in STD_LOGIC;
qout: out STD_LOGIC_VECTOR (15 downto 0);
q: out STD_LOGIC
);
end cnt_16;
architecture cnt_16_arch of cnt_16 is
signal qqout:std_logic_vector(15 downto 0);
signal qq:std_logic;
begin
process(k,qin,en,clk,clr)
begin
if k='1' then
qqout<=qin;
else
if clk'event and clk='1' then
if clr='1' then
qqout<="0000000000000000";
elsif en='1' then
if qqout="1111111111111111" then
qq<='1' ;
qqout<="0000000000000000";
else
qqout<=qqout '1';
end if;
end if;
end if;
end if;
end process;
suocun: process(qqout,qq)
begin
q<=qq;
qout<=qqout;
end process suocun;
end cnt_16_arch;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询