Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Shift right : does not compile in Modelsim VCOM

 
Thread Tools Search this Thread
Old 09-08-2007, 05:17 PM   #1
Default Shift right : does not compile in Modelsim VCOM


In VHDL code, following libraries and signals are defined.
-------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;
.....
signal HF : std_logic_vector(15 downto 0);
signal LF : std_logic_vector(15 downto 0);
-------------------

Problem is that

Following "shift right" is not working.
--------------------
HF <= LF srl 2; -- logical shift right
--------------------

Modelsim 6.1c reports following error :
-------------------
# ** Error: HF.vhd(113): No feasible entries for infix operator "srl".
# ** Error: HF.vhd(113): Type error resolving infix expression "srl"
as type std_logic_vector.
-------------------

I tried different ways, such as "SHR, SHIFT_RIGHT" with different data
types.

If anyone had same problem, please let me know how to resolve this
problem.
thank you in advance



Pasacco
  Reply With Quote
Old 09-08-2007, 06:01 PM   #2
Duane Clark
 
Posts: n/a
Default Re: Shift right : does not compile in Modelsim VCOM
Pasacco wrote:
> In VHDL code, following libraries and signals are defined.
> -------------------
> library IEEE;
> use IEEE.STD_LOGIC_1164.ALL;
> use IEEE.STD_LOGIC_ARITH.ALL;
> use IEEE.STD_LOGIC_UNSIGNED.ALL;
> use IEEE.NUMERIC_STD.ALL;


Don't mix NUMERIC_STD with STD_LOGIC_ARITH/STD_LOGIC_UNSIGNED. In fact,
you really should not be using STD_LOGIC_ARITH/STD_LOGIC_UNSIGNED at
all, ever.

> ....
> signal HF : std_logic_vector(15 downto 0);
> signal LF : std_logic_vector(15 downto 0);
> -------------------
>
> Problem is that
>
> Following "shift right" is not working.
> --------------------
> HF <= LF srl 2; -- logical shift right
> --------------------


I don't really see a reason to bother with srl and similar operators for
that.

HF <= LF(1 downto 0) & LF(15 downto 2);


Duane Clark
  Reply With Quote
Old 09-08-2007, 07:51 PM   #3
Jonathan Bromley
 
Posts: n/a
Default Re: Shift right : does not compile in Modelsim VCOM
On Sat, 08 Sep 2007 09:17:48 -0700, Pasacco <> wrote:

>In VHDL code, following libraries and signals are defined.
>-------------------
>library IEEE;
>use IEEE.STD_LOGIC_1164.ALL;
>use IEEE.STD_LOGIC_ARITH.ALL;
>use IEEE.STD_LOGIC_UNSIGNED.ALL;
>use IEEE.NUMERIC_STD.ALL;


As Duane already said, this is a total mess;
STD_LOGIC_ARITH and NUMERIC_STD both define
a bunch of things with the same names, and
the two USE clauses render *both* sets of
definitions invisible. However, that's not
the problem here.

>signal HF : std_logic_vector(15 downto 0);
>signal LF : std_logic_vector(15 downto 0);
>...
>HF <= LF srl 2; -- logical shift right


># ** Error: HF.vhd(113): No feasible entries for infix operator "srl".


Indeed so. The shift operators have no implicit (built-in)
definition, and std_logic_1164 does not provide definitions
for them.

You can sooooo easily define your own - details below - but
you can also use the shift operators defined on UNSIGNED
vectors in NUMERIC_STD (if, of course, you get rid of the
conflicting USE clause for STD_LOGIC_ARITH).

HF <= std_logic_vector( unsigned(LF) srl 2 );

Yes, I know it's ugly. So, why not make your own?

function "srl" (L: std_logic_vector; R: natural)
return std_logic_vector is
variable V: std_logic_vector(L'length-1 downto 0);
begin
if R >= L'length then
V := (others => '0');
else
V := L;
end if;
for i in V'range loop
if i < R then
V(i) := '0';
else
V(i) := V(i-R);
end if;
end loop;
return V;
end;

--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK

http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.


Jonathan Bromley
  Reply With Quote
Old 09-08-2007, 08:12 PM   #4
Jonathan Bromley
 
Posts: n/a
Default Re: Shift right : does not compile in Modelsim VCOM
On Sat, 08 Sep 2007 19:51:15 +0100, Jonathan Bromley
<> wrote:

>You can sooooo easily define your own [srl operator]


ahem, yes, but the code I provided does a LEFT shift
whoops, sorry. It is left as a trivial exercise for the
reader to rewrite it to do RIGHT shift as required!
(hint: make sure you iterate over the vector elements
in the correct order... and don't be frightened of
giving the internal variable a different declaration
if it makes life easier).
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK

http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.


Jonathan Bromley
  Reply With Quote
Old 09-09-2007, 10:35 AM   #5
Pasacco
 
Posts: n/a
Default Re: Shift right : does not compile in Modelsim VCOM
Now it compiles. Thank you for providing 3 solutions.



Pasacco
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in Modelsim 6.0a boitsas Software 1 10-26-2009 05:36 AM
simprim problems on modelsim saiyijinprince Hardware 2 04-05-2007 02:24 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46