sonar/core/backends/sv.py
def add_timeformat(testbench_config, testbench):
    """
    Configure the time format for the testbench

    Args:
        testbench_config (Testbench): The testbench configuration
        testbench (str): The testbench being generated

    Raises:
        SonarInvalidArgError: Invalid time format

    Returns:
        str: Updated testbench
    """
    time_format_str = "$timeformat("
    precision = str(testbench_config.metadata["Time_Format"]["precision"])
    time_format = testbench_config.metadata["Time_Format"]["unit"]
    if time_format.endswith("fs"):
        time_format_str += "-15, " + precision + ', " fs", 0);'
    elif time_format.endswith("ps"):
        time_format_str += "-12, " + precision + ', " ps", 0);'
    elif time_format.endswith("ns"):
        time_format_str += "-9, " + precision + ', " ns", 0);'
    elif time_format.endswith("us"):
        time_format_str += "-6, " + precision + ', " us", 0);'
    elif time_format.endswith("ms"):
        time_format_str += "-3, " + precision + ', " ms", 0);'
    elif time_format.endswith("s"):
        time_format_str += "0, " + precision + ', " s", 0);'
    else:
        logger.error(
            "Unknown time format: %s", testbench_config.metadata["Time_Format"]
        )
        raise SonarInvalidArgError
    testbench = include.replace_in_testbenches(
        testbench, "SONAR_TIMEFORMAT", time_format_str
    )
    return testbench

    Configure the time format for the testbench

    Args:
        testbench_config (Testbench): The testbench configuration
        testbench (str): The testbench being generated

    Raises:
        SonarInvalidArgError: Invalid time format

    Returns:
        str: Updated testbench
    
Configure the time format for the testbench
Configure the time format for the testbench
def add_timeformat(testbench_config, testbench):
    time_format_str = "$timeformat("
    precision = str(testbench_config.metadata["Time_Format"]["precision"])
    time_format = testbench_config.metadata["Time_Format"]["unit"]
    if time_format.endswith("fs"):
        time_format_str += "-15, " + precision + ', " fs", 0);'
    elif time_format.endswith("ps"):
        time_format_str += "-12, " + precision + ', " ps", 0);'
    elif time_format.endswith("ns"):
        time_format_str += "-9, " + precision + ', " ns", 0);'
    elif time_format.endswith("us"):
        time_format_str += "-6, " + precision + ', " us", 0);'
    elif time_format.endswith("ms"):
        time_format_str += "-3, " + precision + ', " ms", 0);'
    elif time_format.endswith("s"):
        time_format_str += "0, " + precision + ', " s", 0);'
    else:
        logger.error(
            "Unknown time format: %s", testbench_config.metadata["Time_Format"]
        )
        raise SonarInvalidArgError
    testbench = include.replace_in_testbenches(
        testbench, "SONAR_TIMEFORMAT", time_format_str
    )
    return testbench
def add_timeformat ( testbench_config , testbench ) : time_format_str = "$timeformat(" precision = str ( testbench_config . metadata [ "Time_Format" ] [ "precision" ] ) time_format = testbench_config . metadata [ "Time_Format" ] [ "unit" ] if time_format . endswith ( "fs" ) : time_format_str += "-15, " + precision + ', " fs", 0);' elif time_format . endswith ( "ps" ) : time_format_str += "-12, " + precision + ', " ps", 0);' elif time_format . endswith ( "ns" ) : time_format_str += "-9, " + precision + ', " ns", 0);' elif time_format . endswith ( "us" ) : time_format_str += "-6, " + precision + ', " us", 0);' elif time_format . endswith ( "ms" ) : time_format_str += "-3, " + precision + ', " ms", 0);' elif time_format . endswith ( "s" ) : time_format_str += "0, " + precision + ', " s", 0);' else : logger . error ( "Unknown time format: %s" , testbench_config . metadata [ "Time_Format" ] ) raise SonarInvalidArgError testbench = include . replace_in_testbenches ( testbench , "SONAR_TIMEFORMAT" , time_format_str ) return testbench
Configure the time format for the testbench
Configure the time format for the testbench
"""
    Configure the time format for the testbench

    Args:
        testbench_config (Testbench): The testbench configuration
        testbench (str): The testbench being generated

    Raises:
        SonarInvalidArgError: Invalid time format

    Returns:
        str: Updated testbench
    """
None
str
Invalid time format
Invalid time format
SonarInvalidArgError
testbench_config
The testbench configuration
The testbench configuration
testbench
The testbench being generated
The testbench being generated