sonar/core/backends/sv.py
def create_clocks(testbench_config, testbench):
    """
    Create clocks used in the testbench

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

    Returns:
        str: Updated testbench
    """
    # TODO make the initial state of the clock configurable (i.e. for diff. clocks)
    dut = testbench_config.modules["DUT"]
    clocks_in = dut.ports.get_clocks("input")

    largest_clock = ""
    largest_period = 0
    regex_int_str = re.compile(r"([0-9]+([\.][0-9]+)*)([a-z]+)")
    for clock in clocks_in:
        regex_match = regex_int_str.match(clock.period)
        if regex_match.group(3) == "s":
            period = float(regex_match.group(1)) * 10 ** 15
        elif regex_match.group(3) == "ms":
            period = float(regex_match.group(1)) * 10 ** 12
        elif regex_match.group(3) == "us":
            period = float(regex_match.group(1)) * 10 ** 9
        elif regex_match.group(3) == "ns":
            period = float(regex_match.group(1)) * 10 ** 6
        elif regex_match.group(3) == "ps":
            period = float(regex_match.group(1)) * 10 ** 3
        else:
            period = float(regex_match.group(1))
        if period > largest_period:
            largest_period = period
            largest_clock = clock.name
    testbench = include.replace_in_testbenches(
        testbench, "SONAR_VECTOR_CLOCK", largest_clock
    )

    return testbench

    Create clocks used in the testbench

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

    Returns:
        str: Updated testbench
    
Create clocks used in the testbench
Create clocks used in the testbench
def create_clocks(testbench_config, testbench):
    dut = testbench_config.modules["DUT"]
    clocks_in = dut.ports.get_clocks("input")
    largest_clock = ""
    largest_period = 0
    regex_int_str = re.compile(r"([0-9]+([\.][0-9]+)*)([a-z]+)")
    for clock in clocks_in:
        regex_match = regex_int_str.match(clock.period)
        if regex_match.group(3) == "s":
            period = float(regex_match.group(1)) * 10 ** 15
        elif regex_match.group(3) == "ms":
            period = float(regex_match.group(1)) * 10 ** 12
        elif regex_match.group(3) == "us":
            period = float(regex_match.group(1)) * 10 ** 9
        elif regex_match.group(3) == "ns":
            period = float(regex_match.group(1)) * 10 ** 6
        elif regex_match.group(3) == "ps":
            period = float(regex_match.group(1)) * 10 ** 3
        else:
            period = float(regex_match.group(1))
        if period > largest_period:
            largest_period = period
            largest_clock = clock.name
    testbench = include.replace_in_testbenches(
        testbench, "SONAR_VECTOR_CLOCK", largest_clock
    )
    return testbench
def create_clocks ( testbench_config , testbench ) : dut = testbench_config . modules [ "DUT" ] clocks_in = dut . ports . get_clocks ( "input" ) largest_clock = "" largest_period = 0 regex_int_str = re . compile ( r"([0-9]+([\.][0-9]+)*)([a-z]+)" ) for clock in clocks_in : regex_match = regex_int_str . match ( clock . period ) if regex_match . group ( 3 ) == "s" : period = float ( regex_match . group ( 1 ) ) * 10 ** 15 elif regex_match . group ( 3 ) == "ms" : period = float ( regex_match . group ( 1 ) ) * 10 ** 12 elif regex_match . group ( 3 ) == "us" : period = float ( regex_match . group ( 1 ) ) * 10 ** 9 elif regex_match . group ( 3 ) == "ns" : period = float ( regex_match . group ( 1 ) ) * 10 ** 6 elif regex_match . group ( 3 ) == "ps" : period = float ( regex_match . group ( 1 ) ) * 10 ** 3 else : period = float ( regex_match . group ( 1 ) ) if period > largest_period : largest_period = period largest_clock = clock . name testbench = include . replace_in_testbenches ( testbench , "SONAR_VECTOR_CLOCK" , largest_clock ) return testbench
Create clocks used in the testbench
Create clocks used in the testbench
"""
    Create clocks used in the testbench

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

    Returns:
        str: Updated testbench
    """ # TODO make the initial state of the clock configurable (i.e. for diff. clocks)
None
str
testbench_config
The testbench configuration
The testbench configuration
testbench
The testbench being generated
The testbench being generated