GCC Code Coverage Report
Directory: generated/vunit_out/preprocessed/ Exec Total Coverage
File: generated/vunit_out/preprocessed/common/tb_addr_pkg.vhd Lines: 23 23 100.0 %
Date: 2021-06-12 04:12:08 Branches: 76 120 63.3 %

Line Branch Exec Source
1
18
-- -------------------------------------------------------------------------------------------------
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
library ieee;
10
use ieee.std_logic_1164.all;
11
use ieee.numeric_std.all;
12
13
library vunit_lib;
14
context vunit_lib.vunit_context;
15
16
use work.addr_pkg.all;
17
18
19














33
entity tb_addr_pkg is
20
  generic (
21
    runner_cfg : string
22
  );
23
end entity;
24
25
architecture tb of tb_addr_pkg is
26
27
21
  constant addrs : addr_and_mask_vec_t(0 to 6 - 1) := (
28
    0 => (addr => x"0000_0000", mask => x"0000_f000"),
29
    1 => (addr => x"0000_1000", mask => x"0000_f000"),
30
    2 => (addr => x"0000_2000", mask => x"0000_ff00"),
31
    3 => (addr => x"0000_2100", mask => x"0000_ff00"),
32
    4 => (addr => x"0000_3000", mask => x"0000_f000"),
33
    5 => (addr => x"0000_4000", mask => x"0000_f000")
34
  );
35
36
12
  constant addrs2 : addr_and_mask_vec_t(0 to 2 - 1) := (
37
    0 => (addr => x"0120_0000", mask => x"01f0_0000"),
38
    1 => (addr => x"0130_0000", mask => x"01f0_0000")
39
  );
40
41
begin
42
43
3
  main : process
44
30
    variable value : signed(5 - 1 downto 0);
45
46
    -- Use this function to get addr vector constrained
47
    function decode(addr : unsigned(32 - 1 downto 0)) return integer is
48
    begin
49








52
      return decode(addr, addrs);
50
    end function;
51
52
  begin
53
9
    test_runner_setup(runner, runner_cfg);
54
55
3
    if run("test_addr_bits_needed") then
56
2
      check_equal(addr_bits_needed(addrs), 16, line_num => 56, file_name => "tb_addr_pkg.vhd");
57
3
      check_equal(addr_bits_needed(addrs2), 25, line_num => 57, file_name => "tb_addr_pkg.vhd");
58
59
2
    elsif run("test_decode_happy_path") then
60
2
      check_equal(decode(x"43C0_0000"), 0, line_num => 60, file_name => "tb_addr_pkg.vhd");
61
2
      check_equal(decode(x"43C0_1000"), 1, line_num => 61, file_name => "tb_addr_pkg.vhd");
62
2
      check_equal(decode(x"43C0_2000"), 2, line_num => 62, file_name => "tb_addr_pkg.vhd");
63
2
      check_equal(decode(x"43C0_2100"), 3, line_num => 63, file_name => "tb_addr_pkg.vhd");
64
2
      check_equal(decode(x"43C0_3000"), 4, line_num => 64, file_name => "tb_addr_pkg.vhd");
65
3
      check_equal(decode(x"43C0_4000"), 5, line_num => 65, file_name => "tb_addr_pkg.vhd");
66
67
4
    elsif run("test_decode_fail") then
68
2
      check_equal(decode(x"43C0_2200"), addrs'length, line_num => 68, file_name => "tb_addr_pkg.vhd");
69
2
      check_equal(decode(x"43C0_2300"), addrs'length, line_num => 69, file_name => "tb_addr_pkg.vhd");
70
3
      check_equal(decode(x"43C0_5000"), addrs'length, line_num => 70, file_name => "tb_addr_pkg.vhd");
71
    end if;
72
73
43
    test_runner_cleanup(runner);
74
  end process;
75
76
end architecture;