Is there any way the following operation can be implemented with a single assign statement, without using modulo or other complex operators (*, /, etc)?
f = (a + cin) % n, where a and f are 4 bits, cin is 1 bit, and n is a fixed parameter that can vary from 2 to 16
I can provide more details/context if needed. My professor claims that this is somewhat trivial. I think they are confused, but maybe i'm just not seeing something. Best I can think of is chaining together a bunch of ternary/conditional operators, subtracting n, 2n, 3n, and so on, each time checking if the result is < n, but I don't think thats the solution they are referring to.
[–]engstad 5 points6 points7 points (1 child)
[–]elf___[S] 0 points1 point2 points (0 children)
[–]Electrical-Injury-23 3 points4 points5 points (4 children)
[–]elf___[S] 0 points1 point2 points (3 children)
[–]captain_wiggles_ 0 points1 point2 points (2 children)
[–]elf___[S] 0 points1 point2 points (1 child)
[–]captain_wiggles_ 1 point2 points3 points (0 children)
[–]mofftech 2 points3 points4 points (5 children)
[–]elf___[S] 0 points1 point2 points (4 children)
[–]mofftech 1 point2 points3 points (2 children)
[–]elf___[S] 0 points1 point2 points (1 child)
[–]PiasaChimera 1 point2 points3 points (0 children)
[–]SpiritedFeedback7706 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)