Binome
Full Member level 3
- Joined
- Nov 16, 2009
- Messages
- 153
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 1,298
- Location
- Lyon, France
- Activity points
- 2,412
Hi,
I just want to write a simple RAM description in VHDL. Here's my code:
Data_out is turning to 0 for one clock cycle between correct values. Where is my code false?
Thank you.
I just want to write a simple RAM description in VHDL. Here's my code:
Code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity ram_mem is
generic (
data_size : integer:=12;
address_size : integer:=2
);
port(
clock : in std_logic;
enable_write : in std_logic;
address : in std_logic_vector (address_size-1 downto 0);
data_in : in std_logic_vector(data_size-1 downto 0);
data_out : out std_logic_vector(data_size-1 downto 0)
);
end ram_mem;
architecture RTL of ram_mem is
type data_ram is array (0 to 2**address_size-1) of std_logic_vector(data_size-1 downto 0);
signal signal_ram : data_ram := (others => (others => '0'));
begin
process(clock)
begin
if rising_edge(clock) then
if (enable_write = '1') then
data_out <= signal_ram(to_integer(unsigned(address)));
signal_ram(to_integer(unsigned(address))) <= data_in;
end if;
end if;
end process;
end RTL;
Thank you.