| summaryrefslogtreecommitdiff | 
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2017-07-25 16:58:51 +0200 | 
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2017-07-25 16:58:51 +0200 | 
| commit | 54bb34b819c314f2274d560bb50cb1afaeedfa84 (patch) | |
| tree | 18941d5dd4e3f1d29248a8b20b61104729af0916 | |
| parent | d2289b32c2602f9c64d25a80e54e56dee233448a (diff) | |
Removes instr-scripts.
| -rw-r--r-- | instr-scripts/Makefile | 33 | ||||
| -rw-r--r-- | instr-scripts/__init__.py | 0 | ||||
| -rw-r--r-- | instr-scripts/id_manager.py | 88 | ||||
| -rw-r--r-- | instr-scripts/process_internals.py | 651 | ||||
| -rwxr-xr-x | instr-scripts/structural_level.py | 1379 | ||||
| -rw-r--r-- | instr-scripts/waveform_manager.py | 34 | 
6 files changed, 0 insertions, 2185 deletions
| diff --git a/instr-scripts/Makefile b/instr-scripts/Makefile deleted file mode 100644 index 43db096..0000000 --- a/instr-scripts/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -################################################################################ -## LOCAL CONF ################################################################## -################################################################################ -AST_FILE = ../data/ast/best_chronometer_ever.xml - -PYTHON_EXEC = python3 - -## Structural Level -SL_INST_FILE = structural.mod -SL_EXTRA_FILE = system_extra.txt - -################################################################################ -## PROGRAM FILES ############################################################### -################################################################################ -UTIL_LIBS = id_manager.py waveform_manager.py process_internals.py -SL_LEVEL_GEN = structural_level.py - -#EXTRA_SL_PARSER = sl_extra.py -################################################################################ -GLOBAL_DEPS = $(UTIL_LIBS) $(AST_FILE) - -$(SL_INST_FILE): $(SL_LEVEL_GEN) $(GLOBAL_DEPS) -	$(PYTHON_EXEC) $(SL_LEVEL_GEN) \ -		-i $(AST_FILE) \ -		-io $(SL_INST_FILE) \ -		-eo $(SL_EXTRA_FILE) - -export: -	scp \ -		__init__.py Makefile \ -		$(UTIL_LIBS) \ -		$(SL_LEVEL_GEN) \ -		dreamhost:~/noot-noot/onera_2017/scripts/ diff --git a/instr-scripts/__init__.py b/instr-scripts/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/instr-scripts/__init__.py +++ /dev/null diff --git a/instr-scripts/id_manager.py b/instr-scripts/id_manager.py deleted file mode 100644 index 27c1474..0000000 --- a/instr-scripts/id_manager.py +++ /dev/null @@ -1,88 +0,0 @@ -class Id_Manager: -    def __init__ (self, output_file, starting_index): -        self.output = output_file -        self.next_id = starting_index -        self.xml_to_id = dict() -        self.id_to_xml = dict() -        self.string_to_id = dict() -        self.id_to_string = dict() - -    def generate_new_pure_id (self): -        result = str(self.next_id) -        self.next_id += 1 - -        self.output.write( -            "(map_xml_id PURE " -            + result -            + ")\n" -        ) - -        return result - -    def generate_new_id (self, xml_id): -        result = str(self.next_id) -        self.next_id += 1 -        self.xml_to_id[xml_id] = result -        self.id_to_xml[result] = xml_id - -        self.output.write( -            "(map_xml_id " -            + xml_id -            + " " -            + result -            + ")\n" -        ) - -        return result - -    def generate_new_id_for_string (self, string): -        result = str(self.next_id) -        self.next_id += 1 -        self.string_to_id[string] = result -        self.id_to_string[result] = string - -        self.output.write( -            "(map_string \"" -            + string -            + "\" " -            + result -            + ")\n" -        ) - -        return result - -    def get_id_from_string (self, string): -        result = self.string_to_id.get(string) - -        if (result == None): -            return self.generate_new_id_for_string(string) -        else: -            return result - -    def get_string_from_id (self, tid): -        return self.string_from_id[tid] - -    def get_id_from_xml (self, xml_id): -        result = self.xml_to_id.get(xml_id) - -        if (result == None): -            return self.generate_new_id(xml_id) -        else: -            return result - -    def get_xml_from_id (self, tid): -        return self.id_to_xml.get(tid) - -    def force_id_association (self, xml_id, tid): -        self.xml_to_id[xml_id] = tid -        self.id_to_xml[tid] = xml_id - -    def set_next_id (self, next_id): -        self.next_id = next_id - -    def finalize (self): -        self.output.write( -            "(is_next_id " -            + str(self.next_id) -            + ")\n" -        ) diff --git a/instr-scripts/process_internals.py b/instr-scripts/process_internals.py deleted file mode 100644 index c7d4e82..0000000 --- a/instr-scripts/process_internals.py +++ /dev/null @@ -1,651 +0,0 @@ -def is_function_or_literal ( -    root, -    ref -): -    source = root.find(".//el[@id=\"" + ref + "\"]") - -    if (source == None): -        return True -    elif (source.attrib.get("kind") == "function_declaration"): -        return True -    elif (source.attrib.get("kind") == "enumeration_literal"): -        return True - -    return False - -def new_element_from_xml ( -    inst_list_output, -    id_manager, -    etype, -    xml_id -): -    result = id_manager.get_id_from_xml(xml_id) - -    inst_list_output.write("(add_element " + etype + " " + result + ")\n") - -    return result - -def new_element_from_string ( -    inst_list_output, -    id_manager, -    string -): -    result = id_manager.get_id_from_string(string) - -    inst_list_output.write("(add_element string " + result + ")\n") - -    return result - -def new_element ( -    inst_list_output, -    id_manager, -    etype -): -    result = id_manager.generate_new_pure_id() - -    inst_list_output.write("(add_element " + etype + " " + result + ")\n") - -    return result - -class Process_Internals: -    def __init__ (self, root, xml, id_manager, wfm_manager, process_id, output): -        self.xml = xml -        self.xml_root = root -        self.id_manager = id_manager -        self.wfm_manager = wfm_manager -        self.output = output -        self.process_id = process_id - -    def parse (self): -        start = self.xml.find("./sequential_statement_chain") - -        last_nodes = self.handle_sequential_statement_chain( -            start, -            [], -            0, -            [] -        ) - -        final_node_id = new_element(self.output, self.id_manager, "node") - -        for ln in last_nodes: -            self.output.write( -                "(node_connect " -                + ln -                + " " -                + final_node_id -                + ")\n" -            ) - - - -    def handle_sequential_statement_chain ( -        self, -        xml, -        prev_nodes, -        node_depth, -        extra_attributes -    ): -        instructions = xml.findall("./el") - -        for el in instructions: -            el_kind = el.attrib.get("kind") - -            if (el_kind == "if_statement"): -                prev_nodes = self.handle_if_node( -                    el, -                    prev_nodes, -                    node_depth, -                    extra_attributes -                ) -            elif (el_kind == "simple_signal_assignment_statement"): -                prev_nodes = self.handle_signal_assignment_node( -                    el, -                    prev_nodes, -                    node_depth, -                    extra_attributes -                ) -            elif (el_kind == "case_statement"): -                prev_nodes = self.handle_case_node( -                    el, -                    prev_nodes, -                    node_depth, -                    extra_attributes -                ) -            else: -                raise Exception ( -                    "Unimplemented instruction kind \"" -                    + el_kind -                    + "\"" -                ) - -            extra_attributes = [] - -        return prev_nodes - - -    def handle_if_node (self, xml, prev_nodes, node_depth, extra_attributes): -        cond_node_id = new_element(self.output, self.id_manager, "node") - -        ## FIXME: That's a dirty hack. -        if (self.process_id != None): -            self.output.write( -                "(is_start_node " -                + cond_node_id -                + " " -                + self.process_id -                + ")\n" -            ) -            self.process_id = None - -        for pn in prev_nodes: -            self.output.write( -                "(node_connect " -                + pn -                + " " -                + cond_node_id -                + ")\n" -            ) - -        cond_node_xml = xml.find("./condition") - -        sources_xml = cond_node_xml.findall( -            ".//named_entity" -        ) - -        for src_xml in sources_xml: -            ref = src_xml.attrib.get("ref") - -            if (is_function_or_literal(self.xml_root, ref)): -                print( -                    "Assumed that \"" -                    + src_xml.find("./..").attrib.get("identifier") -                    + "\" is a function or literal (XML id: \"" -                    + ref -                    + "\")." -                ) - -                continue - -            self.output.write( -                "(expr_reads " -                + cond_node_id -                + " " -                + self.wfm_manager.get_waveform_from_source( -                    self.id_manager.get_id_from_xml(src_xml.attrib.get("ref")) -                ) -                + ")\n" -            ) - -        #### label -        string_id = new_element_from_string( -            self.output, -            self.id_manager, -            xml.attrib.get("label") -        ) -        self.output.write( -            "(set_function label " -            + cond_node_id -            + " " -            + string_id -            + ")\n" -        ) - -        #### Expression -        # TODO - -        #### Kind -        string_id = new_element_from_string( -            self.output, -            self.id_manager, -            "IF" -        ) -        self.output.write( -            "(set_function kind " -            + cond_node_id -            + " " -            + string_id -            + ")\n" -        ) - -        #### Options -        for attr in extra_attributes: -            string_id = new_element_from_string( -                self.output, -                self.id_manager, -                attr -            ) -            self.output.write( -                "(has_option " + cond_node_id + " " + string_id  + ")\n" -            ) - -        #### Depth -        self.output.write( -            "(set_function depth " -            + cond_node_id -            + " " -            + str(node_depth + 1) -            + ")\n" -        ) - -        #### File / Line / Column -        # TODO - -        true_branch_xml = xml.find("./sequential_statement_chain") - -        exit_points = self.handle_sequential_statement_chain ( -            true_branch_xml, -            [cond_node_id], -            (node_depth + 2), -            ["COND_WAS_TRUE"] -        ) - -        false_branch_xml = xml.find("./else_clause/sequential_statement_chain") - -        if (false_branch_xml == None): -            exit_points += prev_nodes -        else: -            exit_points += self.handle_sequential_statement_chain ( -                false_branch_xml, -                [cond_node_id], -                (node_depth + 2), -                ["COND_WAS_FALSE"] -            ) - -        return exit_points - -    def handle_signal_assignment_node ( -        self, -        xml, -        prev_nodes, -        node_depth, -        extra_attributes -    ): -        node_id = new_element(self.output, self.id_manager, "node") - -        ## FIXME: That's a dirty hack. -        if (self.process_id != None): -            self.output.write( -                "(is_start_node " -                + node_id -                + " " -                + self.process_id -                + ")\n" -            ) -            self.process_id = None - -        for pn in prev_nodes: -            self.output.write( -                "(node_connect " -                + pn -                + " " -                + node_id -                + ")\n" -            ) - -        #### label -        string_id = new_element_from_string( -            self.output, -            self.id_manager, -            xml.attrib.get("label") -        ) -        self.output.write( -            "(set_function label " -            + node_id -            + " " -            + string_id -            + ")\n" -        ) - -        #### Expression -        # TODO - -        #### Kind -        string_id = new_element_from_string( -            self.output, -            self.id_manager, -            "INSTRUCTION" -        ) -        self.output.write( -            "(set_function kind " -            + node_id -            + " " -            + string_id -            + ")\n" -        ) - -        #### Options -        for attr in extra_attributes: -            string_id = new_element_from_string( -                self.output, -                self.id_manager, -                attr -            ) -            self.output.write( -                "(has_option " + node_id + " " + string_id  + ")\n" -            ) - -        #### Depth -        self.output.write( -            "(set_function depth " -            + node_id -            + " " -            + str(node_depth) -            + ")\n" -        ) - -        #### File / Line / Column -        # TODO - -        # <target kind="indexed_name" if vector -        target_xml = xml.find( -            "./target" -        ) - -        # Oddly enough, we can get a target as a ref... -        # The (hacky) solution? Find the real source. -        while (target_xml.tag == "target"): - -            if (target_xml.attrib.get("kind") == "indexed_name"): -                target_xml = target_xml.find("./prefix/named_entity") -            else: -                target_xml = target_xml.find("./named_entity") - -            target_xml = self.xml_root.find( -                ".//*[@id=\"" + target_xml.attrib.get("ref") + "\"]" -            ) - -        self.output.write( -            "(expr_writes " -            + node_id -            + " " -            + self.wfm_manager.get_waveform_from_source( -                self.id_manager.get_id_from_xml(target_xml.attrib.get("id")) -            ) -            + ")\n" -        ) - -        sources_xml = xml.findall( -            "./waveform_chain//named_entity" -        ) - -        for src_xml in sources_xml: -            ref = src_xml.attrib.get("ref") - -            if (is_function_or_literal(self.xml_root, ref)): -                print( -                    "Assumed that \"" -                    + src_xml.find("./..").attrib.get("identifier") -                    + "\" is a function or literal (XML id: \"" -                    + ref -                    + "\")." -                ) - -                continue - -            self.output.write( -                "(expr_reads " -                + node_id -                + " " -                + self.wfm_manager.get_waveform_from_source( -                    self.id_manager.get_id_from_xml(src_xml.attrib.get("ref")) -                ) -                + ")\n" -            ) - -        ## Predicates ########################################################## - -        return [node_id] - -    def handle_case_node (self, xml, prev_nodes, node_depth, extra_attributes): -        cond_node_id = new_element(self.output, self.id_manager, "node") - -        ## FIXME: That's a dirty hack. -        if (self.process_id != None): -            self.output.write( -                "(is_start_node " -                + cond_node_id -                + " " -                + self.process_id -                + ")\n" -            ) -            self.process_id = None - -        for pn in prev_nodes: -            self.output.write( -                "(node_connect " -                + pn -                + " " -                + cond_node_id -                + ")\n" -            ) - -        cond_node_xml = xml.find("./expression") - -        sources_xml = cond_node_xml.findall( -            ".//named_entity" -        ) - -        for src_xml in sources_xml: -            ref = src_xml.attrib.get("ref") - -            if (is_function_or_literal(self.xml_root, ref)): -                print( -                    "Assumed that \"" -                    + src_xml.find("./..").attrib.get("identifier") -                    + "\" is a function or literal (XML id: \"" -                    + ref -                    + "\")." -                ) - -                continue - -            self.output.write( -                "(expr_reads " -                + cond_node_id -                + " " -                + self.wfm_manager.get_waveform_from_source( -                    self.id_manager.get_id_from_xml(src_xml.attrib.get("ref")) -                ) -                + ")\n" -            ) - -        #### label -        string_id = new_element_from_string( -            self.output, -            self.id_manager, -            xml.attrib.get("label") -        ) -        self.output.write( -            "(set_function label " -            + cond_node_id -            + " " -            + string_id -            + ")\n" -        ) - -        #### Expression -        # TODO - -        #### Kind -        string_id = new_element_from_string( -            self.output, -            self.id_manager, -            "CASE" -        ) -        self.output.write( -            "(set_function kind " -            + cond_node_id -            + " " -            + string_id -            + ")\n" -        ) - -        #### Options -        for attr in extra_attributes: -            string_id = new_element_from_string( -                self.output, -                self.id_manager, -                attr -            ) -            self.output.write( -                "(has_option " + cond_node_id + " " + string_id  + ")\n" -            ) - -        #### Depth -        self.output.write( -            "(set_function depth " -            + cond_node_id -            + " " -            + str(node_depth + 1) -            + ")\n" -        ) - -        #### File / Line / Column -        # TODO - -        others_branch_xml = xml.find( -            "./case_statement_alternative_chain/el[@kind=\"choice_by_others\"]" -        ) - -        if (others_branch_xml == None): -            exit_points = [] -        else: -            exit_points = self.handle_when_node( -                others_branch_xml, -                [cond_node_id], -                (node_depth + 2), -                ["WHEN_OTHERS"] -            ) - -        when_branches_xml = xml.findall( -            "./case_statement_alternative_chain/el[@kind=\"choice_by_expression\"]" -        ) - -        for when_branch in when_branches_xml: -            exit_points += self.handle_when_node( -                when_branch, -                [cond_node_id], -                (node_depth + 2), -                [] -            ) - -        # Re-reading this, I doubt this is ever found. Copy/paste mistake? -#        false_branch_xml = xml.find("./else_cause/sequential_statement_chain") -# -#        if (false_branch_xml == None): -#            exit_points += prev_nodes -#        else: -#            exit_points += self.handle_sequential_statement_chain ( -#                false_branch_xml, -#                [cond_node_id], -#                (node_depth + 2), -#                ["COND_WAS_FALSE"] -#            ) - -        return exit_points - -    def handle_when_node (self, xml, prev_nodes, node_depth, extra_attributes): -        node_id = new_element(self.output, self.id_manager, "node") - -        sources_xml = xml.findall( -            "./choice_expression//named_entity" -        ) - -        for src_xml in sources_xml: -            ref = src_xml.attrib.get("ref") - -            if (is_function_or_literal(self.xml_root, ref)): -                print( -                    "Assumed that \"" -                    + src_xml.find("./..").attrib.get("identifier") -                    + "\" is a function or literal (XML id: \"" -                    + ref -                    + "\")." -                ) - -                continue - -            self.output.write( -                "(expr_reads " -                + node_id -                + " " -                + self.wfm_manager.get_waveform_from_source( -                    self.id_manager.get_id_from_xml(src_xml.attrib.get("ref")) -                ) -                + ")\n" -            ) - -        for pn in prev_nodes: -            self.output.write( -                "(node_connect " -                + pn -                + " " -                + node_id -                + ")\n" -            ) - -        #### label -        string_id = new_element_from_string( -            self.output, -            self.id_manager, -            "" -        ) -        self.output.write( -            "(set_function label " -            + node_id -            + " " -            + string_id -            + ")\n" -        ) - -        #### Expression -        # TODO - -        #### Kind -        string_id = new_element_from_string( -            self.output, -            self.id_manager, -            "WHEN" -        ) -        self.output.write( -            "(set_function kind " -            + node_id -            + " " -            + string_id -            + ")\n" -        ) - -        #### Options -        for attr in extra_attributes: -            string_id = new_element_from_string( -                self.output, -                self.id_manager, -                attr -            ) -            self.output.write( -                "(has_option " + node_id + " " + string_id  + ")\n" -            ) - -        #### Depth -        self.output.write( -            "(set_function depth " -            + node_id -            + " " -            + str(node_depth) -            + ")\n" -        ) - -        #### File / Line / Column -        # TODO - -        chain_xml = xml.find("./associated_chain") - -        exit_points = self.handle_sequential_statement_chain( -            chain_xml, -            [node_id], -            (node_depth + 1), -            ["COND_WAS_TRUE"] -        ) - -        return exit_points diff --git a/instr-scripts/structural_level.py b/instr-scripts/structural_level.py deleted file mode 100755 index 4f6f8e9..0000000 --- a/instr-scripts/structural_level.py +++ /dev/null @@ -1,1379 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -from lxml import etree - -import id_manager -import waveform_manager -import process_internals - -def is_function_or_literal ( -    root, -    ref -): -    source = root.find(".//el[@id=\"" + ref + "\"]") - -    if (source == None): -        return True -    elif (source.attrib.get("kind") == "function_declaration"): -        return True -    elif (source.attrib.get("kind") == "enumeration_literal"): -        return True - -    return False - -################################################################################ -## Types ####################################################################### -################################################################################ -def new_element_from_xml ( -    inst_list_output, -    id_manager, -    etype, -    xml_id -): -    result = id_manager.get_id_from_xml(xml_id) - -    inst_list_output.write("(add_element " + etype + "  " + result + ")\n") - -    return result - -def new_element_from_string ( -    inst_list_output, -    id_manager, -    string -): -    result = id_manager.get_id_from_string(string) - -    inst_list_output.write("(add_element string " + result + ")\n") - -    return result - -def new_element ( -    inst_list_output, -    id_manager, -    etype -): -    result = id_manager.generate_new_pure_id() - -    inst_list_output.write("(add_element " + etype + "  " + result + ")\n") - -    return result - - -################################################################################ -## Components ################################################################## -################################################################################ -def handle_port_map ( -    inst_list_output, -    extra_output, -    id_manager, -    wfm_manager, -    root, -    design_file, -    architecture, -    component, -    linked_entity, -    port_map -): -    port_map_list = port_map.findall( -        "./el[@kind=\"association_element_by_expression\"]" -    ) -    real_ports_list = linked_entity.findall( -        "./port_chain/el[@kind=\"interface_signal_declaration\"]" -    ) - -    for i in range(len(port_map_list)): -        actual_wfm = port_map_list[i].find("./actual/named_entity") -        true_port = "" - -        formal = port_map_list[i].find("./formal") - -        if (formal == None): -            ## The port is mapped using its position (i). -            inst_list_output.write( -                "(port_maps " -                + id_manager.get_id_from_xml(component.attrib.get("id")) -                + " " -                + wfm_manager.get_waveform_from_source( -                    id_manager.get_id_from_xml(actual_wfm.attrib.get("ref")) -                ) -                + " " -                + id_manager.get_id_from_xml( -                    real_ports_list[i].attrib.get("id") -                ) -                + ")\n" -            ) -        else: -            ## The port is mapped "Destination => Origin" style -            #### Find the matching port -            true_port = linked_entity.find( -                "./port_chain/el[@identifier=\"" -                + formal.attrib.get("identifier") -                + "\"]" -            ) - -            if (true_port == None): -                # TODO -                raise Exception("Could not find true port for ...") - -            inst_list_output.write( -                "(port_maps " -                + id_manager.get_id_from_xml(component.attrib.get("id")) -                + " " -                + wfm_manager.get_waveform_from_source( -                    id_manager.get_id_from_xml(actual_wfm.attrib.get("ref")) -                ) -                + " " -                + id_manager.get_id_from_xml(true_port.attrib.get("id")) -                + ")\n" -            ) - -## Component uses reference from the architecture declaration ##################  -def handle_component_internal_ref ( -    inst_list_output, -    extra_output, -    id_manager, -    wfm_manager, -    root, -    design_file, -    architecture, -    component, -    source -): -    # We have to find the associated component declaration -    ref_id = source.find("./base_name").attrib.get("ref") - -    component_declaration = architecture.find( -        "./declaration_chain/el[@kind=\"component_declaration\"][@id=\"" -        + ref_id -        + "\"]" -    ) - -    # Then find the actual referenced entity -    linked_entity = root.find( -        ".//library_unit[@kind=\"entity_declaration\"][@identifier=\"" -        + component_declaration.attrib.get("identifier") -        + "\"]" -    ) - -    if (linked_entity == None): -        print( -            "[W] Could not find entity linked to component " -            + id_manager.get_id_from_xml(component.attrib.get("id")) -            + " (XML id: \"" -            + component.attrib.get("id") -            + "\", \"" -            + component.attrib.get("label") -            + "\" from architecture \"" -            + architecture.attrib.get("identifier") -            + "\")." -        ) -        return None - -    linked_entity_id = linked_entity.attrib.get("id") - -    inst_list_output.write( -        "(is_component_of " -        + id_manager.get_id_from_xml(component.attrib.get("id")) -        + " " -        + id_manager.get_id_from_xml(linked_entity_id) -        + ")\n" -    ) - -    return linked_entity - -## Component uses the name of the other entity directly ########################  -def handle_component_external_ref ( -    inst_list_output, -    extra_output, -    id_manager, -    wfm_manager, -    root, -    design_file, -    architecture, -    component, -    source -): -    # FIXME: there's a simpler way: source->./entity_name/named_entity@ref -    entity_ref = source.find( -        "./entity_name[@kind=\"selected_name\"]" -    ) - -    library_ref = entity_ref.find( -        "./prefix[@kind=\"simple_name\"]" -    ) - -    # Then find the actual referenced entity -    linked_entity = root.find( -        "./el[@kind=\"library_declaration\"][@identifier=\"" -        + library_ref.attrib.get("identifier") -        + "\"]//library_unit[@kind=\"entity_declaration\"][@identifier=\"" -        + entity_ref.attrib.get("identifier") -        + "\"]" -    ) - -    if (linked_entity == None): -        print( -            "[W] Could not find entity linked to component " -            + id_manager.get_id_from_xml(component.attrib.get("id")) -            + " (XML id: \"" -            + component.attrib.get("id") -            + "\", \"" -            + elem.attrib.get("label") -            + "\" from architecture \"" -            + architecture.attrib.get("identifier") -            + "\"), looked for \"" -            + library_ref.attrib.get("identifier") -            + "." -            + + entity_ref.attrib.get("identifier") -            +"\"." -        ) -        return None - -    linked_entity_id = linked_entity.attrib.get("id") - -    inst_list_output.write( -        "(is_component_of " -        + id_manager.get_id_from_xml(component.attrib.get("id")) -        + " " -        + id_manager.get_id_from_xml(linked_entity_id) -        + ")\n" -    ) - -    return linked_entity - -################################################################################ -def handle_component ( -    inst_list_output, -    extra_output, -    id_manager, -    wfm_manager, -    root, -    design_file, -    architecture, -    elem -): -    xml_id = elem.attrib.get("id") - -    local_id = new_element_from_xml( -        inst_list_output, -        id_manager, -        "component", -        xml_id -    ) - -    ## Set Functions ########################################################### -    #### line -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("line") -    ) -    inst_list_output.write( -        "(set_function line " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### column -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("col") -    ) -    inst_list_output.write( -        "(set_function column " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### label -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("label") -    ) -    inst_list_output.write( -        "(set_function label " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    ## Set Unary Predicates #################################################### - -    ## Find Source ############################################################# -    source = elem.find("./instantiated_unit") - -    linked_entity = None -    #### If it is from a "component" declaration ############################### -    if (source.attrib.get("kind") == "simple_name"): -        linked_entity = handle_component_internal_ref( -            inst_list_output, -            extra_output, -            id_manager, -            wfm_manager, -            root, -            design_file, -            architecture, -            elem, -            source -        ) -    #### If it is a more direct instantiation ################################## -    elif (source.attrib.get("kind") == "entity_aspect_entity"): -        linked_entity = handle_component_external_ref( -            inst_list_output, -            extra_output, -            id_manager, -            wfm_manager, -            root, -            design_file, -            architecture, -            elem, -            source -        ) -    else: -        raise Exception ( -            "Unhandled component instantiation type for component " -            + local_id -            + " (XML id: \"" -            + xml_id -            + "\", \"" -            + elem.attrib.get("label") -            + "\" from architecture \"" -            + architecture.attrib.get("identifier") -            + "\")." -        ) - -    if (linked_entity != None): -        ## Find Mapped Ports ################################################### -        port_map = elem.find("./port_map_aspect_chain") - -        if (port_map == None): -            print( -                "[W] Component instantiation " -                + local_id -                + " (XML id: \"" -                + xml_id -                + "\", \"" -                + elem.attrib.get("label") -                + "\" from architecture \"" -                + architecture.attrib.get("identifier") -                + "\") does not have any associated port map." -            ) -        else: -            handle_port_map( -                inst_list_output, -                extra_output, -                id_manager, -                wfm_manager, -                root, -                design_file, -                architecture, -                elem, -                linked_entity, -                port_map -            ) - -    return xml_id - -################################################################################ -## PROCESSES ################################################################### -################################################################################ -def handle_process ( -    inst_list_output, -    extra_output, -    id_manager, -    wfm_manager, -    root, -    design_file, -    architecture, -    elem -): -    xml_id = elem.attrib.get("id") - -    local_id = new_element_from_xml( -        inst_list_output, -        id_manager, -        "process", -        xml_id -    ) - -    ## Set Functions ########################################################### -    #### line -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("line") -    ) -    inst_list_output.write( -        "(set_function line " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### column -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("col") -    ) -    inst_list_output.write( -        "(set_function column " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### label -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("label") -    ) -    inst_list_output.write( -        "(set_function label " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    ## Set Unary Predicates #################################################### -    if (elem.attrib.get("seen_flag") == "true"): -        inst_list_output.write("(has_seen_flag " + local_id + ")\n") - -    if (elem.attrib.get("end_has_postponed") == "true"): -        inst_list_output.write("(end_has_postponed " + local_id + ")\n") - -    if (elem.attrib.get("is_ref") == "true"): -        inst_list_output.write("(is_ref " + local_id + ")\n") -    else: -        inst_list_output.write("(is_explicit_process " + local_id + ")\n") - -    if (elem.attrib.get("passive_flag") == "true"): -        inst_list_output.write("(has_passive_flag " + local_id + ")\n") - -    if (elem.attrib.get("postponed_flag") == "true"): -        inst_list_output.write("(has_postponed_flag " + local_id + ")\n") - -    if (elem.attrib.get("visible_flag") == "true"): -        inst_list_output.write("(has_visible_flag " + local_id + ")\n") - -    if (elem.attrib.get("is_within_flag") == "true"): -        inst_list_output.write("(is_within_flag " + local_id + ")\n") - -    if (elem.attrib.get("has_label") == "true"): -        inst_list_output.write("(has_label " + local_id + ")\n") - -    if (elem.attrib.get("has_is") == "true"): -        inst_list_output.write("(has_is " + local_id + ")\n") - -    if (elem.attrib.get("end_has_reserved_id") == "true"): -        inst_list_output.write("(end_has_reserved_id " + local_id + ")\n") - -    if (elem.attrib.get("end_has_identifier") == "true"): -        inst_list_output.write("(end_has_identifier " + local_id + ")\n") - -    ## Link with Waveforms ##################################################### -    children = elem.findall( -        "./sensitivity_list/el/named_entity" -    ) -    for c in children: -        inst_list_output.write( -            "(is_in_sensitivity_list " -            + wfm_manager.get_waveform_from_source( -                id_manager.get_id_from_xml(c.attrib.get("ref")) -            ) -            + " " -            + local_id -            + ")\n" -        ) - -    children = elem.findall( -        "./sensitivity_list/el[@ref]" -    ) -    for c in children: -        inst_list_output.write( -            "(is_in_sensitivity_list " -            + wfm_manager.get_waveform_from_source( -                id_manager.get_id_from_xml(c.attrib.get("ref")) -            ) -            + " " -            + local_id -            + ")\n" -        ) - -    children = elem.findall( -        ".//*[@kind=\"simple_name\"]/named_entity" -    ) -    for c in children: -        ref = c.attrib.get("ref") - -        if (is_function_or_literal(root, ref)): -            print( -                "Assumed that \"" -                + c.find("./..").attrib.get("identifier") -                + "\" is a function or literal (XML id: \"" -                + ref -                + "\")." -            ) - -            continue - -        ref = wfm_manager.get_waveform_from_source( -                id_manager.get_id_from_xml(c.attrib.get("ref")) -            ) - -        inst_list_output.write( -            "(is_accessed_by " -            + ref -            + " " -            + local_id -            + ")\n" -        ) - -    ############################################################################ -    inst_list_output.write("\n") - -    # TODO: use 'pfp' parameter. -    pf = open(('./pfp_id_' + local_id + '.mod'), 'w') - -    internals = process_internals.Process_Internals( -        root, -        elem, -        id_manager, -        wfm_manager, -        local_id, -        pf -    ) -    internals.parse() -    pf.write("\n") -    pf.close() - -    return xml_id - -################################################################################ -## Signals ##################################################################### -################################################################################ -def handle_signal ( -    inst_list_output, -    extra_output, -    id_manager, -    wfm_manager, -    root, -    design_file, -    architecture, -    elem -): -    xml_id = elem.attrib.get("id") - -    local_id = new_element_from_xml( -        inst_list_output, -        id_manager, -        "signal", -        xml_id -    ) - -    ## Set Functions ########################################################### -    #### line -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("line") -    ) -    inst_list_output.write( -        "(set_function line " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### column -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("col") -    ) -    inst_list_output.write( -        "(set_function column " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### column -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("identifier") -    ) -    inst_list_output.write( -        "(set_function identifier " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    ## Set Unary Predicates ####################################################  -    if (elem.attrib.get("has_disconnect_flag") == "true"): -        inst_llocalist_output.write("(has_disconnect_flag " + local_id + ")\n") - -    if (elem.attrib.get("is_ref") == "true"): -        inst_list_output.write("(is_ref " + local_id + ")\n") - -    if (elem.attrib.get("has_active_flag") == "true"): -        inst_list_output.write("(has_active_flag " + local_id + ")\n") - -    if (elem.attrib.get("has_identifier_list") == "true"): -        inst_list_output.write("(has_identifier_list " + local_id + ")\n") - -    if (elem.attrib.get("visible_flag") == "true"): -        inst_list_output.write("(has_visible_flag " + local_id + ")\n") - -    if (elem.attrib.get("after_drivers_flag") == "true"): -        inst_list_output.write("(has_after_drivers_flag " + local_id + ")\n") - -    if (elem.attrib.get("use_flag") == "true"): -        inst_list_output.write("(has_use_flag " + local_id + ")\n") - -    if (elem.attrib.get("guarded_signal_flag") == "true"): -        inst_list_output.write("(has_guarded_signal_flag " + local_id + ")\n") - -    ## Set Other Predicates ####################################################  -    #### Link with Signal Kinds ################################################ -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("signal_kind").upper() -    ) -    inst_list_output.write( -        "(is_of_kind " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    inst_list_output.write("\n") - -    ## Matching Waveform ####################################################### -    #### Add Element ########################################################### -    waveform_id = wfm_manager.get_waveform_from_source(local_id) -    inst_list_output.write("(add_element waveform " + waveform_id + ")\n") - -    #### Link With Signal ###################################################### -    inst_list_output.write( -        "(is_waveform_of " -        + waveform_id -        + " " -        + local_id -        + ")\n" -    ) - -    ############################################################################ -    inst_list_output.write("\n") - -    return xml_id - -################################################################################ -## Architectures ############################################################### -################################################################################ -def handle_architecture ( -    inst_list_output, -    extra_output, -    id_manager, -    wfm_manager, -    root, -    design_file, -    elem -): -    xml_id = elem.attrib.get("id") - -    local_id = new_element_from_xml( -        inst_list_output, -        id_manager, -        "architecture", -        xml_id -    ) - -    ## Set Functions ########################################################### -    #### line -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("line") -    ) -    inst_list_output.write( -        "(set_function line " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### column -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("col") -    ) -    inst_list_output.write( -        "(set_function column " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### identifier -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("identifier") -    ) -    inst_list_output.write( -        "(set_function identifier " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    ## Set Unary Predicates #################################################### -    if (elem.attrib.get("foreign_flag") == "true"): -        inst_list_output.write("(has_foreign_flag " + local_id + ")\n") - -    if (elem.attrib.get("visible_flag") == "true"): -        inst_list_output.write("(has_visible_flag " + local_id + ")\n") - -    if (elem.attrib.get("is_within_flag") == "true"): -        inst_list_output.write("(is_within_flag " + local_id + ")\n") - -    if (elem.attrib.get("end_has_reserved_id") == "true"): -        inst_list_output.write("(end_has_reserved_id " + local_id + ")\n") - -    if (elem.attrib.get("end_has_identifier") == "true"): -        inst_list_output.write("(end_has_identifier " + local_id + ")\n") - -    ## Link to Parent ########################################################## -    inst_list_output.write( -        "(is_in_file " -        + local_id -        + " " -        + id_manager.get_id_from_xml(design_file.attrib.get("id")) -        + ")\n" -    ) - -    inst_list_output.write("\n") - -    ## Handle Children ######################################################### -    #### Internal Signals ###################################################### -    children = elem.findall( -        "./*/el[@kind=\"signal_declaration\"]" -    ) -    for c in children: -        c_id = handle_signal( -            inst_list_output, -            extra_output, -            id_manager, -            wfm_manager, -            root, -            design_file, -            elem, -            c -        ) -        inst_list_output.write( -            "(belongs_to_architecture " -            + id_manager.get_id_from_xml(c_id) -            + " " -            + local_id -            + ")\n" -        ) - -    #### Internal Processes #################################################### -    children = elem.findall( -        "./*/el[@kind=\"sensitized_process_statement\"]" -    ) -    for c in children: -        c_id = handle_process( -            inst_list_output, -            extra_output, -            id_manager, -            wfm_manager, -            root, -            design_file, -            elem, -            c -        ) -        inst_list_output.write( -            "(belongs_to_architecture " -            + id_manager.get_id_from_xml(c_id) -            + " " -            + local_id -            + ")\n" -        ) - -    #### Internal Components ################################################### -    children = elem.findall( -        "./*/el[@kind=\"component_instantiation_statement\"]" -    ) -    for c in children: -        c_id = handle_component( -            inst_list_output, -            extra_output, -            id_manager, -            wfm_manager, -            root, -            design_file, -            elem, -            c -        ) -        inst_list_output.write( -            "(belongs_to_architecture " -            + id_manager.get_id_from_xml(c_id) -            + " " -            + local_id -            + ")\n" -        ) - -    ############################################################################ -    entity = elem.find("./entity_name/named_entity") -    inst_list_output.write( -        "(is_architecture_of " -        + local_id -        + " " -        + id_manager.get_id_from_xml(entity.attrib.get("ref")) -        + ")\n" -    ) -    return xml_id - -################################################################################ -## Generic Constants ########################################################### -################################################################################ -def handle_generic ( -    inst_list_output, -    extra_output, -    id_manager, -    wfm_manager, -    root, -    design_file, -    entity, -    elem -): -    xml_id = elem.attrib.get("id") - -    local_id = new_element_from_xml( -        inst_list_output, -        id_manager, -        "generic", -        xml_id -    ) - -    ## Matching Waveform ####################################################### -    #### Add Element ########################################################### -    waveform_id = wfm_manager.get_waveform_from_source(local_id) -    inst_list_output.write("(add_element waveform " + waveform_id + ")\n") - -    #### Link With Signal ###################################################### -    inst_list_output.write( -        "(is_waveform_of " -        + waveform_id -        + " " -        + local_id -        + ")\n" -    ) - -    ## Set Functions ########################################################### -    #### line -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("line") -    ) -    inst_list_output.write( -        "(set_function line " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### column -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("col") -    ) -    inst_list_output.write( -        "(set_function column " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### identifier -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("identifier") -    ) -    inst_list_output.write( -        "(set_function identifier " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - - -    ## Set Unary Predicates #################################################### -    if (elem.attrib.get("has_class") == "true"): -        inst_list_output.write("(has_class " + local_id + ")\n") - -    if (elem.attrib.get("is_ref") == "true"): -        inst_list_output.write("(is_ref " + local_id + ")\n") - -    if (elem.attrib.get("has_identifier_list") == "true"): -        inst_list_output.write("(has_identifier_list " + local_id + ")\n") - -    if (elem.attrib.get("visible_flag") == "true"): -        inst_list_output.write("(has_visible_flag " + local_id + ")\n") - -    if (elem.attrib.get("after_drivers_flag") == "true"): -        inst_list_output.write("(has_after_drivers_flag " + local_id + ")\n") - -    if (elem.attrib.get("use_flag") == "true"): -        inst_list_output.write("(has_use_flag " + local_id + ")\n") - -    if (elem.attrib.get("guarded_signal_flag") == "true"): -        inst_list_output.write("(has_guarded_signal_flag " + local_id + ")\n") - -    ############################################################################ -    inst_list_output.write("\n") - -    return xml_id - -################################################################################ -## Ports ####################################################################### -################################################################################ -def handle_port ( -    inst_list_output, -    extra_output, -    id_manager, -    wfm_manager, -    root, -    design_file, -    entity, -    elem -): -    xml_id = elem.attrib.get("id") - -    local_id = new_element_from_xml( -        inst_list_output, -        id_manager, -        "port", -        xml_id -    ) - -    ## Set Functions ########################################################### -    #### line -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("line") -    ) -    inst_list_output.write( -        "(set_function line " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### column -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("col") -    ) -    inst_list_output.write( -        "(set_function column " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### identifier -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("identifier") -    ) -    inst_list_output.write( -        "(set_function identifier " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    ## Set Unary Predicates #################################################### -    if (elem.attrib.get("has_disconnect_flag") == "true"): -        inst_list_output.write("(has_disconnect_flag " + local_id + ")\n") - -    if (elem.attrib.get("has_class") == "true"): -        inst_list_output.write("(has_class " + local_id + ")\n") - -    if (elem.attrib.get("is_ref") == "true"): -        inst_list_output.write("(is_ref " + local_id + ")\n") - -    if (elem.attrib.get("has_active_flag") == "true"): -        inst_list_output.write("(has_active_flag " + local_id + ")\n") - -    if (elem.attrib.get("has_identifier_list") == "true"): -        inst_list_output.write("(has_identifier_list " + local_id + ")\n") - -    if (elem.attrib.get("visible_flag") == "true"): -        inst_list_output.write("(has_visible_flag " + local_id + ")\n") - -    if (elem.attrib.get("after_drivers_flag") == "true"): -        inst_list_output.write("(has_after_drivers_flag " + local_id + ")\n") - -    if (elem.attrib.get("use_flag") == "true"): -        inst_list_output.write("(has_use_flag " + local_id + ")\n") - -    if (elem.attrib.get("open_flag") == "true"): -        inst_list_output.write("(has_open_flag " + local_id + ")\n") - -    if (elem.attrib.get("guarded_signal_flag") == "true"): -        inst_list_output.write("(has_guarded_signal_flag " + local_id + ")\n") - -    ## Link With Signal Modes ################################################## -    if (elem.attrib.get("has_mode") == "true"): -        string_id = new_element_from_string( -            inst_list_output, -            id_manager, -            elem.attrib.get("mode").upper() -        ) -        inst_list_output.write( -            "(is_of_mode " -            + local_id -            + " " -            + string_id -            + ")\n" -        ) -    else: -        string_id = new_element_from_string( -            inst_list_output, -            id_manager, -            elem.attrib.get("NONE").upper() -        ) -        inst_list_output.write("(is_of_mode " + local_id + " " + string_id + ")\n") - -    inst_list_output.write("\n") - -    ## Matching Waveform ####################################################### -    #### Add Element ########################################################### -    wfm_id = wfm_manager.get_waveform_from_source(local_id) -    inst_list_output.write( -        "(add_element waveform " -        + wfm_id -        + ")\n" -    ) - -    #### Link With Port ######################################################## -    inst_list_output.write("(is_waveform_of " + wfm_id + " " + local_id + ")\n") - -    ############################################################################ -    inst_list_output.write("\n") - -    return xml_id - -################################################################################ -## Entities #################################################################### -################################################################################ -def handle_entity ( -    inst_list_output, -    extra_output, -    id_manager, -    wfm_manager, -    root, -    design_file, -    elem -): -    xml_id = elem.attrib.get("id") - -    local_id = new_element_from_xml( -        inst_list_output, -        id_manager, -        "entity", -        xml_id -    ) - -    ## Set Functions ########################################################### -    #### line -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("line") -    ) -    inst_list_output.write( -        "(set_function line " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### column -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("col") -    ) -    inst_list_output.write( -        "(set_function column " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    #### identifier -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("identifier") -    ) -    inst_list_output.write( -        "(set_function identifier " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) - -    ## Set Unary Predicates #################################################### -    if (elem.attrib.get("has_begin") == "true"): -        inst_list_output.write("(has_begin " + local_id + ")\n") - -    if (elem.attrib.get("visible_flag") == "true"): -        inst_list_output.write("(has_visible_flag " + local_id + ")\n") - -    if (elem.attrib.get("is_within_flag") == "true"): -        inst_list_output.write("(is_within_flag " + local_id + ")\n") - -    if (elem.attrib.get("end_has_reserved_id") == "true"): -        inst_list_output.write("(end_has_reserved_id " + local_id + ")\n") - -    if (elem.attrib.get("end_has_identifier") == "true"): -        inst_list_output.write("(end_has_identifier " + local_id + ")\n") - -    ## Link to Parent ########################################################## -    inst_list_output.write( -        "(is_in_file " -        + local_id -        + " " -        + id_manager.get_id_from_xml(design_file.attrib.get("id")) -        + ")\n" -    ) - -    inst_list_output.write("\n") - -    ## Handle Children ######################################################### -    #### Ports ################################################################# -    interfaces = elem.findall( -        "./port_chain/el[@kind=\"interface_signal_declaration\"]" -    ) -    for p in interfaces: -        p_id = handle_port( -            inst_list_output, -            extra_output, -            id_manager, -            wfm_manager, -            root, -            design_file, -            elem, -            p -        ) -        inst_list_output.write( -            "(is_port_of " -            + id_manager.get_id_from_xml(p_id) -            + " " -            + local_id -            + ")\n" -        ) - -    #### Generic Constants ##################################################### -    interfaces = elem.findall( -        "./generic_chain/el[@kind=\"interface_constant_declaration\"]" -    ) -    for g in interfaces: -        g_id = handle_generic( -            inst_list_output, -            extra_output, -            id_manager, -            wfm_manager, -            root, -            design_file, -            elem, -            g -        ) -        inst_list_output.write( -            "(is_generic_of " -            + id_manager.get_id_from_xml(g_id) -            + " " -            + local_id -            + ")\n" -        ) - -    return xml_id - -################################################################################ -## Files ####################################################################### -################################################################################ -def handle_design_file ( -    inst_list_output, -    extra_output, -    id_manager, -    wfm_manager, -    root, -    elem -): -    xml_id = elem.attrib.get("id") -    local_id = new_element_from_xml( -        inst_list_output, -        id_manager, -        "file", -        xml_id -    ) - -    ## Set Functions ########################################################### -    #### filename -    string_id = new_element_from_string( -        inst_list_output, -        id_manager, -        elem.attrib.get("file") -    ) -    inst_list_output.write( -        "(set_function filename " -        + local_id -        + " " -        + string_id -        + ")\n" -    ) -    local_id = id_manager.get_id_from_xml(xml_id) - -    ## Handle Children ######################################################### -    #### Entities ############################################################## -    children = elem.findall( -        "./*/*/library_unit[@kind=\"entity_declaration\"]" -    ) -    for c in children: -        c_id = handle_entity( -            inst_list_output, -            extra_output, -            id_manager, -            wfm_manager, -            root, -            elem, -            c -        ) - -    #### Architectures ######################################################### -    children = elem.findall( -        "./*/*/library_unit[@kind=\"architecture_body\"]" -    ) -    for c in children: -        c_id = handle_architecture( -            inst_list_output, -            extra_output, -            id_manager, -            wfm_manager, -            root, -            elem, -            c -        ) - -    ############################################################################ -    return xml_id - -################################################################################ -### MAIN ####################################################################### -################################################################################ -parser = argparse.ArgumentParser( -    description = ( -        "Generates a list of instructions to construct the Structural Level." -    ) -) - -parser.add_argument( -    '-i', -    '--input', -    type = str, -    required = True, -    help = 'AST of the system produced by GHDL (XML).' -) - -parser.add_argument( -    '-io', '--instructions-output', -    type = argparse.FileType(mode = 'w', encoding = 'UTF-8'), -    default = 'structural.mod', -    help = 'Instruction List output file (default: system.mod)', -) - -parser.add_argument( -    '-eo', '--extra-output', -    type = argparse.FileType(mode = 'w', encoding = 'UTF-8'), -    default = 'system_extra.txt', -    help = 'Extra Information output file (default: system_extra.txt)', -) - -parser.add_argument( -    '-pfp', -    '--process-files-prefix', -    type = str, -    default = "./process_instr_", -    help = 'Resulting process description files: this + their ID + ".mod".' -) - -args = parser.parse_args() - -xmltree = etree.parse(args.input) - -xmlroot = xmltree.getroot() - -id_manager = id_manager.Id_Manager(args.extra_output, 0) -wfm_manager = waveform_manager.Waveform_Manager(args.extra_output, id_manager) -## Handle Libraries ############################################################ -#elements = xmlroot.findall("./*/el[@kind=\"library_declaration\"]") -#[handle_library(e, root) for e in elements] - -## Handle Files ################################################################ -elements = xmlroot.findall("./*/*/el[@kind=\"design_file\"][@file]") -[ -    handle_design_file( -        args.instructions_output, -        args.extra_output, -        id_manager, -        wfm_manager, -        xmlroot, -        e -    ) for e in elements -] - -id_manager.finalize() diff --git a/instr-scripts/waveform_manager.py b/instr-scripts/waveform_manager.py deleted file mode 100644 index e73ca2b..0000000 --- a/instr-scripts/waveform_manager.py +++ /dev/null @@ -1,34 +0,0 @@ -class Waveform_Manager: -    def __init__ (self, output_file, id_manager): -        self.output = output_file -        self.from_source = dict() -        self.to_source = dict() -        self.id_manager = id_manager - -    def generate_new_waveform (self, source_id): -        result = self.id_manager.generate_new_pure_id() -        self.from_source[source_id] = result -        self.to_source[result] = source_id - -        self.output.write( -            "(map_waveform " -            + result -            + " " -            + source_id -            + ")\n" -        ) - -        return result - -    def get_waveform_from_source (self, source_id): -        result = self.from_source.get(source_id) - -        if (result == None): -            return self.generate_new_waveform(source_id) -        else: -            return result - -    def get_source_of_waveform (self, wfm_id): -        result = self.to_source.get(wfm_id) - -        return result | 


