Forum Discussion
Altera_Forum
Honored Contributor
15 years ago --- Quote Start --- I now defined count as 17bits wide and I simply check when 17th bit toggles, and the design works. Anyway, I think there should be a better and more efficient way to do it. --- Quote End --- Yes, you are writing behavioral code, so you should do the same for the overflow. You are also "allowed" to add the reset on overwflow action for clarity, although it's performed automatically without coding it.
if (count == 16'hffff)
begin
count <= 0;
// do something on overflow
end The point is to let the design compiler decide how the overflow action can be implemented with least effort. If you want to know how, inspect the gate level code.