
VHDL语言16进制计数器和8进制计数器 20
我想实现当8进制计数器计“000”时16进制计数器从“0000”计数到“1111”如何实现求大神谢谢!...
我想实现当8进制计数器计“000”时16进制计数器从“0000”计数到“1111”如何实现求大神谢谢!
展开
展开全部
ibrary ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity jishuqi is
port(cp,en,r,d:in std_logic;--d=1 => 加法 d=0 => 减法 en使能端,r复位端
m:in std_logic_vector(1 downto 0);--m 选择进制:00为2进制、01为8进制、10为10进制、11为16进制
t:out std_logic_vector(3 downto 0));
end jishuqi;
architecture behave of jishuqi is
signal q:std_logic_vector(3 downto 0);
begin
process(cp,en,r,d,m,q)
begin
if en='0' then
q<="0000";
else
if r='1' then
q<="0000";
else
if cp'event and cp='1' then
if d='1' then
if m="00" then
if q<"0001" then
q<=q+1;
else
q<=(others=>'0');
end if;
elsif m="01" then
if q<"0111" then
q<=q+1;
else
q<=(others=>'0');
end if;
elsif m="10" then
if q<"1001" then
q<=q+1;
else
q<=(others=>'0');
end if;
elsif m="11" then
if q<"1111" then
q<=q+1;
else
q<=(others=>'0');
end if;
end if;
else
if m="00" then
if q>"0000" then
q<=q-1;
else
q<="0001";
end if;
elsif m="01" then
if q>"0000" then
q<=q-1;
else
q<="0111";
end if;
elsif m="10" then
if q>"0000" then
q<=q-1;
else
q<="1001";
end if;
elsif m="11" then
if q>"0000" then
q<=q-1;
else
q<="1111";
end if;
end if;
end if;
end if;
end if;
end if;
end process;
t<=q;
end behave;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity jishuqi is
port(cp,en,r,d:in std_logic;--d=1 => 加法 d=0 => 减法 en使能端,r复位端
m:in std_logic_vector(1 downto 0);--m 选择进制:00为2进制、01为8进制、10为10进制、11为16进制
t:out std_logic_vector(3 downto 0));
end jishuqi;
architecture behave of jishuqi is
signal q:std_logic_vector(3 downto 0);
begin
process(cp,en,r,d,m,q)
begin
if en='0' then
q<="0000";
else
if r='1' then
q<="0000";
else
if cp'event and cp='1' then
if d='1' then
if m="00" then
if q<"0001" then
q<=q+1;
else
q<=(others=>'0');
end if;
elsif m="01" then
if q<"0111" then
q<=q+1;
else
q<=(others=>'0');
end if;
elsif m="10" then
if q<"1001" then
q<=q+1;
else
q<=(others=>'0');
end if;
elsif m="11" then
if q<"1111" then
q<=q+1;
else
q<=(others=>'0');
end if;
end if;
else
if m="00" then
if q>"0000" then
q<=q-1;
else
q<="0001";
end if;
elsif m="01" then
if q>"0000" then
q<=q-1;
else
q<="0111";
end if;
elsif m="10" then
if q>"0000" then
q<=q-1;
else
q<="1001";
end if;
elsif m="11" then
if q>"0000" then
q<=q-1;
else
q<="1111";
end if;
end if;
end if;
end if;
end if;
end if;
end process;
t<=q;
end behave;

2025-01-03 广告
RS232串行通讯的数据格式包括以下组成部分:1. 起始位:一位,用于表示数据的开始。2. 数据位:通常为8位,但也可以是7位或9位。3. 校验位:可以选择奇偶校验或无校验。4. 停止位:一位,用于表示数据的结束,也可以选择使用1.5个或2...
点击进入详情页
本回答由迪凯特科技(北京)有限公司_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询