Coverage for hdl_registers/generator/vhdl/axi_lite/test/test_wrapper.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.6.8, created at 2024-12-01 20:50 +0000

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

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

3# 

4# This file is part of the hdl-registers project, an HDL register generator fast enough to run 

5# in real time. 

6# https://hdl-registers.com 

7# https://github.com/hdl-registers/hdl-registers 

8# -------------------------------------------------------------------------------------------------- 

9 

10""" 

11Some limited unit tests. 

12Note that the generated VHDL code is also simulated in a functional test. 

13""" 

14 

15# First party libraries 

16from hdl_registers.generator.vhdl.axi_lite.wrapper import VhdlAxiLiteWrapperGenerator 

17from hdl_registers.register_list import RegisterList 

18from hdl_registers.register_modes import REGISTER_MODES 

19 

20 

21def test_file_is_not_generated_without_registers(tmp_path): 

22 register_list = RegisterList(name="test", source_definition_file=None) 

23 

24 assert not (VhdlAxiLiteWrapperGenerator(register_list, tmp_path).create()).exists() 

25 

26 register_list.add_constant(name="apa", value=True, description="") 

27 assert not (VhdlAxiLiteWrapperGenerator(register_list, tmp_path).create()).exists() 

28 

29 register_list.append_register(name="hest", mode=REGISTER_MODES["r_w"], description="") 

30 assert (VhdlAxiLiteWrapperGenerator(register_list, tmp_path).create()).exists() 

31 

32 

33def test_re_generating_file_without_registers_should_delete_old_file(tmp_path): 

34 register_list = RegisterList(name="test", source_definition_file=None) 

35 register_list.append_register(name="apa", mode=REGISTER_MODES["r_w"], description="") 

36 

37 assert (VhdlAxiLiteWrapperGenerator(register_list, tmp_path).create()).exists() 

38 

39 register_list.register_objects = [] 

40 assert not (VhdlAxiLiteWrapperGenerator(register_list, tmp_path).create()).exists()