sonar/core/backends/sv.py
def instantiate_dut(testbench_config, testbench):
    """
    Instantiate the device-under-test

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

    Returns:
        str: Updated testbench
    """
    # pylint: disable=too-many-locals
    dut = testbench_config.modules["DUT"]
    clocks_in = dut.ports.get_clocks("input")
    signals_in = dut.ports.get_signals("input")
    resets_in = dut.ports.get_resets("input")
    signals_out = dut.ports.get_signals("output")
    parameters = testbench_config.get_from_dut("parameters")
    interfaces = testbench_config.get_from_dut("interfaces")

    dut_inst = ""
    leading_spaces = include.get_indentation("SONAR_DUT_INST", testbench)
    module_name = testbench_config.metadata["Module_Name"]
    if parameters:
        dut_inst += testbench_config.metadata["Module_Name"] + " #(\n"
        for parameter in parameters[:-1]:
            dut_inst += f"{leading_spaces}{include.TAB_SIZE}.{parameter[0]}({str(parameter[1])}),\n"
        dut_inst += f"{leading_spaces}{include.TAB_SIZE}.{parameters[-1][0]}({str(parameters[-1][1])})\n"
        dut_inst += f"{leading_spaces}) {module_name}_i (\n"
    else:
        dut_inst += f"{module_name} {module_name}_i (\n"
    for signal in itertools.chain(clocks_in, resets_in):
        dut_inst += f"{leading_spaces}{include.TAB_SIZE}.{signal.name}({signal.name}),\n"
    dut_type = testbench_config.modules["DUT"].type
    for signal in itertools.chain(signals_in, signals_out):
        port_name = modify_signal_name(signal.name, dut_type)
        dut_inst += (
            f"{leading_spaces}{include.TAB_SIZE}.{port_name}({signal.name}),\n"
        )
    for interface in interfaces:
        for signal_type, signal in interface.signals.items():
            dut_inst += (
                leading_spaces
                + include.TAB_SIZE
                + "."
                + interface.name
                + "_"
                + signal.name
                + "("
                + interface.name
                + "_"
                + signal_type
                + "),\n"
            )
    dut_inst = dut_inst[:-2] + "\n"
    dut_inst += leading_spaces + ");"
    testbench = include.replace_in_testbenches(
        testbench, "SONAR_DUT_INST", dut_inst
    )

    return testbench

    Instantiate the device-under-test

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

    Returns:
        str: Updated testbench
    
Instantiate the device-under-test
Instantiate the device - under - test
def instantiate_dut(testbench_config, testbench):
    dut = testbench_config.modules["DUT"]
    clocks_in = dut.ports.get_clocks("input")
    signals_in = dut.ports.get_signals("input")
    resets_in = dut.ports.get_resets("input")
    signals_out = dut.ports.get_signals("output")
    parameters = testbench_config.get_from_dut("parameters")
    interfaces = testbench_config.get_from_dut("interfaces")
    dut_inst = ""
    leading_spaces = include.get_indentation("SONAR_DUT_INST", testbench)
    module_name = testbench_config.metadata["Module_Name"]
    if parameters:
        dut_inst += testbench_config.metadata["Module_Name"] + " #(\n"
        for parameter in parameters[:-1]:
            dut_inst += f"{leading_spaces}{include.TAB_SIZE}.{parameter[0]}({str(parameter[1])}),\n"
        dut_inst += f"{leading_spaces}{include.TAB_SIZE}.{parameters[-1][0]}({str(parameters[-1][1])})\n"
        dut_inst += f"{leading_spaces}) {module_name}_i (\n"
    else:
        dut_inst += f"{module_name} {module_name}_i (\n"
    for signal in itertools.chain(clocks_in, resets_in):
        dut_inst += f"{leading_spaces}{include.TAB_SIZE}.{signal.name}({signal.name}),\n"
    dut_type = testbench_config.modules["DUT"].type
    for signal in itertools.chain(signals_in, signals_out):
        port_name = modify_signal_name(signal.name, dut_type)
        dut_inst += (
            f"{leading_spaces}{include.TAB_SIZE}.{port_name}({signal.name}),\n"
        )
    for interface in interfaces:
        for signal_type, signal in interface.signals.items():
            dut_inst += (
                leading_spaces
                + include.TAB_SIZE
                + "."
                + interface.name
                + "_"
                + signal.name
                + "("
                + interface.name
                + "_"
                + signal_type
                + "),\n"
            )
    dut_inst = dut_inst[:-2] + "\n"
    dut_inst += leading_spaces + ");"
    testbench = include.replace_in_testbenches(
        testbench, "SONAR_DUT_INST", dut_inst
    )
    return testbench
def instantiate_dut ( testbench_config , testbench ) : dut = testbench_config . modules [ "DUT" ] clocks_in = dut . ports . get_clocks ( "input" ) signals_in = dut . ports . get_signals ( "input" ) resets_in = dut . ports . get_resets ( "input" ) signals_out = dut . ports . get_signals ( "output" ) parameters = testbench_config . get_from_dut ( "parameters" ) interfaces = testbench_config . get_from_dut ( "interfaces" ) dut_inst = "" leading_spaces = include . get_indentation ( "SONAR_DUT_INST" , testbench ) module_name = testbench_config . metadata [ "Module_Name" ] if parameters : dut_inst += testbench_config . metadata [ "Module_Name" ] + " #(\n" for parameter in parameters [ : - 1 ] : dut_inst += f"{leading_spaces}{include.TAB_SIZE}.{parameter[0]}({str(parameter[1])}),\n" dut_inst += f"{leading_spaces}{include.TAB_SIZE}.{parameters[-1][0]}({str(parameters[-1][1])})\n" dut_inst += f"{leading_spaces}) {module_name}_i (\n" else : dut_inst += f"{module_name} {module_name}_i (\n" for signal in itertools . chain ( clocks_in , resets_in ) : dut_inst += f"{leading_spaces}{include.TAB_SIZE}.{signal.name}({signal.name}),\n" dut_type = testbench_config . modules [ "DUT" ] . type for signal in itertools . chain ( signals_in , signals_out ) : port_name = modify_signal_name ( signal . name , dut_type ) dut_inst += ( f"{leading_spaces}{include.TAB_SIZE}.{port_name}({signal.name}),\n" ) for interface in interfaces : for signal_type , signal in interface . signals . items ( ) : dut_inst += ( leading_spaces + include . TAB_SIZE + "." + interface . name + "_" + signal . name + "(" + interface . name + "_" + signal_type + "),\n" ) dut_inst = dut_inst [ : - 2 ] + "\n" dut_inst += leading_spaces + ");" testbench = include . replace_in_testbenches ( testbench , "SONAR_DUT_INST" , dut_inst ) return testbench
Instantiate the device-under-test
Instantiate the device - under - test
"""
    Instantiate the device-under-test

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

    Returns:
        str: Updated testbench
    """ # pylint: disable=too-many-locals
None
str
testbench_config
The testbench configuration
The testbench configuration
testbench
The testbench being generated
The testbench being generated