I have two 5-bit signals, each guaranteed to be carrying a value between 0 and 25. I would like to add them together and get another 5-bit value between 0 and 25, simply taking the sum % 26
.
The best solution I have so far involves adding them together to get 6-bit sum S
, then also calculating S-26
and selecting between the two based on the output of a comparator to check if S > 25
. This requires quite a few parts to create (4 4bit adders, 2 4-bit comparators, 5 bit mux) and feels kinda clunky.
I know I could do it with a simple rom or micro pretty easy, but I am a bit of a masochist for designs built from 74xx and similar chips only. Is there a more elegant solution to this problem I am missing?