- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everybody,
I'm trying to divide two STD_LOGIC_VECTOR variables, but the "/" operator isn't recognized to this type of variable. When I try to multiply using "*" it works, but when I try to divide it doesn't work. I already try to convert the STD_LOGIC_VETOR to a INTEGER and then divide, but the function CONV_INTEGER returns me a wrong answer. Can somebody help me? Thanks!Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
for a start, you cannot do arithmatic on a std_logic_vector in standard VHDL (pre 2008) - you need non-standard libraries for that. And they do not include a division function. You need to use the numeric_std library for arithmatic, with is done on unsigned and signed data types.
Your attempts at using integer will not work as there is no fraction in in the integer. eg. 3/2 = 1. You need to look into the lpm_divider megafunction. It has pipelining that a division function would not.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the answer, but I've tried to add the numeric_std library and the code doesn't compile.
It's an academic work, in which I need to implement the operations using floating point in IEEE 754 pattern. It's hard and I think your help gonna be very useful. Thank you!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if you Need operations with IEEE754 Floating Point you should use the ALTFP_xxx megafunctions as operations on integers or signed / unsigned vectors and Floating Point numbers are quite different...

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page