用VHDL代码编写一个选择器,具体用途就不说了,不过波形仿真的时候出现状况 代码如下 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity muxrs is port( sel:in std_logic_vector(1 downto 0); rd,wr:in std_logic; ldrut std_logic_vector(3 downto 0); Rbusut std_logic_vector(3 downto 0) ); end muxrs; architecture rtl of muxrs is begin process(sel) begin if(rd='1'and wr='0') then case sel is when "00"=>ldr<="0000";Rbus<="1110"; when "01"=>ldr<="0000";Rbus<="1101"; when "10"=>ldr<="0000";Rbus<="1011"; when "11"=>ldr<="0000";Rbus<="0111"; when others=>Rbus<="1111";ldr<="0000"; end case; elsif (rd='0' and wr='1') then case sel is when "00"=>ldr<="0001";Rbus<="1111"; when "01"=>ldr<="0010";Rbus<="1111"; when "10"=>ldr<="0100";Rbus<="1111"; when "11"=>ldr<="1000";Rbus<="1111"; when others=>ldr<="0000";Rbus<="1111"; end case; else ldr<="0000";Rbus<="1111"; end if; end process; end rtl; 波形仿真如下 是不是WHEN OTHERS不包括条件为高阻态的情况?但如果是这样那么RBUS输出也应该受影响啊。为什么只有 LDR出现这样奇怪的现象? [em06] |