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.

Multi-dimensional array in VHDL

Status
Not open for further replies.

gnudaemon

Member level 1
Member level 1
Joined
Sep 16, 2004
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
338
vhdl array

How to implement in VHDL such structure like array [][] in C/C++?
Thanks in advance.
@gnudaemon
 

array vhdl

Here is one example
array of 16 bit data [128][16]

Code:
subtype tmp is std_logic_vector(15 downto 0);
type memory_array is array(integer range 0 to 127, integer range 0 to 15) of tmp;

Hope this helps
 

vhdl multidimensional array

How to access each element?
 

vhdl array of std_logic_vector

Hi,

I just first got the picture of just two dimentional array.

so one example could be

16 bit array[128]

subtype elements is std_logic_vector(15 downto 0);
type 16bit_array is array (0 to 127) of elements;
signal arr : 16bit_array ;

then accesssing the array element could be done by
arr(0) will get first row of 16 bits or one word.

IF it is complicated then for Multidimentional array one can use records and array of records to avoid confusion.

all the best
 

array in vhdl

subtype tmp is std_logic_vector(15 downto 0);
type memory_array is array(integer range 0 to 127, integer range 0 to 15) of tmp;
variable mem : memory_array;


Then in this case you can access memory as follows

data <= mem(10,10);

Its simple is'nt it?
 
vhdl two dimensional array

no, no, to acces one element:
type memo is array(0 to 7) of std_logic_vector(23 downto 0);
signal mem:memo;
....
....
...

data<=mem(2)(3);
 
vhdl 2 dimensional array

since your multidimensional array typically represents a RAM memory there are two possible usages .

as we suppose that you declared your type and signal identically as other users suggested you :

type memory is array (INTEGER range <>) of std_logic_vector(7 downto 0);

signal GetDescDevice : memory(0 to 92); -- a 93 byte character array


to write one byte you'll refer to :

GetDescDevice(3) <= "10110001"; -- you'll write the 4th byte (an 8 bits vector) of your array


to write one particular bit :

GetDescDevice(3)(4) <= '1';



Should help


Regards,


Tesla101
 
array of std_logic_vector

How do you index 1 bit throug the array?

Using the previous example:

type memory is array (INTEGER range <>) of std_logic_vector(7 downto 0);
signal GetDescDevice : memory(0 to 92); -- a 93 byte character array

to write one byte you'll refer to :
GetDescDevice(3) <= "10110001"; -- you'll write the 4th byte (an 8 bits vector) of your array

to write one particular bit :
GetDescDevice(3)(4) <= '1';

I would loke to set bit8 to '0' in all memory adresses.

GetDescDevice(0 to 92)(7) <= '1';

But I get an errormessage saying '0' isn't declared for type std_logic_vector.
 

multidimensional array vhdl

hi
i have the same probleme! then how to access to data in 2 RAM , and do division between data 1 and data 2
think u
 

two dimensional array in vhdl

Something like the following should work :

Set1bit: for i in 0 to 92 generate
begin
GetDescDevice(i)(7) <= '1';
end generate Set1bit;
 

Re: vhdl two dimensional array

i have the same problem..
i want to access the array as a whole in one part of my code and only a single bit of the array in other part of the code.

port(
Switches : out std_logic_vector(7 downto 0);
);

type register_ram is array (0 to 63) of std_logic_vector (7 downto 0);
signal reg_ram_s :register_ram;



switches(0) <= reg_ram_s(10);
the problem is that here i am tryin to write 8 bits (reg_ram_s 10 signal) to one bit of switches(0)
how to get the one bit from the signal: reg_ram_s(10) ?

---------- Post added at 00:21 ---------- Previous post was at 00:17 ----------

i did it thnks
 

Re: vhdl array of std_logic

Hi,

I just first got the picture of just two dimentional array.

so one example could be

16 bit array[128]

subtype elements is std_logic_vector(15 downto 0);
type 16bit_array is array (0 to 127) of elements;
signal arr : 16bit_array ;

then accesssing the array element could be done by
arr(0) will get first row of 16 bits or one word.

IF it is complicated then for Multidimentional array one can use records and array of records to avoid confusion.

all the best

how can we fetch the dta in this type of array? can ny1 xplain ?
 

Your question has the answer in it. arr(0) will be the first element, arr(1) the second and so on..

If you want to access a particular bit in the 16 bit word then you can use arr(0)(3 downto 0) which will get LSB 4 bits of the first array element.
 

how can i access each element of array
reg [7:0] array[3:0][3:0]
 

Re: array vhdl

Is the following possible?

Code:
TYPE track IS ARRAY(0 TO 17) OF BIT;
TYPE side IS ARRAY(0 TO 79) OF track;
TYPE disk IS ARRAY(0 TO 1) OF side;

What I'm trying to achieve it
Code:
TYPE 3d_array IS ARRAY (0 TO 1, 0 TO 79, 0 TO 17) OF BIT;

THANKS
 

Yes, the first example is possible. But it is not the same as the 3d array you posted. Your first one is a 1d array of 1d array of 1d array. What exactly are you trying to acheive. The 3d array you posted is perfectly legal.

I would not recommend making your own array of bit though. There is an array already defined for that (bit_vector).
 

Thanks TrickyDicky. I know that Bit_vector is an unconstrained array, & therefore my first declaration of track is just a subtype of that array.

Given that the disk array declaration is a 1d array of 1d array side of 1d array track.

Is it possible to locate(index) a possition within like you can with a 3d array? Will there ever be a need for such a tree/branch-like structure?

With regards to what i'm trying to achieve...nothing... I'm just curious. There was a exercise in Peter J. Ashenens book "The Students Guide to VHDL" which said

"The data on a diskette is arranged in 18 sectors per track, 80 tracks per side & two sides per diskette. A computer system maintains a map of free sectors. Write a three-dimensional array type declaration to represent such a map, with a '1' element representing a free sector & a '0' element representing an occupied sector. Write a set of nested for loops to scan a variable of this type to find the location of the first free sector."

Which I successfully answered...but it got me curious about cascading arrays.
 

your track type is NOT a subtype of bit_vector. it is a completly new type. Therefore any functions for bit_vector will NOT work with your track type.

a subtype is declared as
subtype track is bit_vector(0 to 17);

To locate an index in a 3d array, you can just write:

result <= disk(a,b,c);

With your 1d array types, it would be:
result <= disk(a)(b)(c);

There are major differences. With the 3d array type, you can only return single bits. You could not return a whole track for example.
With the 1d array types, you can return a whole track, side or bit:

bit <= disk(a)(b)(c);
side <= disk(a)(b);
track <= disk(a);
 
  • Like
Reactions: wtr

    wtr

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top