![]() |
Array to std_logic
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 |
Re: Array to std_logic
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/...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 |
Re: Array to std_logic
"Ralf Hildebrandt" <Ralf-Hildebrandt@gmx.de> skrev i en meddelelse
news:2v3co3F2ggosqU2@uni-berlin.de... > 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/...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 |
Re: Array to std_logic
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 |
Re: Array to std_logic
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 rick.collins@XYarius.com 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 |
| All times are GMT. The time now is 02:58 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.