Getting Rank of Elements in an Array

OP #7104207
Dear VHDL Coders,

I am trying to get the rank of elements from an array of data. For 
example, I have an array, Voltage = [20 40 10 30] ;

The position of the elements in the voltage array is ranged from 0 to 3.

Using a bubble sorting algorithm, I obtained index of the elements in 
array as follows: Index (0)= 2 ; Index (1)= 0  ;  Index (2)= 3 ; Index 
(3)= 1 ;

However, basically I just the rank of the elements in the voltage array. 
I expect to get: Rank (0) = 1 ; Rank (1) = 3 ; Rank (2) = 0 ; Rank (3) = 
2 ;

I would appreciate any of your help and suggestion to get the desired 
outcome using the VHDL code. Thanks, a bunch in advance  :)
Moderator (Company: Titel)
Md B. wrote:
> Using a bubble sorting algorithm
Which one?

> using the VHDL code.
Must that be finally implemented on hardware or ist it just some fun for 
the simulator?

Because if "VHDL" is 100% then "VHDL for synthesisis" ist somewhat less 
than 5%

> I would appreciate any of your help
Show your code, so we have something to start and the type definitions 
at least...
Guest
No matter if you are interested in the sorted array values or just the 
ranks: It is a sorting problem. So forget VHDL for the moment and think 
about an algorithm for sorting in hardware (assuming you need real 
synthesizable hardware)

What is the size of the array? Shall the sorting be done sequentially or 
in parallel? May be this paper gives you a first idea: 
https://web.ece.ucsb.edu/Faculty/Parhami/pubs_folder/parh99-ieeetpds-dd-lin-arrays.pdf
However, if the array is small as in your example, there may be a 
simpler solution like here 
https://ijariie.com/AdminUploadPdf/hardware_implementatioon_of__sorting__algorithm_using_FPGA_ijariie7623.pdf

Reply

A question of your own? This thread is over 4 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.