None taken.
The _modbv.py already supports any modulo; in simulation it will enforce values between .min and .max.
For conversion the required changes are in _toVHDL.py and _toVerilog.py where you have to intercept the assignment and replace it by several lines of code. That’s may be not that difficult. But that will kind of break existing code (from other users): code like you describe above
if reg == max - 1:
reg.next = 0
else:
reg.next = reg + 1
will then convert to:
if reg = max - 1 then
if 0 < reg.min then
reg <= reg.min;
else
if 0 >= reg.max then
reg <= reg.max - 1;
else
reg <= 0;
end if;
end if ;
else
if reg + 1 < reg,min then
reg <= reg.min;
else
if reg + 1 >= reg.max then
reg <= reg.max - 1;
else
reg <= reg + 1;
end if;
end if;
end if ;
Note that if the right hand side of the assignment is complex, things may get even more complicated.
If you work hard at it, you may eventually clean that up to representable code. I suggest you give it a try.
But I am sure that you will find that writing a re-usable HDL module to do this will be a lot less work.
But with hindsight; I think that the modbv should have be restricted to powers of 2 for simulation also. I estimate that 99.9% of the users use it like that anyway.