Getting Rank of Elements in an Array

OP #7104207
Rate this post
• ▲ useful
▼ not useful
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) #7104765
Rate this post
• ▲ useful
▼ not useful
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 #7104808
Rate this post
• ▲ useful
▼ not useful
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
Moderator (Company: Titel) #7104892
Rate this post
• ▲ useful
▼ not useful
vancouver wrote:
> It is a sorting problem.
For the most easy solution it is simply a "comparing problem". I did a 
little typing in the lunch break... ;-)

Md B. wrote:
> I expect to get:
> Rank (0) = 1 ; Rank (1) = 3 ; Rank (2) = 0 ; Rank (3) = 2 ;
Fits my results. Done. Next problem.
Attached files:

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

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.