sonar/core/backends/sv.py
def declare_signals(testbench_config, testbench):
    """
    Declare all signals used to connect to the DUT

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

    Returns:
        str: Updated testbench
    """
    dut = testbench_config.modules["DUT"]
    clocks_in = dut.ports.get_clocks("input")
    signals = dut.ports.get_signals()
    resets = dut.ports.get_resets()
    interfaces = testbench_config.get_from_dut("interfaces")

    tb_signal_list = ""
    max_signal_size = 0
    leading_spaces = include.get_indentation("SONAR_TB_SIGNAL_LIST", testbench)
    for clock in clocks_in:
        if tb_signal_list != "":
            tb_signal_list += leading_spaces
        tb_signal_list += "logic " + clock.name + ";\n"
    for signal in itertools.chain(signals, resets):
        if int(signal.size) == 1:
            tb_signal_list += leading_spaces + "logic " + signal.name + ";\n"
        else:
            tb_signal_list += (
                leading_spaces
                + "logic ["
                + str(int(signal.size) - 1)
                + ":0] "
                + signal.name
                + ";\n"
            )
        if int(signal.size) > max_signal_size:
            max_signal_size = int(signal.size)
    for interface in interfaces:
        for signal_type, signal in interface.signals.items():
            if int(signal.size) == 1:
                tb_signal_list += (
                    leading_spaces
                    + "logic "
                    + interface.name
                    + "_"
                    + signal_type
                    + ";\n"
                )
            else:
                tb_signal_list += (
                    leading_spaces
                    + "logic ["
                    + str(int(signal.size) - 1)
                    + ":0] "
                    + interface.name
                    + "_"
                    + signal_type
                    + ";\n"
                )
            if int(signal.size) > max_signal_size:
                max_signal_size = int(signal.size)
    testbench = include.replace_in_testbenches(
        testbench, "SONAR_TB_SIGNAL_LIST", tb_signal_list[:-1]
    )
    testbench = include.replace_in_testbenches(
        testbench, "SONAR_MAX_DATA_SIZE", max_signal_size
    )
    return testbench

    Declare all signals used to connect to the DUT

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

    Returns:
        str: Updated testbench
    
Declare all signals used to connect to the DUT
Declare all signals used to connect to the DUT
def declare_signals(testbench_config, testbench):
    dut = testbench_config.modules["DUT"]
    clocks_in = dut.ports.get_clocks("input")
    signals = dut.ports.get_signals()
    resets = dut.ports.get_resets()
    interfaces = testbench_config.get_from_dut("interfaces")
    tb_signal_list = ""
    max_signal_size = 0
    leading_spaces = include.get_indentation("SONAR_TB_SIGNAL_LIST", testbench)
    for clock in clocks_in:
        if tb_signal_list != "":
            tb_signal_list += leading_spaces
        tb_signal_list += "logic " + clock.name + ";\n"
    for signal in itertools.chain(signals, resets):
        if int(signal.size) == 1:
            tb_signal_list += leading_spaces + "logic " + signal.name + ";\n"
        else:
            tb_signal_list += (
                leading_spaces
                + "logic ["
                + str(int(signal.size) - 1)
                + ":0] "
                + signal.name
                + ";\n"
            )
        if int(signal.size) > max_signal_size:
            max_signal_size = int(signal.size)
    for interface in interfaces:
        for signal_type, signal in interface.signals.items():
            if int(signal.size) == 1:
                tb_signal_list += (
                    leading_spaces
                    + "logic "
                    + interface.name
                    + "_"
                    + signal_type
                    + ";\n"
                )
            else:
                tb_signal_list += (
                    leading_spaces
                    + "logic ["
                    + str(int(signal.size) - 1)
                    + ":0] "
                    + interface.name
                    + "_"
                    + signal_type
                    + ";\n"
                )
            if int(signal.size) > max_signal_size:
                max_signal_size = int(signal.size)
    testbench = include.replace_in_testbenches(
        testbench, "SONAR_TB_SIGNAL_LIST", tb_signal_list[:-1]
    )
    testbench = include.replace_in_testbenches(
        testbench, "SONAR_MAX_DATA_SIZE", max_signal_size
    )
    return testbench
def declare_signals ( testbench_config , testbench ) : dut = testbench_config . modules [ "DUT" ] clocks_in = dut . ports . get_clocks ( "input" ) signals = dut . ports . get_signals ( ) resets = dut . ports . get_resets ( ) interfaces = testbench_config . get_from_dut ( "interfaces" ) tb_signal_list = "" max_signal_size = 0 leading_spaces = include . get_indentation ( "SONAR_TB_SIGNAL_LIST" , testbench ) for clock in clocks_in : if tb_signal_list != "" : tb_signal_list += leading_spaces tb_signal_list += "logic " + clock . name + ";\n" for signal in itertools . chain ( signals , resets ) : if int ( signal . size ) == 1 : tb_signal_list += leading_spaces + "logic " + signal . name + ";\n" else : tb_signal_list += ( leading_spaces + "logic [" + str ( int ( signal . size ) - 1 ) + ":0] " + signal . name + ";\n" ) if int ( signal . size ) > max_signal_size : max_signal_size = int ( signal . size ) for interface in interfaces : for signal_type , signal in interface . signals . items ( ) : if int ( signal . size ) == 1 : tb_signal_list += ( leading_spaces + "logic " + interface . name + "_" + signal_type + ";\n" ) else : tb_signal_list += ( leading_spaces + "logic [" + str ( int ( signal . size ) - 1 ) + ":0] " + interface . name + "_" + signal_type + ";\n" ) if int ( signal . size ) > max_signal_size : max_signal_size = int ( signal . size ) testbench = include . replace_in_testbenches ( testbench , "SONAR_TB_SIGNAL_LIST" , tb_signal_list [ : - 1 ] ) testbench = include . replace_in_testbenches ( testbench , "SONAR_MAX_DATA_SIZE" , max_signal_size ) return testbench
Declare all signals used to connect to the DUT
Declare all signals used to connect to the DUT
"""
    Declare all signals used to connect to the DUT

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

    Returns:
        str: Updated testbench
    """
None
str
testbench_config
The testbench configuration
The testbench configuration
testbench
The testbench being generated
The testbench being generated