Forum Discussion
Altera_Forum
Honored Contributor
11 years agoAlternatives to min max?
Hi,
Are there any alternatives for min/max in verilog? For not running past a vector. The best way i can figure out is to give it a bit or two headroom and using an extra if statement. Not such a charming solution.4 Replies
- Altera_Forum
Honored Contributor
Hi, Are you referring to min / max value in a vector? Lets say 3bits vector min 000 - max fff. You don't need any extra bit.
- Altera_Forum
Honored Contributor
I might be missing something as I don't know much verilog, but 3 bits gives a min of 0x0 and a max of 0x7. not 0xfff, which is a 12 bit value.
- Altera_Forum
Honored Contributor
what do you mean by min/max past a vector?
If you mean max plus and min minus then you ought to do clipping before discarding some msbs on your vector - Altera_Forum
Honored Contributor
Yes my bad, example I gave you was 12 bits, one hex digit is 4bits.
for 3 bits is Bin Decimal Min 000 0 Max 111 7 So my point was to get a min / max value of any number of bits you don't need any extra bit, just use the value all "1" to compare and you have your max value and use the value all "0" to compare and you have your min value