i'm a newbie in vhdl, and i'm trying to write a 16 bit i/o register, but it is not working right. can someone help me solve it? I want to be able to write first then read, but it would only work if i read first and then write.
below is my code:
library ieee;
use iee.std_logic_1164.all
entity i/o_reg is
port (dataIn: in std_logic_vector (15 downto 0);
data: inout std_logic_vector (15 downto 0);
dataOut: out std_logic_vector (15 downto 0);
wr_l, rd_l: in std_logic);
end i/o_reg;
architecture model of i/o_reg is
begin
process (wr_l, rd_l) is
begin
if wr_l='0' then dataOut<=data;
elsif rd_l='0' then data<=dataIn;
end if;
end process;
end model;
below is my code:
library ieee;
use iee.std_logic_1164.all
entity i/o_reg is
port (dataIn: in std_logic_vector (15 downto 0);
data: inout std_logic_vector (15 downto 0);
dataOut: out std_logic_vector (15 downto 0);
wr_l, rd_l: in std_logic);
end i/o_reg;
architecture model of i/o_reg is
begin
process (wr_l, rd_l) is
begin
if wr_l='0' then dataOut<=data;
elsif rd_l='0' then data<=dataIn;
end if;
end process;
end model;