sonar/core/backends/cpp.py
def declare_signals(testbench_config, testbench):
    """
    Declare and instantiate the variables used for the signals in the testbench

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

    Returns:
        str: Updated testbench
    """
    dut = testbench_config.modules["DUT"]
    signals = dut.ports.get_signals()
    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 signal in signals:
        # TODO fix leading spaces on first entry
        tb_signal_list += (
            leading_spaces
            + "ap_uint<"
            + str(signal.size)
            + "> "
            + signal.name
            + ";\n"
        )
        if int(signal.size) > max_signal_size:
            max_signal_size = int(signal.size)
    for interface in interfaces:
        if isinstance(interface, AXI4LiteSlave):
            data_width_c = interface.get_signal("wdata").size
            for regs in interface.registers:
                tb_signal_list += (
                    leading_spaces + f"ap_uint<{data_width_c}> {regs};\n"
                )
        elif isinstance(interface, AXI4Stream):
            tb_signal_list += (
                leading_spaces
                + interface.iClass
                + " "
                + interface.name
                + ";\n"
            )
            tb_signal_list += (
                leading_spaces
                + interface.flit
                + " "
                + interface.name
                + "_flit;\n"
            )
    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 and instantiate the variables used for the signals in the testbench

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

    Returns:
        str: Updated testbench
    
Declare and instantiate the variables used for the signals in the testbench
Declare and instantiate the variables used for the signals in the testbench
def declare_signals(testbench_config, testbench):
    dut = testbench_config.modules["DUT"]
    signals = dut.ports.get_signals()
    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 signal in signals:
        tb_signal_list += (
            leading_spaces
            + "ap_uint<"
            + str(signal.size)
            + "> "
            + signal.name
            + ";\n"
        )
        if int(signal.size) > max_signal_size:
            max_signal_size = int(signal.size)
    for interface in interfaces:
        if isinstance(interface, AXI4LiteSlave):
            data_width_c = interface.get_signal("wdata").size
            for regs in interface.registers:
                tb_signal_list += (
                    leading_spaces + f"ap_uint<{data_width_c}> {regs};\n"
                )
        elif isinstance(interface, AXI4Stream):
            tb_signal_list += (
                leading_spaces
                + interface.iClass
                + " "
                + interface.name
                + ";\n"
            )
            tb_signal_list += (
                leading_spaces
                + interface.flit
                + " "
                + interface.name
                + "_flit;\n"
            )
    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" ] signals = dut . ports . get_signals ( ) 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 signal in signals : tb_signal_list += ( leading_spaces + "ap_uint<" + str ( signal . size ) + "> " + signal . name + ";\n" ) if int ( signal . size ) > max_signal_size : max_signal_size = int ( signal . size ) for interface in interfaces : if isinstance ( interface , AXI4LiteSlave ) : data_width_c = interface . get_signal ( "wdata" ) . size for regs in interface . registers : tb_signal_list += ( leading_spaces + f"ap_uint<{data_width_c}> {regs};\n" ) elif isinstance ( interface , AXI4Stream ) : tb_signal_list += ( leading_spaces + interface . iClass + " " + interface . name + ";\n" ) tb_signal_list += ( leading_spaces + interface . flit + " " + interface . name + "_flit;\n" ) 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 and instantiate the variables used for the signals in the testbench
Declare and instantiate the variables used for the signals in the testbench
"""
    Declare and instantiate the variables used for the signals in the testbench

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

    Returns:
        str: Updated testbench
    """ # TODO fix leading spaces on first entry
None
str
testbench_config
The testbench configuration
The testbench configuration
testbench
The testbench being generated
The testbench being generated