Coverage for tsfpga/test/functional/commercial_simulators/test_simulation.py: 0%

25 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2022-11-29 20:01 +0000

1# -------------------------------------------------------------------------------------------------- 

2# Copyright (c) Lukas Vik. All rights reserved. 

3# 

4# This file is part of the tsfpga project, a project platform for modern FPGA development. 

5# https://tsfpga.com 

6# https://gitlab.com/tsfpga/tsfpga 

7# -------------------------------------------------------------------------------------------------- 

8 

9# Standard libraries 

10import os 

11import sys 

12 

13# Third party libraries 

14import pytest 

15 

16# First party libraries 

17import tsfpga 

18from tsfpga.system_utils import run_command 

19 

20 

21@pytest.mark.parametrize("vunit_simulator", ["modelsim", "rivierapro", "ghdl"]) 

22def test_hdl_compilation(vunit_simulator, tmp_path): 

23 """ 

24 Compile all the HDL code, no Vivado involvement. This is a subset of 'test_hdl_test_cases', 

25 but is much faster. 

26 """ 

27 command = [ 

28 sys.executable, 

29 str(tsfpga.TSFPGA_EXAMPLES / "simulate.py"), 

30 "--output-path", 

31 str(tmp_path / "vunit_out"), 

32 "--vivado-skip", 

33 "--compile", 

34 ] 

35 

36 env = os.environ.copy() 

37 env["VUNIT_SIMULATOR"] = vunit_simulator 

38 

39 run_command(cmd=command, cwd=str(tmp_path), env=env) 

40 

41 

42@pytest.mark.parametrize("vunit_simulator", ["modelsim", "rivierapro", "ghdl"]) 

43def test_hdl_test_cases(vunit_simulator, tmp_path): 

44 """ 

45 Compile all the HDL code and run all tests that do not contain IP cores. No Vivado involvement. 

46 """ 

47 # Only one license seat for Modelsim and Riviera-PRO 

48 num_threads = 1 if vunit_simulator != "ghdl" else 12 

49 command = [ 

50 sys.executable, 

51 str(tsfpga.TSFPGA_EXAMPLES / "simulate.py"), 

52 "--output-path", 

53 str(tmp_path / "vunit_out"), 

54 "--vivado-skip", 

55 "--num-threads", 

56 str(num_threads), 

57 ] 

58 

59 env = os.environ.copy() 

60 env["VUNIT_SIMULATOR"] = vunit_simulator 

61 

62 run_command(cmd=command, cwd=str(tmp_path), env=env) 

63 

64 

65@pytest.mark.parametrize("vunit_simulator", ["modelsim", "rivierapro", "ghdl"]) 

66def test_simlib_compilation_and_ip_core_test_cases(vunit_simulator, tmp_path): 

67 """ 

68 Compile simlib and generate IP core files. Run the test cases that depend on IP cores. 

69 For GHDL, no tests will be run (but simlib and IP cores will be handled). 

70 """ 

71 test_filter = "module_with_ip_cores.*" 

72 command = [ 

73 sys.executable, 

74 str(tsfpga.TSFPGA_EXAMPLES / "simulate.py"), 

75 "--output-path", 

76 str(tmp_path / "vunit_out"), 

77 "--output-path-vivado", 

78 str(tmp_path), 

79 "--minimal", 

80 test_filter, 

81 ] 

82 

83 env = os.environ.copy() 

84 env["VUNIT_SIMULATOR"] = vunit_simulator 

85 

86 run_command(cmd=command, cwd=str(tmp_path), env=env)