From b5884712a4ce8980831d4b231d123688063ccbf2 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 21 Jun 2022 23:10:26 +0200 Subject: Enable and disable AMS support based on VHDLVersion. (cherry picked from commit 04d141309147a5731ea3461d59cfc8e17ad57c82) --- pyGHDL/dom/NonStandard.py | 14 +++++++++++++- pyGHDL/libghdl/flags.py | 3 +++ testsuite/pyunit/dom/Sanity.py | 5 ++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pyGHDL/dom/NonStandard.py b/pyGHDL/dom/NonStandard.py index db160faaf..13ddec68f 100644 --- a/pyGHDL/dom/NonStandard.py +++ b/pyGHDL/dom/NonStandard.py @@ -42,6 +42,8 @@ from typing import Any from pyTooling.Decorators import export +from pyGHDL.dom.Names import SimpleName +from pyVHDLModel import VHDLVersion from pyVHDLModel.SyntaxModel import ( Design as VHDLModel_Design, Library as VHDLModel_Library, @@ -50,6 +52,7 @@ from pyVHDLModel.SyntaxModel import ( ) from pyGHDL.libghdl import ( + ENCODING, initialize as libghdl_initialize, finalize as libghdl_finalize, set_option as libghdl_set_option, @@ -58,6 +61,7 @@ from pyGHDL.libghdl import ( files_map, errorout_memory, LibGHDLException, + flags, utils, files_map_editor, ENCODING, @@ -102,7 +106,6 @@ class Design(VHDLModel_Design): errorout_memory.Install_Handler() libghdl_set_option("--std=08") - libghdl_set_option("--ams") Flag_Gather_Comments.value = True Flag_Parse_Parenthesis.value = True @@ -131,6 +134,7 @@ class Document(VHDLModel_Document): self, path: Path, sourceCode: str = None, + vhdlVersion: VHDLVersion = VHDLVersion.VHDL2008, dontParse: bool = False, dontTranslate: bool = False, ): @@ -146,8 +150,16 @@ class Document(VHDLModel_Document): if not dontParse: # Parse input file t1 = time.perf_counter() + + if vhdlVersion.IsAMS(): + flags.AMS_Vhdl.value = True + self.__ghdlFile = sem_lib.Load_File(self.__ghdlSourceFileEntry) CheckForErrors() + + if vhdlVersion.IsAMS(): + flags.AMS_Vhdl.value = False + self.__ghdlProcessingTime = time.perf_counter() - t1 if not dontTranslate: diff --git a/pyGHDL/libghdl/flags.py b/pyGHDL/libghdl/flags.py index fadd3bb52..523b6c9cf 100644 --- a/pyGHDL/libghdl/flags.py +++ b/pyGHDL/libghdl/flags.py @@ -41,6 +41,7 @@ __all__ = [ "Verbose", "Flag_Elaborate_With_Outdated", "Flag_Force_Analysis", + "AMS_Vhdl", "Flag_Gather_Comments", ] @@ -54,4 +55,6 @@ Flag_Elaborate_With_Outdated = c_bool.in_dll(libghdl, "flags__flag_elaborate_wit Flag_Force_Analysis = c_bool.in_dll(libghdl, "flags__flag_force_analysis") +AMS_Vhdl = c_bool.in_dll(libghdl, "flags__ams_vhdl") + Flag_Gather_Comments = c_bool.in_dll(libghdl, "flags__flag_gather_comments") diff --git a/testsuite/pyunit/dom/Sanity.py b/testsuite/pyunit/dom/Sanity.py index 54cb4103b..4fc721d55 100644 --- a/testsuite/pyunit/dom/Sanity.py +++ b/testsuite/pyunit/dom/Sanity.py @@ -34,6 +34,7 @@ from pathlib import Path from pytest import mark +from pyVHDLModel import VHDLVersion from pyGHDL.dom.NonStandard import Design, Document @@ -55,6 +56,8 @@ def test_AllVHDLSources(parameters): id, file = parameters.split(":") filePath = _TESTSUITE_ROOT / file + vhdlVersion = VHDLVersion.AMS2017 if "ams" in file else VHDLVersion.VHDL2008 + lib = design.GetLibrary(f"sanity_{id}") - document = Document(filePath) + document = Document(filePath, vhdlVersion=vhdlVersion) design.AddDocument(document, lib) -- cgit v1.2.3