Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

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

3# 

4# This file is part of the tsfpga project. 

5# https://tsfpga.com 

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

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

8 

9from unittest import TestCase 

10from unittest.mock import patch 

11 

12import pytest 

13 

14from tsfpga.yosys_project import YosysProject 

15 

16 

17@pytest.mark.usefixtures("fixture_tmp_path") 

18class TestYosysProject(TestCase): 

19 

20 top = "dummy_top" 

21 formal_settings = dict( 

22 mode="dummy_mode", 

23 depth=20, 

24 engine_command="dummy_engine_command", 

25 solver_command="dummy_solver_command", 

26 ) 

27 

28 tmp_path = None 

29 compiled_libraries = ["library_1", "library_2"] 

30 src_files = ["file_1", "file_2.vhd"] 

31 generics = dict(dummy_generic="dummy_generic_val") 

32 

33 def setUp(self): 

34 self.project_path = self.tmp_path 

35 

36 def test_can_create(self): 

37 yosys_project = YosysProject( 

38 top=self.top, generics=self.generics, formal_settings=self.formal_settings 

39 ) 

40 assert yosys_project.top == self.top 

41 assert yosys_project.generics == self.generics 

42 assert yosys_project.formal_settings == self.formal_settings 

43 

44 def test_can_create_without_generics(self): 

45 yosys_project = YosysProject(top=self.top, formal_settings=self.formal_settings) 

46 assert yosys_project.generics == dict() 

47 

48 def test_runs_symbiyosys(self): 

49 yosys_project = YosysProject( 

50 top=self.top, generics=self.generics, formal_settings=self.formal_settings 

51 ) 

52 

53 # Check run_function, but mock the subprocess 

54 with patch("tsfpga.yosys_project.Process", autospec=True): 

55 assert yosys_project.run_formal( 

56 project_path=self.project_path, 

57 src_files=self.src_files, 

58 compiled_libraries=self.compiled_libraries, 

59 ) 

60 

61 # Check that the output file was created 

62 assert (self.project_path / "run_symbiyosys.sby").exists()