std_logic_vector ==> interger?

Discussion in 'VHDL' started by uvbaz, Sep 11, 2006.

  1. uvbaz

    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, Sep 11, 2006
    #1
    1. Advertising

  2. uvbaz

    KJ Guest

    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
    KJ, Sep 11, 2006
    #2
    1. Advertising

  3. uvbaz

    Andy Guest

    "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
    Andy, Sep 11, 2006
    #3
  4. uvbaz

    Jim Lewis Guest

    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:
    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
    >
    Jim Lewis, Sep 11, 2006
    #4
  5. uvbaz

    uvbaz Guest

    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, Sep 12, 2006
    #5
  6. 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, Sep 12, 2006
    #6
  7. uvbaz

    uvbaz Guest

    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
    uvbaz, Sep 12, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VGltOjouLg==?=

    Cannot be converted to 'Interger'

    =?Utf-8?B?VGltOjouLg==?=, Nov 3, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,645
    chanmmn
    Nov 3, 2004
  2. I_have_nothing

    Any easy to printf an interger in 9,999, 99 format?

    I_have_nothing, May 13, 2005, in forum: C Programming
    Replies:
    4
    Views:
    389
    Chris McDonald
    May 13, 2005
  3. heng
    Replies:
    3
    Views:
    323
    Steven T. Hatton
    Dec 6, 2006
  4. Tim Slattery
    Replies:
    2
    Views:
    401
    Pete C
    Jan 6, 2007
  5. Thomas Rouam
    Replies:
    6
    Views:
    1,116
Loading...

Share This Page