Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17252 Discussions

Division using STD_LOGIC_VECTOR

Altera_Forum
Honored Contributor II
3,133 Views

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!
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
1,730 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
1,730 Views

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!
0 Kudos
Altera_Forum
Honored Contributor II
1,730 Views

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...

0 Kudos
Reply