Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > std_logic_vector ==> interger?

Reply
Thread Tools

std_logic_vector ==> interger?

 
 
uvbaz
Guest
Posts: n/a
 
      09-11-2006
hallo, everyone

op: in std_logic_vector(3 downto 1);
............
........
if( int(op(3 downto 1)) = 2#110# ) then....

this is part of the code, i got the following error:
(vcom-1136) Unknown identifier "int".

thanks for your help

 
Reply With Quote
 
 
 
 
KJ
Guest
Posts: n/a
 
      09-11-2006

uvbaz wrote:
> hallo, everyone
>
> op: in std_logic_vector(3 downto 1);
> ...........
> .......
> if( int(op(3 downto 1)) = 2#110# ) then....
>
> this is part of the code, i got the following error:
> (vcom-1136) Unknown identifier "int".
>
> thanks for your help


I think what you want is..

if( to_integer(unsigned(op(3 downto 1)))) = 2#110# ) then....

You'll also need to include the numeric_std package outside of the
architecture which is the package that contains the definition of
'unsigned' and 'to_integer'

use ieee.numeric_std.all;

KJ

 
Reply With Quote
 
 
 
 
Andy
Guest
Posts: n/a
 
      09-11-2006
"int" is a conversion function that someone has written themselves.
Make sure you have correct versions of the packages that are used for
this module.

Another way to do the conversion would be, assuming op(3 downto 1) is
really all of op:

if unsigned(op) = 2#110# then

using ieee.numeric_std package

Andy


uvbaz wrote:
> hallo, everyone
>
> op: in std_logic_vector(3 downto 1);
> ...........
> .......
> if( int(op(3 downto 1)) = 2#110# ) then....
>
> this is part of the code, i got the following error:
> (vcom-1136) Unknown identifier "int".
>
> thanks for your help


 
Reply With Quote
 
Jim Lewis
Guest
Posts: n/a
 
      09-11-2006
Uvbaz,
For "=" and "/=" there is no reason not to
use std_logic_vector directly in the comparision.
Hence, your code becomes:

if( op(3 downto 1) = "110" ) then


For using ">", ">", ">=", and "<=", it is easiest to
use a type conversion to convert to unsigned
(as Andy suggested). Also make sure to use the
package "numeric_std". So if you were doing ">",

use ieee.numeric_std.all ; -- before the entity
....

if( unsigned(op(3 downto 1)) > "110" ) then

Due to overloading in numeric_std, it is also valid
to use integer literals with unsigned, and hence the
following are also valid:

if( unsigned(op(3 downto 1)) > 6 ) then
if( unsigned(op(3 downto 1)) > 2#110# ) then

Note that 2#110# is an integer literal (use where integers
can be used), whereas, "110" is a string literal, which
can be use with any array type based on character types
(such as unsigned, std_logic_vector, ...). A few character
based types are character, bit, std_ulogic and std_logic.

Cheers,
Jim

P.S.
Ironically in VHDL understanding types and values is one
of the hard things. However, once you get past beginner
mistakes, these will start to work in your favor - ie: find
bugs at compile time that would otherwise take simulation
and a good testbench to find.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Jim Lewis
Director of Training private.php?do=newpm&u=
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~

> hallo, everyone
>
> op: in std_logic_vector(3 downto 1);
> ...........
> .......
> if( int(op(3 downto 1)) = 2#110# ) then....
>
> this is part of the code, i got the following error:
> (vcom-1136) Unknown identifier "int".
>
> thanks for your help
>

 
Reply With Quote
 
uvbaz
Guest
Posts: n/a
 
      09-12-2006
firstly, thanks a lot to Kevin, Andy and Jim.

if( op(3 downto 1) = "110" ) then <------------------ this works.

however, there is an error, when i try to compile

if( unsigned(op(3 downto 1)) = 2#110# ) then <----------------- XXX,
error!

error:
(vcom-107 Identifier "unsigned" is not directly visible.
Potentially visible declarations are:
ieee.numeric_std.unsigned (type)
ieee.std_logic_arith.unsigned (type)

although i have the following declaration in the code.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.numeric_std.all;

thanks again, everyone. You are so kindly.

 
Reply With Quote
 
Paul Uiterlinden
Guest
Posts: n/a
 
      09-12-2006
uvbaz wrote:

> firstly, thanks a lot to Kevin, Andy and Jim.
>
> if( op(3 downto 1) = "110" ) then <------------------ this works.
>
> however, there is an error, when i try to compile
>
> if( unsigned(op(3 downto 1)) = 2#110# ) then <----------------- XXX,
> error!
>
> error:
> (vcom-107 Identifier "unsigned" is not directly visible.
> Potentially visible declarations are:
> ieee.numeric_std.unsigned (type)
> ieee.std_logic_arith.unsigned (type)
>
> although i have the following declaration in the code.
> library ieee;
> use ieee.std_logic_1164.all;
> use ieee.std_logic_arith.all;
> use ieee.numeric_std.all;
>
> thanks again, everyone. You are so kindly.


You should get rid of the use ieee.std_logic_arith.all statement and
never use it again.

In stead, use numeric_std. That is an IEEE standardized package, where
std_logic_arith is not (it is by Synopsys)

So just use numeric_std.

--
Paul.
 
Reply With Quote
 
uvbaz
Guest
Posts: n/a
 
      09-12-2006

Paul Uiterlinden schrieb:

> uvbaz wrote:
>
> > firstly, thanks a lot to Kevin, Andy and Jim.
> >
> > if( op(3 downto 1) = "110" ) then <------------------ this works.
> >
> > however, there is an error, when i try to compile
> >
> > if( unsigned(op(3 downto 1)) = 2#110# ) then <----------------- XXX,
> > error!
> >
> > error:
> > (vcom-107 Identifier "unsigned" is not directly visible.
> > Potentially visible declarations are:
> > ieee.numeric_std.unsigned (type)
> > ieee.std_logic_arith.unsigned (type)
> >
> > although i have the following declaration in the code.
> > library ieee;
> > use ieee.std_logic_1164.all;
> > use ieee.std_logic_arith.all;
> > use ieee.numeric_std.all;
> >
> > thanks again, everyone. You are so kindly.

>
> You should get rid of the use ieee.std_logic_arith.all statement and
> never use it again.
>
> In stead, use numeric_std. That is an IEEE standardized package, where
> std_logic_arith is not (it is by Synopsys)
>
> So just use numeric_std.
>
> --
> Paul.


Yes, it works...
thanks, Paul

 
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
Array of std_logic_vector Willem Oosthuizen VHDL 3 02-26-2010 12:27 AM
character to std_logic_vector Pedro Claro VHDL 7 10-21-2009 08:38 AM
inout std_logic_vector to array of std_logic_vector of generic length conversion... Thomas Rouam VHDL 6 11-09-2007 11:49 AM
std_logic_vector port doesn't work after synthesis. Mike VHDL 3 07-09-2003 09:10 PM
STD_LOGIC_VECTOR vs. UNSIGNED vs. SIGNED Jeremy Pyle VHDL 3 06-28-2003 10:47 PM



Advertisments