I doubt that it matters. You write a behavioral description of the logic function and the synthesis tool tries to minimize the logic.But its is not very efficient.
A for-loop version probably works fine.
if not, you can convert it into a rotate + priority encoder + adder, at least for the 2^N inputs case.
There are a few other implementations possible. For example, you can create constants for 10101010, 11001100, 11110000 etc... based on elaboration time constants. Then you can use the "(-x) and (x)" trick to get a one-hot value. each bit of the encoder is then the or-reduction of "constantand one_hot". That sounds interesting, but I'm not sure if it is actually better. The use of the addition should force the tools to use a different implementation method though.
But I'd start by comparing the for-loop version to a more verbose fixed sized version. It doesn't take much time and allows you to determine if the for-loop approach happens to map better to a LUT based implementation.
But overall this sounds like a really bad project. Unless there is some trick, this doesn't look like a problem that is well solved by structural modeling. This seems like something that forces the student to write code poorly which doesn't really serve to teach the student nor prepare them for a career. The only point this serves is that just because you can do something doesn't mean you should. Really, the structural techniques taught in classes are often very misapplied.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?