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

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

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

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