Coverage for tsfpga/examples/example_env.py: 0%

15 statements  

« prev     ^ index     » next       coverage.py v6.4, created at 2022-05-28 04:01 +0000

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 

9""" 

10Common functions and definitions in the example build environment. 

11""" 

12 

13import sys 

14 

15import tsfpga 

16 

17# Do PYTHONPATH insert() instead of append() to prefer any local repo checkout over any pip install 

18PATH_TO_HDL_REGISTERS = tsfpga.REPO_ROOT.parent.resolve() / "hdl_registers" 

19sys.path.insert(0, str(PATH_TO_HDL_REGISTERS)) 

20PATH_TO_VUNIT = tsfpga.REPO_ROOT.parent.parent.resolve() / "vunit" / "vunit" 

21sys.path.insert(0, str(PATH_TO_VUNIT)) 

22 

23# pylint: disable=wrong-import-order 

24from hdl_registers.register_list import Register 

25 

26from tsfpga.module import get_modules 

27 

28TSFPGA_EXAMPLES_TEMP_DIR = tsfpga.TSFPGA_GENERATED 

29 

30 

31def get_default_registers(): 

32 """ 

33 Default registers for tsfpga examples. 

34 """ 

35 registers = [ 

36 Register("config", 0, "r_w", "Configuration register."), 

37 Register( 

38 "command", 

39 1, 

40 "wpulse", 

41 "When this register is written, all '1's in the written word will be asserted for one " 

42 "clock cycle in the FPGA logic.", 

43 ), 

44 Register("status", 2, "r", "Status register."), 

45 Register( 

46 "irq_status", 

47 3, 

48 "r_wpulse", 

49 "Reading a '1' in this register means the corresponding interrupt has triggered.\n" 

50 "Writing to this register will clear the interrupts where there is a '1' in the " 

51 "written word.", 

52 ), 

53 Register( 

54 "irq_mask", 

55 4, 

56 "r_w", 

57 "A '1' in this register means that the corresponding interrupt is enabled.", 

58 ), 

59 ] 

60 return registers 

61 

62 

63def get_tsfpga_example_modules(names_include=None, names_avoid=None): 

64 """ 

65 Wrapper of the regular :func:`.get_modules`. call with correct settings for tsfpga 

66 example modules. 

67 This will include the example tsfpga modules, but not the "real" modules. 

68 

69 Arguments will be passed on to :func:`.get_modules`. 

70 """ 

71 return get_modules( 

72 modules_folders=[tsfpga.TSFPGA_EXAMPLE_MODULES], 

73 names_include=names_include, 

74 names_avoid=names_avoid, 

75 library_name_has_lib_suffix=False, 

76 default_registers=get_default_registers(), 

77 )