def _get_simulator_precision(): # cache and replace this function precision = simulator.get_precision() global _get_simulator_precision _get_simulator_precision = precision.__int__ return _get_simulator_precision()
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Collection of handy functions.""" import ctypes import math import os import sys import weakref import functools import warnings if "COCOTB_SIM" in os.environ: from cocotb import simulator _LOG_SIM_PRECISION = simulator.get_precision() # request once and cache else: simulator = None _LOG_SIM_PRECISION = -15 def get_python_integer_types(): warnings.warn( "This is an internal cocotb function, use six.integer_types instead", DeprecationWarning) return (int, ) # Simulator helper functions def get_sim_time(units=None): """Retrieves the simulation time from the simulator.