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

Reply

VHDL - inferred ram with initial values

 
Thread Tools Search this Thread
Old 04-02-2007, 10:57 AM   #1
Default inferred ram with initial values


Hi everyone,

I use to instantiate all my ram with a own template, but now I would
like the ram to have an initial value (in fact it was first a ROM
declaration but now I want to be able to rewrite the memory) In my rom
description the memory was declared as a constant array of std_logic:

type bloc_memory is array (2**size_adress-1 downto 0) of
std_logic_vector(size_word-1 downto 0) ;

constant bloc_ram : bloc_memory := (others => (others =>'0'));

But to be able to make it rewritable i change the constant to signal , I
think in simulation it will work but do you think it will really
instantiate a ram with an initialized memory?
I don't like to give a value at the declaration of a signal but i see no
other ways to achieve to do my ram. Is there any other way or does these
one is good?


Alexis






Here is the template of my ram :

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;

ENTITY RAM_dual_port IS
Generic(
constant size_adress : natural := 12;
constant size_word : natural := 31

);
PORT (
clk_in : in std_logic;
we_in : in std_logic;
adress_in : in std_logic_vector(size_adress-1 downto 0);
data_in : in std_logic_vector(size_word-1 downto 0);
clk_out : in std_logic;
adress_out : in std_logic_vector(size_adress-1 downto 0);
data_out : out std_logic_vector(size_word-1 downto 0)
);
END RAM_dual_port;

architecture behavorial of RAM_dual_port is

type bloc_memory is array (2**size_adress-1 downto 0) of
std_logic_vector(size_word-1 downto 0) ;

signal bloc_ram : bloc_memory := (others => (others =>'0'));

begin

ecriture : process(clk_in)
begin
if rising_edge(clk_in) then
if we_in = '1' then
bloc_ram(to_integer(unsigned(adress_in))) <= data_in;
end if;
end if;
end process ecriture;


lecture : process(clk_out)
begin
if rising_edge(clk_out) then
data_out <= bloc_ram(to_integer(unsigned(adress_out)));
end if;
end process lecture;

end;


Alexis GABIN
  Reply With Quote
Old 04-02-2007, 01:14 PM   #2
Mike Treseler
 
Posts: n/a
Default Re: inferred ram with initial values
Alexis GABIN wrote:

> I use to instantiate all my ram with a template,


That's how I do it.

> but now I would
> like the ram to have an initial value (in fact it was first a ROM
> declaration but now I want to be able to rewrite the memory)


The only vendor-independent way to do this
is with separate ROM and RAM inferences.
See my ROM example here:

http://home.comcast.net/~mike_treseler/

> But to be able to make it rewritable i change the constant to signal , I
> think in simulation it will work but do you think it will really
> instantiate a ram with an initialized memory?


No.
RAM is writable by preforming a write cycle.
RAM can only be initialized in a vendor-dependent way.
ROM is not writable.

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 04-02-2007, 01:51 PM   #3
Andy
 
Posts: n/a
Default Re: inferred ram with initial values
Initializing inferred ram is a synthesis-tool-specific exercise.
Synplicity allows it, but I don't remember whether it is via
attributes or the signal/variable initializer.

Check your synthesis documentation.

Andy

On Apr 2, 4:57 am, Alexis GABIN <alexis.gabin@_NOSPAM_sptech.com.tw>
wrote:
> Hi everyone,
>
> I use to instantiate all my ram with a own template, but now I would
> like the ram to have an initial value (in fact it was first a ROM
> declaration but now I want to be able to rewrite the memory) In my rom
> description the memory was declared as a constant array of std_logic:
>
> type bloc_memory is array (2**size_adress-1 downto 0) of
> std_logic_vector(size_word-1 downto 0) ;
>
> constant bloc_ram : bloc_memory := (others => (others =>'0'));
>
> But to be able to make it rewritable i change the constant to signal , I
> think in simulation it will work but do you think it will really
> instantiate a ram with an initialized memory?
> I don't like to give a value at the declaration of a signal but i see no
> other ways to achieve to do my ram. Is there any other way or does these
> one is good?
>
> Alexis
>
> Here is the template of my ram :
>
> LIBRARY ieee;
> USE ieee.std_logic_1164.ALL;
> USE ieee.numeric_std.ALL;
>
> ENTITY RAM_dual_port IS
> Generic(
> constant size_adress : natural := 12;
> constant size_word : natural := 31
>
> );
> PORT (
> clk_in : in std_logic;
> we_in : in std_logic;
> adress_in : in std_logic_vector(size_adress-1 downto 0);
> data_in : in std_logic_vector(size_word-1 downto 0);
> clk_out : in std_logic;
> adress_out : in std_logic_vector(size_adress-1 downto 0);
> data_out : out std_logic_vector(size_word-1 downto 0)
> );
> END RAM_dual_port;
>
> architecture behavorial of RAM_dual_port is
>
> type bloc_memory is array (2**size_adress-1 downto 0) of
> std_logic_vector(size_word-1 downto 0) ;
>
> signal bloc_ram : bloc_memory := (others => (others =>'0'));
>
> begin
>
> ecriture : process(clk_in)
> begin
> if rising_edge(clk_in) then
> if we_in = '1' then
> bloc_ram(to_integer(unsigned(adress_in))) <= data_in;
> end if;
> end if;
> end process ecriture;
>
> lecture : process(clk_out)
> begin
> if rising_edge(clk_out) then
> data_out <= bloc_ram(to_integer(unsigned(adress_out)));
> end if;
> end process lecture;
>
> end;





Andy
  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
Values set by javascript are not reflected in serverside(.Net) rchimakurty Software 2 11-28-2007 10:07 AM
Checkbox values problem in gridview thanigaimani.thirumalai Software 0 11-09-2007 05:12 AM
Cisco QOS MIB values required manjunatht Software 0 09-11-2007 05:40 PM
How to make the form View save it's field values in Visual Stdio .NET asammoud Software 0 07-17-2007 10:57 AM
Is the Initial IDM-1731 the same DVD player that's "branded" by other manufacturers? C. Osbourne DVD Video 2 10-18-2004 09:44 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