sonar/core/backends/sv.py
def write_line(data_file, command, vector_id):
    """
    Write one command to the data file

    Args:
        data_file (list): List of commands to write
        command (dict): Current command being written
        vector_id (int): Index of the test vector this command belongs to

    Returns:
        list: Updated data_file
    """
    # pylint: disable=too-many-branches
    if "interface" in command:
        curr_interface = include.get_interface(command["interface"]["type"])
        line = curr_interface.write_sv(command["interface"])
        if line != "":
            data_file.append(line)
    elif "wait" in command:
        if "value" in command["wait"]:
            arg = command["wait"]["value"]
        else:
            arg = 0
        txt = "wait " + command["wait"]["key"] + " "
        if "args" in command["wait"] and command["wait"]["args"]:
            txt += str(len(command["wait"]["args"]))
            for arg in command["wait"]["args"]:
                txt += " " + str(arg)
        else:
            txt += "0"
        data_file.append(txt)
    elif "signal" in command:
        # TODO temporary hack for endpoint assignment
        if "value2" in command["signal"]:
            data_file.append(
                "signal "
                + str(command["signal"]["name"])
                + " "
                + str(2)
                + " "
                + str(command["signal"]["value"])
                + " "
                + str(command["signal"]["value2"])
            )
        else:
            data_file.append(
                "signal "
                + str(command["signal"]["name"])
                + " "
                + str(1)
                + " "
                + str(command["signal"]["value"])
            )
    elif "delay" in command:
        data_file.append(
            "delay "
            + "ns"
            + " "
            + str(1)
            + " "
            + str(command["delay"][:-2])  # TODO fix. Assumes ns
        )
    elif "display" in command:
        data_file.append(
            'display "' + str(command["display"]) + '" ' + str(1) + " " + "0"
        )
    elif "call_dut" in command:
        pass
    elif "flag" in command:
        if "set_flag" in command["flag"]:
            data_file.append(
                "flag "
                + "set"
                + " "
                + str(1)
                + " "
                + str(command["flag"]["set_flag"])
            )
        else:
            data_file.append(
                "flag "
                + "clear"
                + " "
                + str(1)
                + " "
                + str(command["flag"]["clear_flag"])
            )
    elif "timestamp" in command:
        data_file.append(
            "timestamp "
            + str(command["timestamp"])
            + " "
            + str(1)
            + " "
            + str(0)
        )
    elif "macro" in command:
        if command["macro"] == "END":
            data_file.append(
                "end "
                + "Vector_"
                + str(vector_id)
                + " "
                + str(1)
                + " "
                + str(0)
            )
        else:
            for init_command in command["commands"]:
                data_file = write_line(data_file, init_command, vector_id)
    else:
        logger.error("Unhandled packet type: %s", str(command))

    return data_file

    Write one command to the data file

    Args:
        data_file (list): List of commands to write
        command (dict): Current command being written
        vector_id (int): Index of the test vector this command belongs to

    Returns:
        list: Updated data_file
    
Write one command to the data file
Write one command to the data file
def write_line(data_file, command, vector_id):
    if "interface" in command:
        curr_interface = include.get_interface(command["interface"]["type"])
        line = curr_interface.write_sv(command["interface"])
        if line != "":
            data_file.append(line)
    elif "wait" in command:
        if "value" in command["wait"]:
            arg = command["wait"]["value"]
        else:
            arg = 0
        txt = "wait " + command["wait"]["key"] + " "
        if "args" in command["wait"] and command["wait"]["args"]:
            txt += str(len(command["wait"]["args"]))
            for arg in command["wait"]["args"]:
                txt += " " + str(arg)
        else:
            txt += "0"
        data_file.append(txt)
    elif "signal" in command:
        if "value2" in command["signal"]:
            data_file.append(
                "signal "
                + str(command["signal"]["name"])
                + " "
                + str(2)
                + " "
                + str(command["signal"]["value"])
                + " "
                + str(command["signal"]["value2"])
            )
        else:
            data_file.append(
                "signal "
                + str(command["signal"]["name"])
                + " "
                + str(1)
                + " "
                + str(command["signal"]["value"])
            )
    elif "delay" in command:
        data_file.append(
            "delay "
            + "ns"
            + " "
            + str(1)
            + " "
            + str(command["delay"][:-2])  
        )
    elif "display" in command:
        data_file.append(
            'display "' + str(command["display"]) + '" ' + str(1) + " " + "0"
        )
    elif "call_dut" in command:
        pass
    elif "flag" in command:
        if "set_flag" in command["flag"]:
            data_file.append(
                "flag "
                + "set"
                + " "
                + str(1)
                + " "
                + str(command["flag"]["set_flag"])
            )
        else:
            data_file.append(
                "flag "
                + "clear"
                + " "
                + str(1)
                + " "
                + str(command["flag"]["clear_flag"])
            )
    elif "timestamp" in command:
        data_file.append(
            "timestamp "
            + str(command["timestamp"])
            + " "
            + str(1)
            + " "
            + str(0)
        )
    elif "macro" in command:
        if command["macro"] == "END":
            data_file.append(
                "end "
                + "Vector_"
                + str(vector_id)
                + " "
                + str(1)
                + " "
                + str(0)
            )
        else:
            for init_command in command["commands"]:
                data_file = write_line(data_file, init_command, vector_id)
    else:
        logger.error("Unhandled packet type: %s", str(command))
    return data_file
