diff options
Diffstat (limited to 'testsuite/pyunit')
6 files changed, 51 insertions, 52 deletions
diff --git a/testsuite/pyunit/dom/StopWatch.py b/testsuite/pyunit/dom/StopWatch.py index 37b8293de..b733cd786 100644 --- a/testsuite/pyunit/dom/StopWatch.py +++ b/testsuite/pyunit/dom/StopWatch.py @@ -34,7 +34,7 @@ from pathlib import Path from unittest import TestCase from pyGHDL.dom.NonStandard import Design, Document - +from pyGHDL.dom.formatting.prettyprint import PrettyPrint if __name__ == "__main__": print("ERROR: you called a testcase declaration file as an executable module.") @@ -47,51 +47,56 @@ class Designs(TestCase): _sourceDirectory: Path = _root / "dom/examples/StopWatch" _packageFiles = ( - Path("Utilities.pkg.vhdl"), - Path("StopWatch.pkg.vhdl"), + ("lib_Utilities", Path("Utilities.pkg.vhdl")), + ("lib_Utilities", Path("Utilities.ctx.vhdl")), + ("lib_StopWatch", Path("StopWatch.pkg.vhdl")), + ("lib_StopWatch", Path("StopWatch.ctx.vhdl")), ) _encoderFiles = _packageFiles + ( - Path("seg7_Encoder.vhdl"), - Path("toplevel.Encoder.vhdl"), + ("lib_StopWatch", Path("seg7_Encoder.vhdl")), + ("lib_StopWatch", Path("toplevel.Encoder.vhdl")), ) _displayFiles = _packageFiles + ( - Path("Counter.vhdl"), - Path("seg7_Encoder.vhdl"), - Path("seg7_Display.vhdl"), - Path("toplevel.Display.vhdl"), + ("lib_StopWatch", Path("Counter.vhdl")), + ("lib_StopWatch", Path("seg7_Encoder.vhdl")), + ("lib_StopWatch", Path("seg7_Display.vhdl")), + ("lib_StopWatch", Path("toplevel.Display.vhdl")), ) _stopwatchFiles = _packageFiles + ( - Path("Counter.vhdl"), - Path("seg7_Encoder.vhdl"), - Path("seg7_Display.vhdl"), - Path("StopWatch.vhdl"), - Path("Debouncer.vhdl"), - Path("toplevel.StopWatch.vhdl"), + ("lib_Utilities", Path("Counter.vhdl")), + ("lib_StopWatch", Path("seg7_Encoder.vhdl")), + ("lib_StopWatch", Path("seg7_Display.vhdl")), + ("lib_StopWatch", Path("StopWatch.vhdl")), + ("lib_Utilities", Path("Debouncer.vhdl")), + ("lib_StopWatch", Path("toplevel.StopWatch.vhdl")), ) class Display(Designs): def test_Encoder(self): design = Design() - for file in self._encoderFiles: + for lib, file in self._encoderFiles: + library = design.GetLibrary(lib) document = Document(self._sourceDirectory / file) - design.Documents.append(document) + design.AddDocument(document, library) self.assertEqual(len(self._encoderFiles), len(design.Documents)) def test_Display(self): design = Design() - for file in self._displayFiles: + for lib, file in self._displayFiles: + library = design.GetLibrary(lib) document = Document(self._sourceDirectory / file) - design.Documents.append(document) + design.AddDocument(document, library) self.assertEqual(len(self._displayFiles), len(design.Documents)) def test_StopWatch(self): design = Design() - for file in self._stopwatchFiles: + for lib, file in self._stopwatchFiles: + library = design.GetLibrary(lib) document = Document(self._sourceDirectory / file) - design.Documents.append(document) + design.AddDocument(document, library) self.assertEqual(len(self._stopwatchFiles), len(design.Documents)) @@ -101,9 +106,16 @@ class CompileOrder(Designs): design = Design() design.LoadStdLibrary() design.LoadIEEELibrary() - library = design.GetLibrary("lib_StopWatch") - for file in self._encoderFiles: + for lib, file in self._encoderFiles: + library = design.GetLibrary(lib) document = Document(self._sourceDirectory / file) design.AddDocument(document, library) design.Analyze() + + PP = PrettyPrint() + buffer = [] + buffer.append("Design:") + for line in PP.formatDesign(design, 1): + buffer.append(line) + print("\n".join(buffer)) diff --git a/testsuite/pyunit/dom/examples/StopWatch/StopWatch.ctx.vhdl b/testsuite/pyunit/dom/examples/StopWatch/StopWatch.ctx.vhdl index 1a40718aa..ea66f7597 100644 --- a/testsuite/pyunit/dom/examples/StopWatch/StopWatch.ctx.vhdl +++ b/testsuite/pyunit/dom/examples/StopWatch/StopWatch.ctx.vhdl @@ -1,21 +1,11 @@ -- Author: Patrick Lehmann -- License: MIT -- --- A generic counter module used in the StopWatch example. +-- undocumented -- -library IEEE; -use IEEE.std_logic_1164.all; -use IEEE.numeric_std.all; +context StopWatch_ctx is + library lib_Utilities; + context lib_Utilities.Utilities_pkg; --- Package with stop watch specific types. -package StopWatch_pkg is - subtype T_BCD is unsigned(3 downto 0); - type T_BCD_Vector is array(natural range <>) of T_BCD; - - type T_DIGIT_CONFIGURATION is record - Modulo : positive; - Dot : std_logic; - end record; - - type T_STOPWATCH_CONFIGURATION is array(natural range <>) of T_DIGIT_CONFIGURATION; -end package; + use work.StopWatch_pkg.all; +end context; diff --git a/testsuite/pyunit/dom/examples/StopWatch/Utilities.ctx.vhdl b/testsuite/pyunit/dom/examples/StopWatch/Utilities.ctx.vhdl index e6551cffd..050682098 100644 --- a/testsuite/pyunit/dom/examples/StopWatch/Utilities.ctx.vhdl +++ b/testsuite/pyunit/dom/examples/StopWatch/Utilities.ctx.vhdl @@ -1,12 +1,12 @@ -- Author: Patrick Lehmann -- License: MIT -- --- A generic counter module used in the StopWatch example. +-- undocumented -- -context StopWatch_ctx is +context Utilities_ctx is library IEEE; use IEEE.std_logic_1164.all, IEEE.numeric_std.all; - use work.StopWatch_pkg.all; + use work.Utilities_pkg.all; end context; diff --git a/testsuite/pyunit/dom/examples/StopWatch/Utilities.pkg.vhdl b/testsuite/pyunit/dom/examples/StopWatch/Utilities.pkg.vhdl index 16a40ccba..e15048dcf 100644 --- a/testsuite/pyunit/dom/examples/StopWatch/Utilities.pkg.vhdl +++ b/testsuite/pyunit/dom/examples/StopWatch/Utilities.pkg.vhdl @@ -9,7 +9,7 @@ use IEEE.numeric_std.all; -- Useful utility functions and types. -package Utilities is +package Utilities_pkg is type freq is range integer'low to integer'high units Hz; kHz = 1000 Hz; @@ -33,7 +33,7 @@ package Utilities is end package; -package body Utilities is +package body Utilities_pkg is function simulation return boolean is variable result : boolean := FALSE; begin diff --git a/testsuite/pyunit/dom/examples/StopWatch/seg7_Encoder.vhdl b/testsuite/pyunit/dom/examples/StopWatch/seg7_Encoder.vhdl index 3742982be..88074c884 100644 --- a/testsuite/pyunit/dom/examples/StopWatch/seg7_Encoder.vhdl +++ b/testsuite/pyunit/dom/examples/StopWatch/seg7_Encoder.vhdl @@ -3,12 +3,7 @@ -- -- A generic counter module used in the StopWatch example. -- -library IEEE; -use IEEE.std_logic_1164.all; -use IEEE.numeric_std.all; - -use work.Utilities.all; -use work.StopWatch_pkg.all; +context work.StopWatch_ctx; -- Encoder that translates from 4-bit binary (BCD) to 7-segment code. diff --git a/testsuite/pyunit/dom/examples/StopWatch/toplevel.Encoder.vhdl b/testsuite/pyunit/dom/examples/StopWatch/toplevel.Encoder.vhdl index 58294b67f..de18778a0 100644 --- a/testsuite/pyunit/dom/examples/StopWatch/toplevel.Encoder.vhdl +++ b/testsuite/pyunit/dom/examples/StopWatch/toplevel.Encoder.vhdl @@ -7,8 +7,10 @@ library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; -use work.Utilities.all; -use work.StopWatch_pkg.all; +library lib_Utilities; +use lib_Utilities.Utilities_pkg.all; + +use lib_StopWatch.StopWatch_pkg.all; -- Toplevel module to demonstrate the translation of 4 slide-switches to 1 digit 7-segment display. |