VHDL中32位ALU的实现

Implementation of 32 bit ALU in VHDL

我正在用 VHDL 实现 32 位 ALU。我发现了一个错误。我不明白为什么我得到这个.. 这是 无法更新 'in' 对象 out_alu

 library IEEE;
 use IEEE.STD_LOGIC_1164.ALL;
 ----==== Entity of AlU with input and Output 
 entity AlU is  Port (
   A : in  STD_LOGIC_VECTOR (31 downto 0);       ---== A input   Vector with 32 Bit 
   B : in  STD_LOGIC_VECTOR (31 downto 0);       ---== B input   Vector with 32 Bit 
   S : in  STD_LOGIC_VECTOR (2 downto 0) ;       ---== S select  Input Vector 3 bit for operation  
   out_AlU : in  STD_LOGIC_VECTOR (31 downto 0));---== Output of AlU 32 
 end AlU;

 architecture Behavioral of AlU is
 begin

 Select_for_operation: Process (S)   ---= Deffierent  Process for AlU with the     selection of S
                  begin
                                Case S is  
                                when     "000" =>  
                                          out_AlU <=A xor  B ;
                                when   "001"=> 
                                          out_AlU <=A Xnor B ;
                                when   "100"=> 
                                          out_AlU <=A  or  B ; 
                                when   "101"=> 
                                         out_AlU  <=A  nor B ;
                                when   "110"=> 
                                         out_AlU  <=A  and B ;
                                when    others => 
                                                    NULL ;      
                                end case ;
                        end Process ;
 end Behavioral;

您的信号 out_ALU 被声明为您实体的输入。这就是为什么你不能给它分配信号(可以说它是只读的)。

将其更改为 out,它可能会编译:

 entity AlU is  Port (
   A : in  STD_LOGIC_VECTOR (31 downto 0);       ---== A input   Vector with 32 Bit 
   B : in  STD_LOGIC_VECTOR (31 downto 0);       ---== B input   Vector with 32 Bit 
   S : in  STD_LOGIC_VECTOR (2 downto 0) ;       ---== S select  Input Vector 3 bit for operation  
   out_AlU : out  STD_LOGIC_VECTOR (31 downto 0));---== Output of AlU 32 
 end AlU;