"cltsaig" <> wrote in message
news: lkaboutprogramming.com...
> Hi all,
>
> I got an syntax error with the following left shfit operation
assignment.
> # Assignment target incompatible with right side. Expected type
> "INTEGER".
> # Cannot find function to_integer for these actuals.
> # Undefined type of expression.
>
> library ieee;
> use ieee.std_logic_1164.all;
> use ieee.numeric_std.all;
> use ieee.math_real.al
>
> process
> variable ip1, nprev: integer;
> begin
> nprev:=20;
> ip1:=to_integer(to_StdLogicVector(nprev) sll 1);
> end process;
>
> Any help will be very appreciate!!!
>
In Numeric_std, sll is defined for types signed and unsigned.
So you need to do
a) convert your integer to unsigned
b) shift left, producing an unsigned result
c) convert from unsigned back to integer
ip1 := to_integer( to_unsigned(nprev, 5) sll 1 );
Note that to_unsigned takes a second argument specifying the
width of the resultant vector.
Regarding the problem, you could of course with your
example code simply say
ip1 := 40; -- only joking!
It might be worth trying (depending on your synthesis tool)
ip1 := nprev * 2;
as multiplication by a constant power of 2 is understood
by many tools and can be implemented by a shift in hardware.
If you want to use integers, and they are for representing
unsigned values, I would declare them as "natural" rather than
"integer".
You may find that if you are doing lots of bit shifting
and arithmetic operations, it is easier to use the vector
types unsigned and signed, and then convert the final output
to the required type.
regards
Alan
--
Alan Fitch
Consultant
DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project
Services
Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24
1AW, UK
Tel: +44 (0)1425 471223 mail:
Fax: +44 (0)1425 471573 Web:
http://www.doulos.com
The contents of this message may contain personal views which are not
the
views of Doulos Ltd., unless specifically stated.