What does this do ?

Discussion in 'VHDL' started by iqbalmuh@hotmail.co.uk, Jan 4, 2008.

  1. Guest

    Hi,

    Can anyone tell me what this bit of code is doing ?

    -- declarations
    -------------------------------------------------------------------------------------------
    signal phase : std_logic_vector(6 downto 0);

    type INTEGER_ARRAY is array ( natural range <> ) of integer;

    constant NUMERATOR : INTEGER_ARRAY(7 downto 0) := (7,30,7,7, 30, 30,
    30,30);

    variable phase_next : std_logic_vector(6 downto 0);
    --------------------------------------------------------------------------------------------

    -- **** problem code **********

    phase_next := phase + NUMERATOR(conv_integer(std));

    Obviously the conv_integer(std) part of the code is being used to
    access the array NUMERATOR but I don't understand exactly how since no
    number value is being specified to key into the array.

    Thanks
    , Jan 4, 2008
    #1
    1. Advertising

  2. KJ Guest


    >
    > -- **** problem code **********
    >
    > phase_next := phase + NUMERATOR(conv_integer(std));
    >
    > Obviously the conv_integer(std) part of the code is being used to
    > access the array NUMERATOR but I don't understand exactly how since no
    > number value is being specified to key into the array.
    >

    conv_integer returns an integer value...that is the "number value is
    being specified to key into the array."

    KJ
    KJ, Jan 4, 2008
    #2
    1. Advertising

  3. Guest

    On Jan 4, 2:05 pm, KJ <> wrote:
    > > -- **** problem code **********

    >
    > > phase_next := phase + NUMERATOR(conv_integer(std));

    >
    > > Obviously the conv_integer(std) part of the code is being used to
    > > access the array NUMERATOR but I don't understand exactly how since no
    > > number value is being specified to key into the array.

    >
    > conv_integer returns an integer value...that is the "number value is
    > being specified to key into the array."
    >
    > KJ


    Yes but what IS the number value ?

    That's the bit I don't understand ie. what is the value of 'std' which
    is being converted by 'conv_integer ?
    , Jan 4, 2008
    #3
  4. Andy Guest

    On Jan 4, 8:10 am, wrote:
    > On Jan 4, 2:05 pm, KJ <> wrote:
    >
    > > > -- **** problem code **********

    >
    > > > phase_next := phase + NUMERATOR(conv_integer(std));

    >
    > > > Obviously the conv_integer(std) part of the code is being used to
    > > > access the array NUMERATOR but I don't understand exactly how since no
    > > > number value is being specified to key into the array.

    >
    > > conv_integer returns an integer value...that is the "number value is
    > > being specified to key into the array."

    >
    > > KJ

    >
    > Yes but what IS the number value ?
    >
    > That's the bit I don't understand ie. what is the value of 'std' which
    > is being converted by 'conv_integer ?


    From the context "std" is a std_logic_vector whose contents are being
    transformed into an integer to index the array. Where does "std" come
    from? It is not shown elsewhere in the code you posted, so how are we
    to know?.

    Andy
    Andy, Jan 4, 2008
    #4
  5. Xin Xiao Guest

    hi

    you have not declared "std", that's the problem. it should be a
    std_logic_vector and it will be converted to integer.

    hth,

    <> wrote in message
    news:...
    On Jan 4, 2:05 pm, KJ <> wrote:
    > > -- **** problem code **********

    >
    > > phase_next := phase + NUMERATOR(conv_integer(std));

    >
    > > Obviously the conv_integer(std) part of the code is being used to
    > > access the array NUMERATOR but I don't understand exactly how since no
    > > number value is being specified to key into the array.

    >
    > conv_integer returns an integer value...that is the "number value is
    > being specified to key into the array."
    >
    > KJ


    Yes but what IS the number value ?

    That's the bit I don't understand ie. what is the value of 'std' which
    is being converted by 'conv_integer ?
    Xin Xiao, Jan 4, 2008
    #5
  6. Symon Guest

    <> wrote in message
    news:...
    >Yes but what IS the number value ?


    I guess 3. But you could simulate it and find out...

    HTH, Syms.
    Symon, Jan 4, 2008
    #6
    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. Bill Johnson
    Replies:
    0
    Views:
    1,225
    Bill Johnson
    Jul 8, 2005
  2. Replies:
    3
    Views:
    468
    Ken Cox [Microsoft MVP]
    Oct 7, 2005
  3. Janet Collins
    Replies:
    0
    Views:
    1,131
    Janet Collins
    Jan 13, 2006
  4. Replies:
    1
    Views:
    829
    Juan T. Llibre
    Feb 8, 2006
  5. Alek Nazarian
    Replies:
    7
    Views:
    3,208
    Alek Nazarian
    Oct 22, 2003
Loading...

Share This Page