VHDL 组件多路复用器在模型中不返回值im



我正在尝试使用带有端口映射的加法器,mux2和mux4组件制作ALU。 我已经编写了它通过编译的 ALU。问题是当我尝试在 modelsim 中给出值时,加法器工作正常,但 mux2 (sub_module( 和 mux4 (sub_module x2( 不提供输出。我替换了 2-3 倍的复用代码,问题是一样的。我只得到 outY 的 UUUUUUUU 值。 我已经最小化了代码。

模型模拟

主铝最小化

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity ALU7_minimal is
Port ( inpA : IN STD_LOGIC_VECTOR (7 downto 0) :="10110001";
inpB : IN STD_LOGIC_VECTOR (7 downto 0) :="00011001";
ALUS0 : in  STD_LOGIC := '0';
outY : out  STD_LOGIC_VECTOR (7 downto 0));
end ALU7_minimal;
architecture Behavioral  of ALU7_minimal is
component sub_module
port(x,y : in STD_LOGIC_VECTOR (7 downto 0);
s: in STD_LOGIC;
z: out STD_LOGIC_VECTOR (7 downto 0));
end component;

begin
U0: sub_module port map (inpA, inpB, ALUS0, outY );

end Behavioral ;

复用器2-1

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity sub_module is
port(x,y : in STD_LOGIC_VECTOR (7 downto 0);
s: in STD_LOGIC;
z: out STD_LOGIC_VECTOR (7 downto 0));
end sub_module ;
architecture Behavioral of sub_module is
begin
process (x,y,s) is
begin
if (s ='0') then
z <= x;
else
z <= y;
end if;
end process;
end Behavioral;

不需要进程!

begin
with s select
z <= x  when '0',
y  when '1',
'U' when others;

仅供遇到相同问题的其他人将来参考(我的老师发现它(: 在运行仿真之前,您需要将所有组件文件导入到模型中。悖论的是,即使我没有导入 1bit 和 8bit 的加法器也在工作,但 mux(2-1/4-1( 不会给出任何结果。当我导入所有组件文件(而不仅仅是主程序(时,ModelSim 会正确显示结果。 感谢您的时间和帮助伙计们,真的很感激。

最新更新