コード例 #1
0
ファイル: workspace.py プロジェクト: goddess5321/ghdl
    def x_get_entity_interface(self, library, name):
        def create_interfaces(inters):
            res = []
            while inters != nodes.Null_Iir:
                res.append({
                    'name':
                    name_table.Get_Name_Ptr(
                        nodes.Get_Identifier(inters)).decode('latin-1')
                })
                inters = nodes.Get_Chain(inters)
            return res

        # Find library
        lib_id = name_table.Get_Identifier(library.encode('utf-8'))
        lib = libraries.Get_Library_No_Create(lib_id)
        if lib == name_table.Null_Identifier:
            return None
        # Find entity
        ent_id = name_table.Get_Identifier(name.encode('utf-8'))
        unit = libraries.Find_Primary_Unit(lib, ent_id)
        if unit == nodes.Null_Iir:
            return None
        ent = nodes.Get_Library_Unit(unit)
        return {
            'library': library,
            'entity': name,
            'generics': create_interfaces(nodes.Get_Generic_Chain(ent)),
            'ports': create_interfaces(nodes.Get_Port_Chain(ent))
        }
コード例 #2
0
ファイル: workspace.py プロジェクト: vanessaborja/ghdl
    def x_get_entity_interface(self, library, name):
        def create_interfaces(inters):
            res = []
            while inters != nodes.Null_Iir:
                res.append(
                    {
                        "name": name_table.Get_Name_Ptr(
                            nodes.Get_Identifier(inters)
                        ).decode("latin-1")
                    }
                )
                inters = nodes.Get_Chain(inters)
            return res

        # Find library
        lib_id = name_table.Get_Identifier(library.encode("utf-8"))
        lib = libraries.Get_Library_No_Create(lib_id)
        if lib == name_table.Null_Identifier:
            return None
        # Find entity
        ent_id = name_table.Get_Identifier(name.encode("utf-8"))
        unit = libraries.Find_Primary_Unit(lib, ent_id)
        if unit == nodes.Null_Iir:
            return None
        ent = nodes.Get_Library_Unit(unit)
        return {
            "library": library,
            "entity": name,
            "generics": create_interfaces(nodes.Get_Generic_Chain(ent)),
            "ports": create_interfaces(nodes.Get_Port_Chain(ent)),
        }
コード例 #3
0
ファイル: document.py プロジェクト: FisherG1/ghdl-1
 def load(source, dirname, filename):
     # Write text to file buffer.
     src_bytes = source.encode(Document.encoding, "replace")
     src_len = len(src_bytes)
     buf_len = src_len + Document.initial_gap_size
     fileid = name_table.Get_Identifier(filename.encode('utf-8'))
     if os.path.isabs(filename):
         dirid = name_table.Null_Identifier
     else:
         dirid = name_table.Get_Identifier(dirname.encode('utf-8'))
     sfe = files_map.Reserve_Source_File(dirid, fileid, buf_len)
     files_map_editor.Fill_Text(sfe, ctypes.c_char_p(src_bytes), src_len)
     return sfe
コード例 #4
0
def list_units(filename):
    # Load the file
    file_id = name_table.Get_Identifier(filename.encode('utf_8'))
    sfe = files_map.Read_Source_File(name_table.Null_Identifier, file_id)
    if sfe == files_map.No_Source_File_Entry:
        print("cannot open file '{}'".format(filename))
        return

    # Parse and analyze
    file = sem_lib.Load_File(sfe)

    # Display all design units
    unit = nodes.Get_First_Design_Unit(file)
    while unit != nodes.Null_Iir:
        lib_unit = nodes.Get_Library_Unit(unit)
        if nodes.Get_Kind(lib_unit) == nodes.Iir_Kind.Entity_Declaration:
            print('entity {}'.format(get_identifier_ptr(lib_unit)))
        elif nodes.Get_Kind(lib_unit) == nodes.Iir_Kind.Architecture_Body:
            print('architecture {}'.format(get_identifier_ptr(lib_unit)))
        else:
            print('unknown unit!')
        unit = nodes.Get_Chain(unit)