parametric vector slices

Discussion in 'VHDL' started by alb, Aug 27, 2013.

  1. alb

    alb Guest

    Hi everyone,

    I'm not sure if the 'subject' is correctly formulated but I'll try anyway.

    Assume an array of bits 'a' which has N number of bits. Now assume M < N
    where N/M = k is an integer number. I'd like to slice a in k pieces in
    such a way that I can assign each slice to another array of bits with M
    bits.

    Something like this:

    <code>

    --not tested
    variable a : my_array_of_bits(N-1 downto 0);

    type list is array (0 to k) of my_array_of_bits(M-1 downto 0);
    variable l : list;

    for i in 0 to l'range - 1 loop
    l(i) <= a((i+1)*M - 1 downto i*M);
    end loop;

    </code>

    Is there any better way to do this?

    Al

    --
    A: Because it fouls the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    alb, Aug 27, 2013
    #1
    1. Advertising

  2. alb

    Andy Guest

    Al,

    For vhdl-2008 compliant tools, you can declare a type that is an unconstrained array of unconstrained arrays, so it is possible to write a "slice(input, M)" function that would return such a type. You may want a function that does the reverse too.

    Check your tools' documentation to see which 2008 features they support.

    Andy
    Andy, Aug 27, 2013
    #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. Matthias Kaeppler

    Parametric covariance in class hierarchies

    Matthias Kaeppler, Jan 22, 2006, in forum: Java
    Replies:
    6
    Views:
    391
    Roedy Green
    Jan 23, 2006
  2. Catalin Marinas

    [RFC] Parametric Polymorphism

    Catalin Marinas, Sep 25, 2005, in forum: Python
    Replies:
    11
    Views:
    602
    Catalin Marinas
    Sep 27, 2005
  3. Replies:
    8
    Views:
    1,891
    Csaba
    Feb 18, 2006
  4. Dexter
    Replies:
    0
    Views:
    349
    Dexter
    Mar 26, 2008
  5. Dexter

    Noah's ArcLength (Parametric Curves)

    Dexter, Mar 26, 2008, in forum: C Programming
    Replies:
    0
    Views:
    304
    Dexter
    Mar 26, 2008
Loading...

Share This Page