【发布时间】:2015-03-15 21:20:17
【问题描述】:
我在处理我的项目时遇到了 VHDL if 语句的一个奇怪问题。虽然我修复了它,但我仍然不明白它为什么会发生。我使用 ModelSPIM 刺激了我的代码。在我更改代码之前,我期望 rd <= inst (20 downto 16); 当 RegDst = '1',但它给了我 rd <= inst (15 downto 11);。我检查了RegDst 真的等于0,但它给了我错误的分配。在我更改代码后,一切都变得正常了。它们有什么区别?
之前:
fetch: process(inst)
begin
if( inst = x"0000_0000" ) then -- end of program
endRun <= '1';
else
endRun <= '0';
opcode <= inst (31 downto 26);
rs <= inst (25 downto 21);
rt <= inst (20 downto 16);
if( RegDst = '1' ) then
rd <= inst (15 downto 11);
else
rd <= inst (20 downto 16);
end if;
funct <= inst (5 downto 0);
offset <= inst (15 downto 0);
jsec <= inst (25 downto 0);
end if;
end process fetch;
之后:
fetch: process(inst)
begin
if( inst = x"0000_0000" ) then -- end of program
endRun <= '1';
else
endRun <= '0';
opcode <= inst (31 downto 26);
rs <= inst (25 downto 21);
rt <= inst (20 downto 16);
funct <= inst (5 downto 0);
offset <= inst (15 downto 0);
jsec <= inst (25 downto 0);
end if;
end process fetch;
rd <= inst (15 downto 11) when (RegDst = '1') else
inst(20 downto 16); -- RegDst mux
【问题讨论】:
标签: if-statement vhdl