I've tried to use processes , but still nothing (I'm pretty sure something is still wrong , as I said I'm new to VHDL). Here is my code :
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity ALU is
Port (
RdData1 : in STD_LOGIC_VECTOR (31 downto 0);
RdData2 : in STD_LOGIC_VECTOR (31 downto 0);
FAddr : in STD_LOGIC_VECTOR (15 downto 0);
ALUSrc : in STD_LOGIC;
ALUOP : in STD_LOGIC_VECTOR (2 downto 0);
Sa : in STD_LOGIC_VECTOR (4 downto 0);
Y : out STD_LOGIC_VECTOR (31 downto 0)
);
end ALU;
architecture Behavioral of ALU is
signal SEAddr : STD_LOGIC_VECTOR(31 downto 0);
signal OP1 : STD_LOGIC_VECTOR(31 downto 0);
signal OP2 : STD_LOGIC_VECTOR(31 downto 0);
signal OP3 : STD_LOGIC_VECTOR(31 downto 0);
signal S_nat : natural;
begin
OP2 <= RdData2 when AluSrc='0' else SEAddr;
SEAddr(15 downto 0) <= FAddr;
SEAddr(31 downto 16) <= x"0000" when FAddr(15)='0' else x"FFFF";
OP1 <= RdData1;
process (RdData2)
begin
OP3 <= RdData2;
end process;
with Sa select
S_nat <= 0 when "00000",1 when "00001",2 when "00010",3 when "00011",4 when "00100",5 when "00101",
6 when "00110",7 when "00111",8 when "01000",9 when "01001",10 when "01010",11 when "01011",
12 when "01100",13 when "01101",14 when "01110",15 when "01111",16 when "10000",17 when "10001",
18 when "10010",19 when "10011",20 when "10100",21 when "10101",22 when "10110",23 when "10111",
24 when "11000",25 when "11001",26 when "11010",27 when "11011",28 when "11100",29 when "11101",
30 when "11110",31 when others;
process (S_nat)
begin
OP3(S_nat) <= '1';
end process;
with ALUOP select
y <= OP1 + OP2 when "000", OP1 - OP2 when "001", OP1 AND OP2 when "010", OP1 OR OP2 when "011", OP3 when others;
end Behavioral;
What I want is that OP3 to be exactly as RdData2 (and if I just do OP3 <= RdData2 ,it is) but also that 1 bit which is determined by Sa to become 1.
For example , RdData 2 is 5555 5555 , and if I do only Op3 <= RdData2 then OP3 becomes 5555 5555 , but if i also do OP3(S_nat) <= '1' , then the result is XXXX XXX (to be more precise is xxxx xxxx xxxx xxxx xxxx xx1x xxxx xxx1 , so that 1 specific bit (10 in this case) becomes 1 , but the others are X-es).
Any help would be highly appreciated , I'm working on this problem for several days and it still bugs me
.