bit access in multi dimensional array

M

Marco Lazar

Guest
Lets say i have a multi-dimensional array of
32 words, each word is 128 bits wide:

reg [127 : 0] mem [5:0];

How do i access bit 117 in word 14 ?

Is mem[117][14] correct ?

Thanks
 
Marco Lazar <lazar@hou.asp.ti.com> wrote in message news:<bv8t76$nrr$1@newshost.hou.asp.ti.com>...
Lets say i have a multi-dimensional array of
32 words, each word is 128 bits wide:

reg [127 : 0] mem [5:0];

How do i access bit 117 in word 14 ?

Is mem[117][14] correct ?
If your tool fully supports Verilog-2001, then you can do
it with mem[14][117] (the bit index is always the rightmost,
even though it is on the left in the declaration).

If you must stick with Verilog-1995, then there is no way
to do this directly. You cannot apply a bit or part select
to an array word (i.e. only one set of brackets is allowed
after a reference). To read a bit from a word in an array,
you must copy the word out into a temporary vector variable,
and then access a bit select of that variable. To write a
bit into a word in an array, you must copy the word out into
a temporary variable, modify the bit select of the variable,
then copy the modified value back into the word of the array.
 

Welcome to EDABoard.com

Sponsor

Back
Top