Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to transfer a row of 2 d array into a 1 d array

Status
Not open for further replies.

adityarajrulz

Newbie level 5
Joined
Jun 4, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Noida, India, India
Activity points
1,345
I have a 2 d array :

type memory is array(0 to 100) of std_logic_vector (7 downto 0)



now i want to read a row of this "memory" array where the row number is known to me in terms of binary values say a1,a2,a3,a4,a5,a6..

i have to read the particular row corresponding to the address bits, and transfer it into another array :

signal data : std_logic_vector (7 downto 0)


when i am using the syntax for transfer as :




data <= memory (a1&a2&a3&......); : the said syntax is showing error.


can you kindly suggest me the correct syntax for this process.
. besides
should i have the memory array as a 2 d array or 1 d array of 1 d array ? and in accordance to memory array , how should i define the data array!!!
 

Are you planning to synthesize this vhdl into an actual circuit? Or will this vhdl only be used in simulation, such as in a testbench?
 

Dear adityarajrulz,

you can easily use a case statement, and put results directly into your target signal 'data'. Access to an array structure is done through integer index. Assuming you have access bits 'ai', you can do as follows:

Code:
READ_PROCESS : process(address_i) is
begin
   case address_i is
      when "0000000" => selected_line <= memory(0);
      when "0000001" => selected_line <= memory(1);
      
      -- and so on
      
      when others => selected_line <= (others => '0');
   end case;
end process READ_PROCESS;

-- Assign to address vector
address_i <= a1 & a2 & a3 & a4 & a5 & a6 & a7;
-- Assign back to original vector
data <= selected_line;

Cheers
 

I have a 2 d array :

type memory is array(0 to 100) of std_logic_vector (7 downto 0)



now i want to read a row of this "memory" array where the row number is known to me in terms of binary values say a1,a2,a3,a4,a5,a6..

i have to read the particular row corresponding to the address bits, and transfer it into another array :

signal data : std_logic_vector (7 downto 0)


when i am using the syntax for transfer as :




data <= memory (a1&a2&a3&......); : the said syntax is showing error.


can you kindly suggest me the correct syntax for this process.
. besides
should i have the memory array as a 2 d array or 1 d array of 1 d array ? and in accordance to memory array , how should i define the data array!!!

Arrays can only be accessed by integer values so you need to construct an integer number out of the address bits that you have. The easiest way is to collect the bits into an unsigned type and then convert that to the integer you need like this...
data <= memory(to_integer(unsigned'(a1 & a2 & a3 & a4 & a5 & a6 & a7)));

But based on your naming convention of a1, a2, etc. I would think that you should already have a std_logic_vector 'a' defined so bit 1 would be a(1), not a1. If that is the case, then the following will do the trick
data <= memory(to_integer(unsigned(a(1 to 7))));

Kevin Jennings
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top