Forum Discussion
Altera_Forum
Honored Contributor
12 years ago --- Quote Start --- hi all, i got a vhdl assignment and im stuck. i need to create a controller and data path that have 4 numbers as inputs (as well as clk and reset) and i need to arrange them from the smallest to the largest (4 outputs). i also have 1 comparator that i can use as component inside the data path (i can use only one). the comparator have 2 inputs (2 numbers) and 2 outputs (smaller number and larger number). the controller is a component inside the data path and i can program it however i want (need to have the same clk and reset as the data path as inputs, among othere inputs and outputs as we like). the contoller have a state machine, i think that the state machine has 5 or 6 states, lets say if the inputs are (A B C D) so it will compare AB and place the bigger as new A and smaller as new B, the same for CD, thats 2 states, then compare the new AC and replace larger and smaller, the same for BD, and the 5 state will be comparison of the new BC, maybe we need another state, im not sure. (thats my idea, so fell free to advice for other state machines if u got :) ) in the datapath, we can use 1 comparator, 1 controller (both as components), and whatever else we want to add, but not as components. i hope that im clear, and really need some help, cuz im stuck, thanks alot :) --- Quote End --- One way is to have 3 tests: test1: find max of A,B,C,D e.g C is max, put C as highest test2: find max of A,B,D e.g. D is max, put D as second highest test3: find max of A,B e.g. A is max, put A as third the last value B is fourth If you are restricted to one comparator then you need to share it for test1(3 comparisons) and test2(two comaprisons)