EmbDev.net

Forum: FPGA, VHDL & Verilog function "to_integer"


Author: Mira Miyou (Company: LERICA) (ramiss)
Posted on:

Rate this post
0 useful
not useful
I have a problem when using this function and i have this message : 
"Argument of 'to_integer' function must have size less than 32"

from what I understand, the to_integer function from numeric_std works 
with 32 bits vectors max!!!
is there a way to make it accept 64 bits vectors? ou more?
or is there some other function i should use?

Thank you a lot,
Regards,

Author: Peter K. (Guest)
Posted on:

Rate this post
0 useful
not useful
What programming language do you use?
Maybe the function name is to_long, or you could transform the 64Bit 
vector to 32bit, this truncates the information in the lower 32Bit but 
maybe the precision is enough for your purpose.

Why would you transform to integer datatype, if your datatype is double 
just round it and keep the double datatype

Author: Mira Miyou (Company: LERICA) (ramiss)
Posted on:

Rate this post
0 useful
not useful
Peter Kremsner wrote:
> What programming language do you use?
> Maybe the function name is to_long, or you could transform the 64Bit
> vector to 32bit, this truncates the information in the lower 32Bit but
> maybe the precision is enough for your purpose.
>
> Why would you transform to integer datatype, if your datatype is double
> just round it and keep the double datatype


Thanks for your quickly response,

I use VHDL language (xilinx ISE),
The program concerns manipulation of image block data in order to
achieve a motion estimation, I use a register (32bits) for saving (or
delaying) the data, thus the program works when data size is less than
32-bits but in my case I need 64-bits, so how can I do this?

Thank you,

Author: Peter K. (Guest)
Posted on:

Rate this post
0 useful
not useful
Truncate the 64 Bit to 32 Bit or use 2 32Bit Register for saving the 
data.
1 for the low 32Bit the other for the high 32Bit and perform the 
operation with two registers.

Author: -gb- (Guest)
Posted on:

Rate this post
0 useful
not useful
You could use unsigned/signed. They are not limited in length.

Author: Mira Miyou (Company: LERICA) (ramiss)
Posted on:

Rate this post
0 useful
not useful
Peter Kremsner wrote:
> Truncate the 64 Bit to 32 Bit or use 2 32Bit Register for saving the
> data.
> 1 for the low 32Bit the other for the high 32Bit and perform the
> operation with two registers.


Thank you again for your valuable comments,
I did as you mentioned, I split my data into two parts, once using 
32-bit registers, and the second part another 32-bit registers, only I 
hope it wont be a blend of data :)

Thank you all,
Best regards,

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Mira Miyou wrote:
> I did as you mentioned, I split my data into two parts
And what do you do with that segmented value afterwards?

My way would be to use a unsigned(63 downto 0) vector and the 
numeric_std for the calculations with it...

Author: Mira Miyou (Company: LERICA) (ramiss)
Posted on:

Rate this post
0 useful
not useful
Lothar Miller wrote:
> And what do you do with that segmented value afterwards?
>
> My way would be to use a unsigned(63 downto 0) vector and the
> numeric_std for the calculations with it...

Actually I reduced the size of register at 32bits and I changed the way 
in which the data are presented in my program so that it goes with the 
32bits, since anyway I can't go beyond.

concerning the function unsigned, I don't use it because before storing 
the value in the register I use an absolute value like this:
abs (to_integer (signed (data)))
thank you again for the time you spent to write me,

Author: berndl (Guest)
Posted on:

Rate this post
0 useful
not useful
Mira Miyou wrote:
> abs (to_integer (signed (data)))

you should accept the fact that VHDL has integers (that's signed by the 
way!) of only 32 bits. For anything beyond this, you might follow 
Lothars advice and go to 'signed' and 'unsigned' (which are unlimited in 
bit-width)...

Author: Mira Miyou (Company: LERICA) (ramiss)
Posted on:

Rate this post
0 useful
not useful
berndl wrote:
> Mira Miyou wrote:
>> abs (to_integer (signed (data)))
>
> you should accept the fact that VHDL has integers (that's signed by the
> way!) of only 32 bits. For anything beyond this, you might follow
> Lothars advice and go to 'signed' and 'unsigned' (which are unlimited in
> bit-width)...

Ok, thank's for your advice :)
Regards,

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.