std_logic_vector ==> interger?

U

uvbaz

Guest
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
 
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
 
"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
 
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 mailto:Jim@SynthWorks.com
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
 
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-1078) 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.
 
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-1078) 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.
 
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-1078) 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
 

Welcome to EDABoard.com

Sponsor

Back
Top