Пример #1
0
 def __init__(self, root_uri, server):
     self._root_uri = root_uri
     self._server = server
     self._root_path = lsp.path_from_uri(self._root_uri)
     self._docs = {}  # uri -> doc
     self._fe_map = {}  # fe -> doc
     self._prj = {}
     self._last_linted_doc = None
     errorout_memory.Install_Handler()
     libghdl.flags.Flag_Elocations.value = True
     # libghdl.Flags.Verbose.value = True
     # We do analysis even in case of errors.
     libghdl.vhdl.parse.Flag_Parse_Parenthesis.value = True
     # Force analysis to get more feedback + navigation even in case
     # of errors.
     libghdl.flags.Flag_Force_Analysis.value = True
     # Do not consider analysis order issues.
     libghdl.flags.Flag_Elaborate_With_Outdated.value = True
     libghdl.errorout.Enable_Warning(errorout.Msgid.Warnid_Unused, True)
     self.read_project()
     self.set_options_from_project()
     if libghdl.analyze_init_status() != 0:
         log.error("cannot initialize libghdl")
         raise InitError
     self._diags_set = set()  # Documents with at least one diagnostic.
     self.read_files_from_project()
     self.gather_diagnostics(None)
Пример #2
0
    def test_InitializeGHDL(self) -> None:
        """Initialization: set options and then load libaries."""
        libghdl.initialize()

        # Print error messages on the console.
        errorout_console.Install_Handler()

        # Set options. This must be done before analyze_init()
        libghdl.set_option("--std=08")

        # Finish initialization. This will load the standard package.
        if libghdl.analyze_init_status() != 0:
            self.fail("libghdl initialization error")

        # Load the file
        file_id = name_table.Get_Identifier(str(self._filename))
        sfe = files_map.Read_Source_File(name_table.Null_Identifier, file_id)
        if sfe == files_map.No_Source_File_Entry:
            self.fail("Cannot read file '{!s}'".format(self._filename))

        # Parse
        file = sem_lib.Load_File(sfe)

        # Display all design units
        designUnit = nodes.Get_First_Design_Unit(file)
        while designUnit != nodes.Null_Iir:
            libraryUnit = nodes.Get_Library_Unit(designUnit)

            if nodes.Get_Kind(
                    libraryUnit) == nodes.Iir_Kind.Entity_Declaration:
                entityName = self.getIdentifier(libraryUnit)
                self.assertEqual(
                    entityName,
                    "entity_1",
                    "expected entity name 'e1', got '{}'".format(entityName),
                )

            elif nodes.Get_Kind(
                    libraryUnit) == nodes.Iir_Kind.Architecture_Body:
                architectureName = self.getIdentifier(libraryUnit)
                self.assertEqual(
                    architectureName,
                    "behav",
                    "expected architecture name 'behav', got '{}'".format(
                        architectureName),
                )

            else:
                self.fail("Unknown unit.")

            designUnit = nodes.Get_Chain(designUnit)
Пример #3
0
    def __ghdl_init(self):
        """Initialization: set options and then load libraries"""
        # Initialize libghdl
        libghdl.finalize()
        libghdl.initialize()

        # Collect error messages in memory
        errorout_memory.Install_Handler()

        libghdl.set_option(b"--std=08")

        # Finish initialization. This will load the standard package.
        if libghdl.analyze_init_status() != 0:
            raise LibGHDLException("Error initializing 'libghdl'.")