VHDL 将 10 位程序计数器加 1

VHDL Increment 10-bit Program Counter by 1

我正在尝试使用 VHDL 中经过修改的 MIPS 指令集制作 32 位 CPU。我目前正在尝试让我的程序计数器为下一条指令增加 1,除非它是一条跳转指令,然后程序计数器将等于跳转值。

entity PC is
Port ( PC_IN     : in STD_LOGIC_VECTOR (9 downto 0); --New PC in value (PC+1 or jump)
       PC_OUT    : out STD_LOGIC_VECTOR (9 downto 0); --PC out to instruction memory
       Jump_Inst : in STD_LOGIC_VECTOR(9 downto 0); --Jump address
       Jump      : in STD_LOGIC; --Jump MUX
       clk       : in STD_LOGIC);
end PC;

architecture Behavioral of PC is
begin

PC_IN <= (PC_IN + "0000000001") when (Jump = '0')
else Jump_Inst;     

process(clk)
begin
   if rising_edge(clk) then --If it is the next clock cycle (i.e time for the next instruction)
   PC_OUT <= PC_IN;

end if;
end process;     
end Behavioral;

我在这一行遇到错误 PC_IN <= (PC_IN + "0000000001") when (Jump = '0')。错误包括 cannot update 'in' object pc_in0 definitions of operator "+" match here,所以它不喜欢我使用 + 运算符,也许 pc_in 需要作为输出?

有谁知道如何让我的程序计数器为下一条指令递增 1?任何帮助,将不胜感激。谢谢。

PC_IN 定义为 std_logic_vector。您没有显示正在使用的库,但默认情况下,std_logic_1164 中的 std_logic_vector+ 没有定义的运算符。请注意您的错误消息:

0 definitions of operator "+" match here

这是你的意思,+ 没有在此上下文中定义。为了使用 + 运算符,您需要包含一个支持该运算符的库并使用适当的类型。

你的其他错误:

cannot update 'in' object pc_in

告诉您不能设置 in 端口。值得注意的是,PC_IN 是一个输入,但您正在尝试驱动 PC_IN。也许你的意思是开车 PC_OUT?

我不会提及替代方法,但在这种情况下您可能应该使用 numeric_std。例如:

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

...

PC_OUT <= std_logic_vector(unsigned(PC_IN) + 1) when (Jump = '0') else Jump_Inst;