Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Shift arithmetic problem for noob

Reply
Thread Tools

Shift arithmetic problem for noob

 
 
jeucomanu@virgilio.it
Guest
Posts: n/a
 
      11-01-2007
hi everybody,

how i can traslate this line in C

varA = (varA<<4) + varB;

in VHDL language????

wrong exemple

varA <= (varA sll 4) + varB;

My problem is the shift "<<" i try with SHL, sll, ecc. but i cant
compile the vhdl because there is some error.
I have include librerie std_logic_arith "use
IEEE.std_logic_arith.all;" but have this error:

Operator "sll" is not defined for such operands.
Undefined type of expression.
Assignment target incompatible with right side. Expected type
"std_logic_vector".

i have tray with different type: std_logic_vector, integer, bit_vector
but i have the same result, error on compile.

pls, help me.

Jeuco

 
Reply With Quote
 
 
 
 
KJ
Guest
Posts: n/a
 
      11-01-2007

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> hi everybody,
>
> how i can traslate this line in C
>
> varA = (varA<<4) + varB;
>
> in VHDL language????
>
> wrong exemple
>
> varA <= (varA sll 4) + varB;
>
> My problem is the shift "<<" i try with SHL, sll, ecc. but i cant
> compile the vhdl because there is some error.
> I have include librerie std_logic_arith "use
> IEEE.std_logic_arith.all;" but have this error:
>
> Operator "sll" is not defined for such operands.
> Undefined type of expression.
> Assignment target incompatible with right side. Expected type
> "std_logic_vector".
>
> i have tray with different type: std_logic_vector, integer, bit_vector
> but i have the same result, error on compile.
>


Don't use std_logic_arith, use numeric_std instead.....and take a look at
the shift_left function it does exactly what you want

KJ


 
Reply With Quote
 
 
 
 
Andy
Guest
Posts: n/a
 
      11-01-2007
On Nov 1, 6:02 am, "KJ" <(E-Mail Removed)> wrote:
>
> Don't use std_logic_arith, use numeric_std instead.....and take a look at
> the shift_left function it does exactly what you want
>
> KJ


As does multiplication by a constant power of two for integer or
numeric_std.signed/unsigned:

varA <= varA * 2**4 + varB;

If the length of varB is also 4 (or less), then the arithmetic will
optimize out to just bit stuffing.

Andy

 
Reply With Quote
 
jeucomanu@virgilio.it
Guest
Posts: n/a
 
      11-01-2007
On 1 Nov, 21:40, Andy <(E-Mail Removed)> wrote:
> On Nov 1, 6:02 am, "KJ" <(E-Mail Removed)> wrote:
>
>
>
> > Don't use std_logic_arith, use numeric_std instead.....and take a look at
> > the shift_left function it does exactly what you want

>
> > KJ

>
> As does multiplication by a constant power of two for integer or
> numeric_std.signed/unsigned:
>
> varA <= varA * 2**4 + varB;
>
> If the length of varB is also 4 (or less), then the arithmetic will
> optimize out to just bit stuffing.
>
> Andy


Ok, i now this trick and there are another solution for bypass the
problem but i want know why sll don't work and resolve the problem for
use sll or SHl?

anybody can explain me?

 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      11-02-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Ok, i now this trick and there are another solution for bypass the
> problem but i want know why sll don't work and resolve the problem for
> use sll or SHl?
>
> anybody can explain me?
>

http://groups.google.com/groups/sear...l+shifter+po_v
 
Reply With Quote
 
jeucomanu@virgilio.it
Guest
Posts: n/a
 
      11-03-2007
On 2 Nov, 17:22, Mike Treseler <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > Ok, i now this trick and there are another solution for bypass the
> > problem but i want know why sll don't work and resolve the problem for
> > use sll or SHl?

>
> > anybody can explain me?

>
> http://groups.google.com/groups/sear...l+shifter+po_v


but you read what i wrote? i don't want a trick o different solution,
i want know why i cant compile vhdl whit operator SLL or SHL

 
Reply With Quote
 
KJ
Guest
Posts: n/a
 
      11-03-2007

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> On 2 Nov, 17:22, Mike Treseler <(E-Mail Removed)> wrote:
>> (E-Mail Removed) wrote:
>> > Ok, i now this trick and there are another solution for bypass the
>> > problem but i want know why sll don't work and resolve the problem for
>> > use sll or SHl?

>>
>> > anybody can explain me?

>>
>> http://groups.google.com/groups/sear...l+shifter+po_v

>
> but you read what i wrote? i don't want a trick o different solution,
> i want know why i cant compile vhdl whit operator SLL or SHL
>


Well gee, you don't post your code and you expect people to tell you why
your code doesn't compile? The data types matter, and the error messages
that you are getting were telling you that the data types are not correct.
Like all other functions and procedures, 'sll' expects certain data types
as inputs and produces certain data types as outputs. Those definitions are
not secrets, do a search for the the function definition of 'sll' and you
will see what data types it expects and produces.

For some sample code that uses sll in a manner similar to how you listed in
your code snippet at the start of the thread, see below. It compiles and
works so look at how your code differs from it...that is a likely source of
your error.

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity foo is
end foo;

architecture RTL of foo is
signal Vara, Varb, Varc: unsigned(7 downto 0);
begin
Vara <= "00000001";
Varb <= "00000010";
Varc <= (Vara sll 4) + Varb;
end RTL;

KJ


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java left shift and right shift operators. Sanny Java 38 04-29-2011 10:02 PM
what "shift" does, if not "$_ = shift;" ? devphylosoff Perl Misc 3 12-04-2007 12:27 AM
Left Shift / Right Shift Operators Santosh Nayak C Programming 16 11-30-2006 05:10 PM
Shift - byte[] buf shift Roberto Gallo Java 3 01-27-2004 04:26 PM
left shift then right shift an unsigned int Wenjie C++ 3 07-11-2003 08:22 PM



Advertisments