HI,
That is not the way to write Register Files. You could check the code
below . It has synchronous write and asynchornous read.
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
entity Regfile is
generic( DATA_WIDTH : natural := 32;
ADDRS_WIDTH : natural := 4
);
port(
Data_In : in signed(DATA_WIDTH-1 downto 0); -- Input Data
Addrs_In : in unsigned(ADDRS_WIDTH-1 downto 0); -- Input
Address
Addrs1_Out : in unsigned(ADDRS_WIDTH-1 downto 0); -- Output
Address 1
Addrs2_Out : in unsigned(ADDRS_WIDTH-1 downto 0); -- Output Address
2
Wr_En : in std_logic; -- Write Enable
Clk : in std_logic; -- Global Clk
Data1_Out : out signed(DATA_WIDTH-1 downto 0); -- Output Data 1
Data2_Out : out signed(DATA_WIDTH-1 downto 0) -- Output Data 2
);
end entity Regfile;
architecture Regfile_Arch of Regfile is
-- Declarations of Register File type & signal
type Regfile_type is array (natural range<>) of signed(DATA_WIDTH-1
downto 0);
signal Regfile_Coff : Regfile_type(0 to ADDRS_WIDTH-1);
begin
--------------------------------------------------------
-- Concurrent Statements
-- Regfile_Read Assignments
Data1_Out <= Regfile_Coff(TO_INTEGER(Addrs1_Out));
Data2_Out <= Regfile_Coff(TO_INTEGER(addrs2_Out));
--------------------------------------------------------
-- Sequential Process
-- Register File Write Process
Regfile_Write

rocess(Clk)
begin
if(RISING_EDGE(Clk))then
if(Wr_En = '1')then
Regfile_Coff(TO_INTEGER(Addrs_In)) <= Data_In;
end if;
end if;
end process Regfile_Write;
--------------------------------------------------------
end architecture Regfile_Arch;