2019-10-13 12:53:38 -06:00
|
|
|
from ... import utils
|
2018-12-15 07:23:42 -07:00
|
|
|
from ...hdl import ast
|
2019-10-13 12:53:38 -06:00
|
|
|
from ..._utils import deprecated
|
2018-12-12 07:11:19 -07:00
|
|
|
|
|
|
|
|
|
|
|
__all__ = ["log2_int", "bits_for", "value_bits_sign"]
|
|
|
|
|
|
|
|
|
2019-10-13 12:53:38 -06:00
|
|
|
@deprecated("instead of `log2_int`, use `nmigen.utils.log2_int`")
|
2018-12-12 07:11:19 -07:00
|
|
|
def log2_int(n, need_pow2=True):
|
2019-10-13 12:53:38 -06:00
|
|
|
return utils.log2_int(n, need_pow2)
|
2018-12-12 07:11:19 -07:00
|
|
|
|
|
|
|
|
2019-10-13 12:53:38 -06:00
|
|
|
@deprecated("instead of `bits_for`, use `nmigen.utils.bits_for`")
|
2018-12-12 07:11:19 -07:00
|
|
|
def bits_for(n, require_sign_bit=False):
|
2019-10-13 12:53:38 -06:00
|
|
|
return utils.bits_for(n, require_sign_bit)
|
2018-12-12 07:11:19 -07:00
|
|
|
|
|
|
|
|
2018-12-12 19:06:49 -07:00
|
|
|
@deprecated("instead of `value_bits_sign(v)`, use `v.shape()`")
|
2018-12-12 07:11:19 -07:00
|
|
|
def value_bits_sign(v):
|
2020-07-20 20:53:29 -06:00
|
|
|
return tuple(ast.Value.cast(v).shape())
|