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

Reply

VHDL - Index Array (Yet Another Question)

 
Thread Tools Search this Thread
Old 11-26-2008, 03:43 PM   #1
Default Index Array (Yet Another Question)


Hi,

I found several questions posted about array indexing but I am still
confused on how can I solve my problem.
I have a memory array that I want to index with a hot-one address.

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

entity memory is
generic( addr_width : integer := 5;
data_width : integer := 4);
port(
Q : out std_logic_vector(data_width - 1 downto 0 );
R_ADR : in std_logic_vector(2**addr_width - 1 downto 0);
W_ADR : in std_logic_vector(2**addr_width - 1 downto 0);
D : in std_logic_vector(data_width - 1 downto 0 );
W : in std_logic;
R : in std_logic;
ME : in std_logic;
CLK : in std_logic
);
end memory;


architecture synth_mem of memory is
type mem_array is array (std_ulogic range <>) of std_logic_vector
(data_width - 1 downto 0 );
signal ram : mem_array(2**addr_width - 1 downto 0);

-- function hot_to_int(hot: std_logic_vector(2**addr_width - 1
downto 0)) return integer is
-- variable conv : integer := 0;
-- begin
-- for i in 0 to 2**addr_width - 1 loop
-- if hot(i) = '1' then
-- conv := i;
-- end if;
-- end loop;
-- return conv;
-- end hot_to_int;

begin
-- process (ME, CLK)
-- begin
-- if ME = '1' then
-- Q <= (others => '1');
-- elsif CLK'event and CLK = '1' then
-- if R = '1' then
-- Q <= ram(R_ADR);
-- else
-- Q <= (others => '1');
-- end if;
---- if W = '1' then
---- ram(W_ADR) <= D;
---- end if;
-- end if;
-- end process;

ram(W_ADR) <= D when (W = '1' and CLK = '0');
Q <= ram(R_ADR) when (R = '1' and CLK = '0');

end synth_mem;


Filipa
  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
synthesis error sekhar_kollati Hardware 0 11-13-2007 04:48 AM
Re: Dial-up Modem Question w_tom A+ Certification 0 09-18-2005 09:12 PM
Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good God DVD Video 3 04-25-2005 04:19 PM
Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good Filthy Mcnasty DVD Video 0 04-25-2005 04:29 AM
Re: Safe Mode Question (A+ question) Gordon Findlay A+ Certification 0 06-16-2004 10:48 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