Array to std_logic

Discussion in 'VHDL' started by Joshdak, Nov 6, 2004.

  1. Joshdak

    Joshdak Guest

    If I have for example:

    signal mytest: std_logic_vector(9 downto 0);

    type storage is array (0 to 7,0 to 7) of real;

    top: process
    variable test_storage : storage := (
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    );

    Then I want to do, actually, in pseudo code:
    mytest <= test_storage(4,5);
    But how to do this ? I would acutally like to do this for several types of
    precision for the data, for example - in pseudo iw would like something
    like:

    variable test_storage : storage := 2^8 * (
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    (1.345,1.1450,1.1220,1.1530,1.1550,1.1550,0.1550,0.155.0),
    );

    mytest <= test_storage(4,5); -- could I do this or similar?

    Best Regards
    Joshdak, Nov 6, 2004
    #1
    1. Advertising

  2. Joshdak wrote:


    > signal mytest: std_logic_vector(9 downto 0);


    An integer type.

    > type storage is array (0 to 7,0 to 7) of real;


    A floating point type.

    > mytest <= test_storage(4,5);
    > But how to do this ?


    What do you expect, if you convert a floating point type to an integer type?

    You could implement floating point arithmetic by doing it manually.
    http://www.psc.edu/general/software/packages/ieee/ieee.html
    At the moment real is not synthesitzeable in VHDL.

    If you don't need it so accurately you may do fixed point arithmetics.


    > variable test_storage : storage := 2^8 * (

    ....
    > mytest <= test_storage(4,5); -- could I do this or similar?


    Look at the IEEE floating point standard or if you use fixed point
    arithmetics shift the value by 8 bits.

    Ralf
    Ralf Hildebrandt, Nov 6, 2004
    #2
    1. Advertising

  3. Joshdak

    Joshdak Guest

    "Ralf Hildebrandt" <> skrev i en meddelelse
    news:...
    > Joshdak wrote:
    >
    >
    > > signal mytest: std_logic_vector(9 downto 0);

    >
    > An integer type.
    >
    > > type storage is array (0 to 7,0 to 7) of real;

    >
    > A floating point type.
    >
    > > mytest <= test_storage(4,5);
    > > But how to do this ?

    >
    > What do you expect, if you convert a floating point type to an integer

    type?
    >
    > You could implement floating point arithmetic by doing it manually.
    > http://www.psc.edu/general/software/packages/ieee/ieee.html
    > At the moment real is not synthesitzeable in VHDL.
    >
    > If you don't need it so accurately you may do fixed point arithmetics.
    >
    >
    > > variable test_storage : storage := 2^8 * (

    > ...
    > > mytest <= test_storage(4,5); -- could I do this or similar?

    >
    > Look at the IEEE floating point standard or if you use fixed point
    > arithmetics shift the value by 8 bits.
    >
    > Ralf



    Yes sorry, this was what I meant. Maybe I have'nt made my self clear, sorry.
    But what I want to do is actually convert the floating point values to fixed
    point values. But do not want to have to perform this operation each time I
    index my table. I want synthesis tool to acknowledge the table as being
    these fixed point values as default. That is, for example, if we take the
    value 1.345 and I would as an example shift with 8 bit (the problem is that
    I would like this value in which I am shifting to be generic) I would like
    the value 1.345*2^8 (shifted 8 times) to "mytest" signal.
    So actually I would like to, in pseudo, to do something like:

    variable test_storage : storage := 2^N * (1.345,......,.....,.....,....
    mytest <= to_integer(test_storage(XXX));
    Where the to_integer function then would truncate my test_storage value.

    Best Regards
    Joshdak, Nov 6, 2004
    #3
  4. Joshdak wrote:

    > But what I want to do is actually convert the floating point values to fixed
    > point values. But do not want to have to perform this operation each time I
    > index my table. I want synthesis tool to acknowledge the table as being
    > these fixed point values as default.


    Ok. - Now you have to specify how many bits after the point you need.


    > That is, for example, if we take the
    > value 1.345


    1.345 = (decimal, floating point)
    0 * 2^3 +
    0 * 2^2 +
    0 * 2^1 +
    1 * 2^0 +
    0 * 2^-1 +
    1 * 2^-2 +
    0 * 2^-3 +
    1 * 2^-4 +
    1 * 2^-5 +
    .... (and so on...)
    = 0001.01011 (binary, fiexd point with 5 bits after the point)

    For a small number of values, its easy to precomupte it manually and
    juste strore these precomputed values in an array of std_ulogic_vectors.

    > and I would as an example shift with 8 bit (the problem is that
    > I would like this value in which I am shifting to be generic) I would like
    > the value 1.345*2^8 (shifted 8 times) to "mytest" signal.


    If you use the above explained fixed point format, its very easy to shift.


    Ralf
    Ralf Hildebrandt, Nov 6, 2004
    #4
  5. Joshdak

    rickman Guest

    Joshdak wrote:
    >
    > Yes sorry, this was what I meant. Maybe I have'nt made my self clear, sorry.
    > But what I want to do is actually convert the floating point values to fixed
    > point values. But do not want to have to perform this operation each time I
    > index my table. I want synthesis tool to acknowledge the table as being
    > these fixed point values as default. That is, for example, if we take the
    > value 1.345 and I would as an example shift with 8 bit (the problem is that
    > I would like this value in which I am shifting to be generic) I would like
    > the value 1.345*2^8 (shifted 8 times) to "mytest" signal.
    > So actually I would like to, in pseudo, to do something like:
    >
    > variable test_storage : storage := 2^N * (1.345,......,.....,.....,....
    > mytest <= to_integer(test_storage(XXX));
    > Where the to_integer function then would truncate my test_storage value.


    If you don't want the floating point data converted when you access the
    table, then you need to convert the data first and store the converted
    data in the table.

    --

    Rick "rickman" Collins


    Ignore the reply address. To email me use the above address with the XY
    removed.

    Arius - A Signal Processing Solutions Company
    Specializing in DSP and FPGA design URL http://www.arius.com
    4 King Ave 301-682-7772 Voice
    Frederick, MD 21701-3110 301-682-7666 FAX
    rickman, Nov 7, 2004
    #5
    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. Christopher Bunk

    Synthesis of STD_LOGIC

    Christopher Bunk, Jul 1, 2003, in forum: VHDL
    Replies:
    2
    Views:
    1,295
    Tim Hubberstey
    Jul 4, 2003
  2. zoro
    Replies:
    2
    Views:
    3,030
    =?ISO-8859-1?Q?Nicolai_J=F8rgensen?=
    Jul 5, 2003
  3. valentin tihomirov

    boolean to std_logic

    valentin tihomirov, Dec 31, 2003, in forum: VHDL
    Replies:
    3
    Views:
    14,302
    Mike Treseler
    Jan 5, 2004
  4. poulette
    Replies:
    1
    Views:
    1,757
    joris
    Feb 12, 2009
  5. sylwa
    Replies:
    2
    Views:
    1,276
    sylwa
    Apr 21, 2011
Loading...

Share This Page