Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - RAM initialization

 
Thread Tools Search this Thread
Old 05-31-2004, 10:24 PM   #1
Default RAM initialization


Hello,

I am new in VHDL and I would like to make a question.

I saw in a site a RAM code and manipulated it to make a 15 bit address an 8
bit word RAM (32k)

Is there a possible way to initialize this RAM using an external file and
how?How this file should look like?

Here is the code :

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity RAM_32K is
port (
CLK : in std_logic;
WE : in std_logic; -- write enable
EN : in std_logic;
addr : in std_logic_vector(14 downto 0);
datain : in std_logic_vector(7 downto 0);
dataout : out std_logic_vector(7 downto 0));
end RAM_32K;

architecture RAM32 of RAM_32K is
type ram_type is array(32767 downto 0) of std_logic_vector(7 downto 0);
signal ram : ram_type;
begin
process(CLK)
begin
if (CLK'event and CLK = '1') then
if (en = '1') then
if (we = '1') then
ram(conv_integer(addr)) <= datain;
dataout <= datain;
else dataout <= ram(conv_integer(addr));
end if;
end if;
end if;
end process;
end;













Mario
  Reply With Quote
Old 06-01-2004, 06:46 PM   #2
Mike Treseler
 
Posts: n/a
Default Re: RAM initialization
"Mario" <> wrote in message news:<c9g7pu$7lr$>...

> Is there a possible way to initialize this RAM using an external file


This has been covered in comp.arch.fpga:
http://groups.google.com/groups?q=fpga+initialize+ram

I have modified your code (below) as an example of
how to use the numeric_std library.

Since you asked the vhdl newsgroup,
here's my vhdl skewed take on blockram initialization:

Why might I want to init a blockram during download?
There are two possible reasons.

1. I really need a rom, and should consider using a vhdl
constant array of vectors to infer the ROM from
block RAM without worrying about vendor specific files.

2. I have a local or external controller that
will do read and write cycles to this block ram.
In this case, consider inferring the RAM from
a template and init it (if need be) using the controller.

-- Mike Treseler
--------------------------------------------------------------
> Here is the code :


-- modified to use numeric_std
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity RAM_32K is
port (
CLK : in std_logic;
WE : in std_logic; -- write enable
EN : in std_logic;
addr : in std_logic_vector(14 downto 0);
datain : in std_logic_vector(7 downto 0);
dataout : out std_logic_vector(7 downto 0));
end RAM_32K;

architecture RAM32 of RAM_32K is
type ram_type is array(32767 downto 0)
of std_logic_vector(7 downto 0);
signal ram : ram_type;
begin
process(CLK)
begin
if (CLK'event and CLK = '1') then
if (en = '1') then
if (we = '1') then
ram(to_integer(unsigned(addr))) <= datain;
dataout <= datain;
else
dataout <= ram(to_integer(unsigned(addr)));
end if;
end if;
end if;
end process;
end;


Mike Treseler
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
.net framework initialization erro Horvath3081 General Help Related Topics 1 06-22-2009 01:51 AM
Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/ emerald Software 3 05-14-2006 04:47 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46