
怎样用VHDL设计含有异步清零和同步时钟使能的10位加法计数器
1个回答
展开全部
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity add is
port(clr,en,clkin:in std_logic; ---------清零,使能及触发时钟
a,b:in std_logic_vector(9 downto 0);---------加数
c:out std_logic_vector(9 downto 0);----------和
ci:out std_logic ---------进位
);
end add;
architecture arch of add is
---------;
signal reg:std_logic_vector(10 downto 0):="00000000000";
----------------------------------------------------------------------------
begin
----------------
process(clr,clkin,en,a,b)
begin
if(clr='0') then --------------异步清零
reg<="00000000000";
elsif(clkin'event and clkin='1') then
if(en='1')then -------------同步使能
reg<=('0'&a)+('0'&b); ---------求和
end if;
end if;
end process;
---------------
c<=reg(9 downto 0); ----------赋值给和
ci<=reg(10); ----------赋值给进位
---------------------------------------------------------------------
end arch;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity add is
port(clr,en,clkin:in std_logic; ---------清零,使能及触发时钟
a,b:in std_logic_vector(9 downto 0);---------加数
c:out std_logic_vector(9 downto 0);----------和
ci:out std_logic ---------进位
);
end add;
architecture arch of add is
---------;
signal reg:std_logic_vector(10 downto 0):="00000000000";
----------------------------------------------------------------------------
begin
----------------
process(clr,clkin,en,a,b)
begin
if(clr='0') then --------------异步清零
reg<="00000000000";
elsif(clkin'event and clkin='1') then
if(en='1')then -------------同步使能
reg<=('0'&a)+('0'&b); ---------求和
end if;
end if;
end process;
---------------
c<=reg(9 downto 0); ----------赋值给和
ci<=reg(10); ----------赋值给进位
---------------------------------------------------------------------
end arch;

2022-05-15 广告
光电编码器,是一种通过光电转换将输出轴上的机械几何位移量转换成脉冲或数字量的传感器。光电编码器每转输出60(我们用老板没有说)个脉冲,五线制。其中两根为电源线,三根为脉冲线(A相、B相、Z)。电源的工作电压为 (+5~+24V)直流电源。光...
点击进入详情页
本回答由上海巴鲁图工程机械科技有限公司_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询