Question

I am building a model which requires me to find the maximum of a set of 8 signals, also find the index of the maximum value.

How can I build such a model in Simulink(Xilinx library) ?

I am guessing Compare block followed by a counter block. But somehow, I am not able to figure all things together.

Thanks

Was it helpful?

Solution

One way which gets it all done in parallel:

You need to build a tree of comparators and multiplexers:

  • Start with a block which takes in two values and two indices and passes out the index and the value of the larger. One comparator, 2 muxes per block.
  • On the first level of your tree you have 4 of these blocks feeding into
    • a second level of 2 of these blocks, the results of which feed into
      • a final block which produces your answers

This can be pipelined so you can pour data through it as fast as you like. But it'll use a fair amount of resource. How wide are your signals? Each comparator is 1 LUT4 per bit and a 2:1 mux is 1 LUT4 per bit.

Alternatively, you use a counter to select each of your values in turn. If it's bigger than the current biggest, latch the value into your "biggest" register and latch the counter into a "biggest index" register. Reset the "biggest" register to the smallest value each time your counter resets.

This will take as many clock cycles as you have signal (8 in your case)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top