How to get a slice of INTEGER type out?

W

walala

Guest
Dear all,

I declared:

Variable Temp: INTEGER RANGE -32768 TO 32767;
Signal x: INTEGER RANGE -128 TO 127;
Signal y: INTEGER RANGE -128 TO 127;

I want to do:

Temp=32*x;

y=Temp(15 downto 8);


The compiler has an error message:

Prefix of a slice must be an array...

Which conversion function shall I use in order to get the higher byte
of the 2-word databus?

Thanks a lot,

-Walala
 
Walala,

To take a slice from an integer you need to convert it to something like
std_logic_vector or unsigned. Here is an example of such a conversion based
on your code but ignoring negative numbers as I don't want to think about
negatives at the moment:

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

signal i_x : integer range 0 to 255;
signal u_y : std_logic_vector(7 downto 0);
signal u_temp : unsigned(15 downto 0);

u_temp (12 downto 5) <= to_unsigned(i_x, 8); -- shift by 5 bits is
equivalent to multiplying by 32
u_y <= std_logic_vector(u_temp (15 downto 8)); -- close types can be
converted by casting

/Mikhail


"walala" <mizhael@yahoo.com> wrote in message
news:6f348bd1.0309050935.1d872226@posting.google.com...
Dear all,

I declared:

Variable Temp: INTEGER RANGE -32768 TO 32767;
Signal x: INTEGER RANGE -128 TO 127;
Signal y: INTEGER RANGE -128 TO 127;

I want to do:

Temp=32*x;

y=Temp(15 downto 8);


The compiler has an error message:

Prefix of a slice must be an array...

Which conversion function shall I use in order to get the higher byte
of the 2-word databus?

Thanks a lot,

-Walala
 

Welcome to EDABoard.com

Sponsor

Back
Top