def write_line ( data_file , command , vector_id ) : if "interface" in command : curr_interface = include . get_interface ( command [ "interface" ] [ "type" ] ) line = curr_interface . write_sv ( command [ "interface" ] ) if line != "" : data_file . append ( line ) elif "wait" in command : if "value" in command [ "wait" ] : arg = command [ "wait" ] [ "value" ] else : arg = 0 txt = "wait " + command [ "wait" ] [ "key" ] + " " if "args" in command [ "wait" ] and command [ "wait" ] [ "args" ] : txt += str ( len ( command [ "wait" ] [ "args" ] ) ) for arg in command [ "wait" ] [ "args" ] : txt += " " + str ( arg ) else : txt += "0" data_file . append ( txt ) elif "signal" in command : if "value2" in command [ "signal" ] : data_file . append ( "signal " + str ( command [ "signal" ] [ "name" ] ) + " " + str ( 2 ) + " " + str ( command [ "signal" ] [ "value" ] ) + " " + str ( command [ "signal" ] [ "value2" ] ) ) else : data_file . append ( "signal " + str ( command [ "signal" ] [ "name" ] ) + " " + str ( 1 ) + " " + str ( command [ "signal" ] [ "value" ] ) ) elif "delay" in command : data_file . append ( "delay " + "ns" + " " + str ( 1 ) + " " + str ( command [ "delay" ] [ : - 2 ] ) ) elif "display" in command : data_file . append ( 'display "' + str ( command [ "display" ] ) + '" ' + str ( 1 ) + " " + "0" ) elif "call_dut" in command : pass elif "flag" in command : if "set_flag" in command [ "flag" ] : data_file . append ( "flag " + "set" + " " + str ( 1 ) + " " + str ( command [ "flag" ] [ "set_flag" ] ) ) else : data_file . append ( "flag " + "clear" + " " + str ( 1 ) + " " + str ( command [ "flag" ] [ "clear_flag" ] ) ) elif "timestamp" in command : data_file . append ( "timestamp " + str ( command [ "timestamp" ] ) + " " + str ( 1 ) + " " + str ( 0 ) ) elif "macro" in command : if command [ "macro" ] == "END" : data_file . append ( "end " + "Vector_" + str ( vector_id ) + " " + str ( 1 ) + " " + str ( 0 ) ) else : for init_command in command [ "commands" ] : data_file = write_line ( data_file , init_command , vector_id ) else : logger . error ( "Unhandled packet type: %s" , str ( command ) ) return data_file
Write one command to the data file
Write one command to the data file
"""
    Write one command to the data file

    Args:
        data_file (list): List of commands to write
        command (dict): Current command being written
        vector_id (int): Index of the test vector this command belongs to

    Returns:
        list: Updated data_file
    """ # pylint: disable=too-many-branches # TODO temporary hack for endpoint assignment # TODO fix. Assumes ns
None
list
data_file
List of commands to write
List of commands to write
command
Current command being written
Current command being written
vector_id
Index of the test vector this command belongs to
Index of the test vector this command belongs to