How can I access a 2d array completely.

  • Thread starter bharat1986@gmail.com
  • Start date
B

bharat1986@gmail.com

Guest
I have used a 2d array

type CRC is array(3 downto 0) of std_logic_vector(7 downto 0);
signal Frame_CRC : CRC;

now I want to access all the 32 bits in the Frame_CRC...

to assign a 32bit signal to that Frame_CRC..

How can I do it???
 
On Mon, 6 Jul 2009 00:26:41 -0700 (PDT), <bharat1986@gmail.com> wrote:

type CRC is array(3 downto 0) of std_logic_vector(7 downto 0);
signal Frame_CRC : CRC;

now I want to access all the 32 bits in the Frame_CRC...
to assign a 32bit signal to that Frame_CRC..
By re-assembling them into a single 32-bit vector.
Assuming CRC(3) is the most-significant byte:

signal CRC32: std_logic_vector(31 downto 0);
...
CRC32 <= CRC(3) & CRC(2) & CRC(1) & CRC(0);

If you expect to do that more than once, it's
better to write functions to convert:

subtype slv32 is std_logic_vector(31 downto 0);
function to_vec32(Frame_CRC CRC) return slv32 is
begin
return CRC(3) & CRC(2) & CRC(1) & CRC(0);
end;
function to_CRC(slv32 crc32) return Frame_CRC is
begin
return ( 0 => crc32(7 downto 0),
1 => crc32(15 downto 8),
2 => crc32(23 downto 16),
3 => crc32(31 downto 24) );
end;

If you find yourself using 2-d arrays a great deal,
you may wish to write more general pack/unpack functions
using for-loops and the 'RANGE attributes. But the
examples I've given are easy to understand, and do the
job for your specific problem.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 

Welcome to EDABoard.com

Sponsor

Back
Top