EmbDev.net

Forum: FPGA, VHDL & Verilog Getting Rank of Elements in an Array


von Md B. (mulu07)


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  :)

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


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

von vancouver (Guest)


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

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Attached files:

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.

: Edited by Moderator

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]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig