# Attribute init, using on part of an array

Status
Not open for further replies.

#### AndyDesigner

##### Newbie level 4
Hello,

I want to set initial values into part of a 2D array as follows, but ISE doesnt appear to alllow it.

Here is what im doing:

subtype T1 is Std_logic_vector (7 down to 0);
type T1_ARRAY is arr....... of T1;

attribute init: string;
attritute init of T1_ARRAY(0) is "S";

The porlbem appears to be that ISE doesnt allow only part of the array to be setup. IE this works ok:

attritute init of T1_ARRAY is "S";

any ideas on the best way to get around this?

Andy

#### bigdogguru

Where to begin?

I'm not exactly sure what your goals are here, but is sounds as if you want to initialize part of an array of ASCII characters. It looks like you want a 1Dx1D array, not a 2D array. You may want to try something along these lines:

Code:
TYPE Chars IS ARRAY (0 TO 9) OF STD_LOGIC_VECTOR(0 TO 7);

SIGNAL x: Chars;

x(0) <= CONV_STD_LOGIC_VECTOR(character'pos('P'),8);

This creates an array of ten ascii codes, which you can initialize individually with a character to ASCII conversion.

Beware of passing around nonstandard dataypes, such as character, in your vhdl code, you can simulate the code, but you will not be able to implement it. Using a conversion to standard logic is alright because it takes place at compile time, not during implemenation.

Of course there are several other ways of accomplishing the same feat.

If you are really looking for a 2D array then try this code:

Code:
TYPE Chars IS ARRAY (0 TO 9, 9 DOWNTO 0) OF STD_LOGIC_VECTOR(0 TO 7);

SIGNAL x: Chars;

x(0,0) <= CONV_STD_LOGIC_VECTOR(character'pos('P'),8);

This forms a 10x10 array of 1 Byte for your ASCII codes, enough for one hundred characters to be stored as ASCII.

Both these examples compile fine and can be implemented.

Status
Not open for further replies.