SivabalanBalasundram
Newbie level 4
vhdl initialize ram zero others
Hi..I need some guideance on writing VHDL code for a RAM..Currently i have wrote a VHDL code for a RAM Which the initial value of all the adrees are '0' when Read operation occurs...I want to create a Ram which i can intialiaze the values in the addresses according to my usage..Can someone help me with this? Here i past my VHDL code for my RAM(Initial vaues are zero)..Can someone show me how to write the code to initialize a RAM???Thank u!!!
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY ram IS
GENERIC
( ADDRESS_WIDTH : integer := 4;
DATA_WIDTH : integer := 8);
PORT( clock : IN std_logic;
data : IN std_logic_vector(DATA_WIDTH - 1 DOWNTO 0);
write_address : IN std_logic_vector(ADDRESS_WIDTH - 1 DOWNTO 0);
read_address : IN std_logic_vector(ADDRESS_WIDTH - 1 DOWNTO 0);
we : IN std_logic;
q : OUT std_logic_vector(DATA_WIDTH - 1 DOWNTO 0));
END ram;
ARCHITECTURE rtl OF ram IS
TYPE RAM IS ARRAY(0 TO 2 ** ADDRESS_WIDTH - 1) OF std_logic_vector(DATA_WIDTH - 1 DOWNTO 0);
SIGNAL ram_block : RAM;
BEGIN
PROCESS (clock)
BEGIN
IF (clock'event AND clock = '1') THEN
IF (we = '1') THEN
ram_block(to_integer(unsigned(write_address))) <= data;
END IF;
q <= ram_block(to_integer(unsigned(read_address)));
END IF;
END PROCESS;
END rtl;
Hi..I need some guideance on writing VHDL code for a RAM..Currently i have wrote a VHDL code for a RAM Which the initial value of all the adrees are '0' when Read operation occurs...I want to create a Ram which i can intialiaze the values in the addresses according to my usage..Can someone help me with this? Here i past my VHDL code for my RAM(Initial vaues are zero)..Can someone show me how to write the code to initialize a RAM???Thank u!!!
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY ram IS
GENERIC
( ADDRESS_WIDTH : integer := 4;
DATA_WIDTH : integer := 8);
PORT( clock : IN std_logic;
data : IN std_logic_vector(DATA_WIDTH - 1 DOWNTO 0);
write_address : IN std_logic_vector(ADDRESS_WIDTH - 1 DOWNTO 0);
read_address : IN std_logic_vector(ADDRESS_WIDTH - 1 DOWNTO 0);
we : IN std_logic;
q : OUT std_logic_vector(DATA_WIDTH - 1 DOWNTO 0));
END ram;
ARCHITECTURE rtl OF ram IS
TYPE RAM IS ARRAY(0 TO 2 ** ADDRESS_WIDTH - 1) OF std_logic_vector(DATA_WIDTH - 1 DOWNTO 0);
SIGNAL ram_block : RAM;
BEGIN
PROCESS (clock)
BEGIN
IF (clock'event AND clock = '1') THEN
IF (we = '1') THEN
ram_block(to_integer(unsigned(write_address))) <= data;
END IF;
q <= ram_block(to_integer(unsigned(read_address)));
END IF;
END PROCESS;
END rtl;