Forum Discussion
Altera_Forum
Honored Contributor
12 years agosorter in vhdl
hi every one i want avhdl code to sort integer input ascending if i have an array such as 1,8,9,7,2 the out put will be such as 1,2,7,8,9 i search a lot but didn't find any code that he...
Altera_Forum
Honored Contributor
12 years ago --- Quote Start --- hi kaz i want first to thank you very much i have finished the part of authentication mode i would not finish it without you help . now if i have two input first for codes std_logic_vector ( 0 to 7) and the second for its time which is in integer type ,such as 00000001 ------> 125 ms 00010010 ------> 100 ms 01000100 ------> 200 ms 01111000 ------> 147 ms and i want to sort them as the following 00010010 ------> 100 ms 00000001 ------> 125 ms 01111000 ------> 147 ms 01000100 ------> 200 ms so, i want to sort the second input in ascending order and the corresponding firt input data to it i hope to understand me and help me to start that code. sorry for bad english --- Quote End --- use same principle as above(using counters per ram location) but with some modification: have a ram 256 depth, 10 bits wide. use ms value as address for each address read data, increment it by 1, write the corresponding code into 8 msbs of ram data and increment value into two lsbs of ram data. at the end you will have your ram ready sorted in ascending order of address. The value of ms is the address, the 8 bits content is your corresponding code. the two lsbs are counter for how many times same value occured. if necessary use > 2 bits for counting.