VHDL错误(10818):无法推断寄存器

时间:2015-11-25 02:34:42

标签: mips vhdl

所以我是VHDL的初学者,我正在尝试为FPGA编写MIPS处理器。 CPU寄存器的文件未编译。它正在生成错误代码,如下面的Error (10818): Can't infer register for "Reg[0][2]" at cpu_register.vhd(32) because it does not hold its value outside the clock edge

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity cpu_register is
Port ( Source_Register_Address : in std_logic_vector(4 downto 0);
 Target_Register_Address : in std_logic_vector(4 downto 0);
 Destination_Register_Address : in std_logic_vector(4 downto 0);
 Cyclic_Target_Register_Address : in std_logic_vector(4 downto 0);
 Program_Counter : in std_logic_vector(31 downto 0);
 Load_Data : in std_logic_vector(31 downto 0);
 Execution_Result : in std_logic_vector(31 downto 0);
 Operation_Code : in std_logic_vector(5 downto 0);
 Source_Register_Data : out std_logic_vector(31 downto 0);
 Target_Register_Data : out std_logic_vector(31 downto 0);
 Clock : in std_logic);
end cpu_register;
architecture behavioral of cpu_register is
type Register_Array is array (0 to 31) of std_logic_vector(31 downto 0);
signal Reg: Register_Array;
begin
t1:process
(Operation_Code,Source_Register_Address,Target_Register_Address,Clock)
begin
Reg(0) <= "00000000000000000000000000000000";
Source_Register_Data <= Reg(CONV_INTEGER(Source_Register_Address));
Target_Register_Data <= Reg(CONV_INTEGER(Target_Register_Address));
end process;
t2: process (Clock)
begin
Reg(0) <= "00000000000000000000000000000000";
if (Clock'event and Clock='0') then
case Operation_Code is
when "000000" =>
if (Destination_Register_Address="00000") then
Reg(0) <= "00000000000000000000000000000000";
else
Reg(CONV_INTEGER(Destination_Register_Address)) <=
Execution_Result;
end if;
when "001000" | "001001" | "001100" | "001101" | "001110" | "001111" |
"001010" | "001011" =>
if (Cyclic_Target_Register_Address="00000") then
Reg(0) <= "00000000000000000000000000000000";
else
Reg(CONV_INTEGER(Cyclic_Target_Register_Address)) <= Execution_Result;
end if;
when "100011" =>
if (Cyclic_Target_Register_Address="00000") then
Reg(0) <= "00000000000000000000000000000000";
else
Reg(CONV_INTEGER(Cyclic_Target_Register_Address)) <= Load_Data;
end if;
when "000011" =>
Reg(31) <= Program_Counter;
when others =>
Reg(0) <= "00000000000000000000000000000000";
end case;
end if;
end process;
end behavioral;

任何有关如何修复它的帮助将非常感激。感谢

1 个答案:

答案 0 :(得分:1)

注释if语句之外的两个Reg(0)赋值由clock&#39;事件和clock =&#39; 0&#39;。

决定。

t1中的分配看起来是无意的,可能会在模拟过程中导致“X”。您希望您的综合软件也可能会抱怨。

t1:process
(Operation_Code,Source_Register_Address,Target_Register_Address,Clock)
begin
-- Reg(0) <= "00000000000000000000000000000000";
Source_Register_Data <= Reg(CONV_INTEGER(Source_Register_Address));
Target_Register_Data <= Reg(CONV_INTEGER(Target_Register_Address));
end process;
t2: 
    process (Clock)
    begin
        -- Reg(0) <= "00000000000000000000000000000000";
        if Clock'event and Clock ='0' then
            case Operation_Code is
            when "000000" =>
                if (Destination_Register_Address="00000") then
                    Reg(0) <= "00000000000000000000000000000000";
                else
                    Reg(CONV_INTEGER(Destination_Register_Address)) <=
                            Execution_Result;
                end if;
            when "001000" | "001001" | "001100" | 
                 "001101" | "001110" | "001111" |
                 "001010" | "001011" =>
                if (Cyclic_Target_Register_Address="00000") then
                    Reg(0) <= "00000000000000000000000000000000";
                else
                    Reg(CONV_INTEGER(Cyclic_Target_Register_Address)) <= 
                             Execution_Result;
                end if;
            when "100011" =>
                if (Cyclic_Target_Register_Address="00000") then
                    Reg(0) <= "00000000000000000000000000000000";
                else
                    Reg(CONV_INTEGER(Cyclic_Target_Register_Address)) <= 
                            Load_Data;
                end if;
            when "000011" =>
                Reg(31) <= Program_Counter;
            when others =>
                Reg(0) <= "00000000000000000000000000000000";
            end case;
        end if;
    end process;

在t2中注释掉的那个导致你的错误。

相关问题