VHDL中IF和CASE嵌套的问题
libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;--Uncommentthefollowinglibrarydeclarationifusi...
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity testing is
port
(
date:inoutSTD_LOGIC_VECTOR( 7 downto 0 );
ctr:inSTD_LOGIC_VECTOR( 1 downto 0 );
dout:outSTD_LOGIC_VECTOR( 7 downto 0 );
a:inSTD_LOGIC
);
end testing;
architecture Behavioral of testing is
begin
process(date,ctr)
begin
-- if( a = '1' ) then
--date<="10101010";
--else
case ctr is
when"00"=>
dout<=date;
when"01"=>
dout<="00000000";
when"10"=>
dout<="11111111";
whenothers=>
dout<="01010101";
end case;
--end if;
end process;
end Behavioral;
这是我自己写的一个简单的测试程序 我本来是只写了case语句,在ctr输入不同时dout输出不同值,后来因为需要把date改为双向,当a为1时输出一个固定值,在a为0时才按照case语句执行,但是在没加入case语句时,程序能按照预订的进行,加入if语句后,综合也能通过,但是生产的RTL电路中,date全部都接地了,不明白为什么,本人没有系统的学过VHDL,只是最近项目需要看了一点,球各路大神指教一下是哪里的问题,拜谢拜谢 展开
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity testing is
port
(
date:inoutSTD_LOGIC_VECTOR( 7 downto 0 );
ctr:inSTD_LOGIC_VECTOR( 1 downto 0 );
dout:outSTD_LOGIC_VECTOR( 7 downto 0 );
a:inSTD_LOGIC
);
end testing;
architecture Behavioral of testing is
begin
process(date,ctr)
begin
-- if( a = '1' ) then
--date<="10101010";
--else
case ctr is
when"00"=>
dout<=date;
when"01"=>
dout<="00000000";
when"10"=>
dout<="11111111";
whenothers=>
dout<="01010101";
end case;
--end if;
end process;
end Behavioral;
这是我自己写的一个简单的测试程序 我本来是只写了case语句,在ctr输入不同时dout输出不同值,后来因为需要把date改为双向,当a为1时输出一个固定值,在a为0时才按照case语句执行,但是在没加入case语句时,程序能按照预订的进行,加入if语句后,综合也能通过,但是生产的RTL电路中,date全部都接地了,不明白为什么,本人没有系统的学过VHDL,只是最近项目需要看了一点,球各路大神指教一下是哪里的问题,拜谢拜谢 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
展开全部
将进程改一下:
process(date,ctr)
begin
if( a = '1' ) then
date<="10101010";
else
date <= (others => 'Z');
end if;
case ctr is
when"00" => dout <= date;
when"01" => dout <= "00000000";
when"10" => dout <= "11111111";
when others => dout <= "01010101";
end case;
end process;
process(date,ctr)
begin
if( a = '1' ) then
date<="10101010";
else
date <= (others => 'Z');
end if;
case ctr is
when"00" => dout <= date;
when"01" => dout <= "00000000";
when"10" => dout <= "11111111";
when others => dout <= "01010101";
end case;
end process;
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询