Using a vector as an index

Discussion in 'VHDL' started by M. Hamed, May 22, 2008.

  1. M. Hamed

    M. Hamed Guest

    Why is the Xilinx tool complaining about this (VHDL):

    timer_done <= timer(data_len);

    Where data_len is a 4 bit std_logic_vector, and timer is a 16 bit
    std_logic_vector.

    I want the tool to automatically infer a MUX with data_len as the
    selector and timer as the input.

    I can use a CASE statement but that is a lot of coding. I think
    Verilog can happily accept that.

    Thanks.
     
    M. Hamed, May 22, 2008
    #1
    1. Advertising

  2. M. Hamed

    Dave Guest

    On May 22, 3:40 pm, "M. Hamed" <> wrote:
    > Why is the Xilinx tool complaining about this (VHDL):
    >
    > timer_done <= timer(data_len);
    >
    > Where data_len is a 4 bit std_logic_vector, and timer is a 16 bit
    > std_logic_vector.
    >
    > I want the tool to automatically infer a MUX with data_len as the
    > selector and timer as the input.
    >
    > I can use a CASE statement but that is a lot of coding. I think
    > Verilog can happily accept that.
    >
    > Thanks.


    Try this:

    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.numeric_std.all;

    -- snip

    timer_done <= timer(to_integer(unsigned(data_len));

    Dave
     
    Dave, May 22, 2008
    #2
    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. pmatos
    Replies:
    6
    Views:
    23,827
  2. Replies:
    8
    Views:
    1,932
    Csaba
    Feb 18, 2006
  3. Javier
    Replies:
    2
    Views:
    570
    James Kanze
    Sep 4, 2007
  4. Rushikesh Joshi
    Replies:
    0
    Views:
    366
    Rushikesh Joshi
    Jul 10, 2004
  5. Tomasz Chmielewski

    sorting index-15, index-9, index-110 "the human way"?

    Tomasz Chmielewski, Mar 4, 2008, in forum: Perl Misc
    Replies:
    4
    Views:
    307
    Tomasz Chmielewski
    Mar 4, 2008
Loading...

Share This Page