GCC Code Coverage Report
Directory: generated/vunit_out/preprocessed/ Exec Total Coverage
File: generated/vunit_out/preprocessed/common/tb_types_pkg.vhd Lines: 71 71 100.0 %
Date: 2021-06-12 04:12:08 Branches: 28 56 50.0 %

Line Branch Exec Source
1
36
-- -------------------------------------------------------------------------------------------------
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.types_pkg.all;
17
18
19














166
entity tb_types_pkg is
20
  generic (
21
    runner_cfg : string
22
  );
23
end entity;
24
25
12
architecture tb of tb_types_pkg is
26
begin
27
28
6
  main : process
29
30
6
    variable byte_data0 : std_logic_vector(4 * 8 - 1 downto 0) := x"01_23_45_67";
31
6
    constant byte_data0_swapped : std_logic_vector(byte_data0'range) := x"67_45_23_01";
32
33
6
    variable byte_data1 : std_logic_vector(8 * 8 - 1 downto 4 * 8) := x"01_23_45_67";
34
6
    constant byte_data1_swapped : std_logic_vector(byte_data0'range) := x"67_45_23_01";
35
36
6
    variable bit_data0 : std_logic_vector(6 - 1 downto 0) := "101010";
37
6
    constant bit_data0_swapped : std_logic_vector(bit_data0'range) := "010101";
38
39
6
    variable bit_data1 : std_logic_vector(0 to 6 - 1) := "101010";
40
6
    constant bit_data1_swapped : std_logic_vector(bit_data1'range) := "010101";
41
42
6
    variable bit_data2 : std_logic_vector(12 - 1 downto 6) := "101010";
43
6
    constant bit_data2_swapped : std_logic_vector(bit_data2'range) := "010101";
44
45
6
    variable bit_data3 : std_logic_vector(6 to 12 - 1) := "101010";
46
6
    constant bit_data3_swapped : std_logic_vector(bit_data2'range) := "010101";
47
48
54
    variable positive_vec : positive_vec_t(0 to 3) := (others => 1);
49
50
  begin
51
18
    test_runner_setup(runner, runner_cfg);
52
53
54
6
    if run("test_get_maximum_positive") then
55
1
      positive_vec := (1, 1, 1, 1);
56
2
      check_equal(get_maximum(positive_vec), 1, line_num => 56, file_name => "tb_types_pkg.vhd");
57
58
1
      positive_vec := (4, 3, 2, 1);
59
3
      check_equal(get_maximum(positive_vec), 4, line_num => 59, file_name => "tb_types_pkg.vhd");
60
61
5
    elsif run("test_to_bool_std_logic") then
62
2
      check_equal(to_bool('0'), false, line_num => 62, file_name => "tb_types_pkg.vhd");
63
3
      check_equal(to_bool('1'), true, line_num => 63, file_name => "tb_types_pkg.vhd");
64
65
4
    elsif run("test_to_bool_integer") then
66
2
      check_equal(to_bool(0), false, line_num => 66, file_name => "tb_types_pkg.vhd");
67
3
      check_equal(to_bool(1), true, line_num => 67, file_name => "tb_types_pkg.vhd");
68
69
3
    elsif run("test_swap_byte_order") then
70
1
      byte_data0 := swap_byte_order(byte_data0);
71
2
      check_equal(byte_data0, byte_data0_swapped, line_num => 71, file_name => "tb_types_pkg.vhd");
72
2
      check_equal(byte_data0'high, 4 * 8 - 1, line_num => 72, file_name => "tb_types_pkg.vhd");
73
2
      check_equal(byte_data0'low, 0, line_num => 73, file_name => "tb_types_pkg.vhd");
74
2
      check_equal(byte_data0'left, byte_data0'high, line_num => 74, file_name => "tb_types_pkg.vhd");
75
2
      check_equal(byte_data0'right, byte_data0'low, line_num => 75, file_name => "tb_types_pkg.vhd");
76
77
1
      byte_data1 := swap_byte_order(byte_data1);
78
2
      check_equal(byte_data1, byte_data1_swapped, line_num => 78, file_name => "tb_types_pkg.vhd");
79
2
      check_equal(byte_data1'high, 8 * 8 - 1, line_num => 79, file_name => "tb_types_pkg.vhd");
80
2
      check_equal(byte_data1'low, 4 * 8, line_num => 80, file_name => "tb_types_pkg.vhd");
81
2
      check_equal(byte_data1'left, byte_data1'high, line_num => 81, file_name => "tb_types_pkg.vhd");
82
3
      check_equal(byte_data1'right, byte_data1'low, line_num => 82, file_name => "tb_types_pkg.vhd");
83
84
2
    elsif run("test_swap_bit_order") then
85
1
      bit_data0 := swap_bit_order(bit_data0);
86
2
      check_equal(bit_data0, bit_data0_swapped, line_num => 86, file_name => "tb_types_pkg.vhd");
87
2
      check_equal(bit_data0'high, 5, line_num => 87, file_name => "tb_types_pkg.vhd");
88
2
      check_equal(bit_data0'low, 0, line_num => 88, file_name => "tb_types_pkg.vhd");
89
2
      check_equal(bit_data0'left, bit_data0'high, line_num => 89, file_name => "tb_types_pkg.vhd");
90
2
      check_equal(bit_data0'right, bit_data0'low, line_num => 90, file_name => "tb_types_pkg.vhd");
91
92
1
      bit_data1 := swap_bit_order(bit_data1);
93
2
      check_equal(bit_data1, bit_data1_swapped, line_num => 93, file_name => "tb_types_pkg.vhd");
94
2
      check_equal(bit_data1'high, 5, line_num => 94, file_name => "tb_types_pkg.vhd");
95
2
      check_equal(bit_data1'low, 0, line_num => 95, file_name => "tb_types_pkg.vhd");
96
2
      check_equal(bit_data1'left, bit_data1'low, line_num => 96, file_name => "tb_types_pkg.vhd");
97
2
      check_equal(bit_data1'right, bit_data1'high, line_num => 97, file_name => "tb_types_pkg.vhd");
98
99
1
      bit_data2 := swap_bit_order(bit_data2);
100
2
      check_equal(bit_data2, bit_data2_swapped, line_num => 100, file_name => "tb_types_pkg.vhd");
101
2
      check_equal(bit_data2'high, 11, line_num => 101, file_name => "tb_types_pkg.vhd");
102
2
      check_equal(bit_data2'low, 6, line_num => 102, file_name => "tb_types_pkg.vhd");
103
2
      check_equal(bit_data2'left, bit_data2'high, line_num => 103, file_name => "tb_types_pkg.vhd");
104
2
      check_equal(bit_data2'right, bit_data2'low, line_num => 104, file_name => "tb_types_pkg.vhd");
105
106
1
      bit_data3 := swap_bit_order(bit_data3);
107
2
      check_equal(bit_data3, bit_data3_swapped, line_num => 107, file_name => "tb_types_pkg.vhd");
108
2
      check_equal(bit_data3'high, 11, line_num => 108, file_name => "tb_types_pkg.vhd");
109
2
      check_equal(bit_data3'low, 6, line_num => 109, file_name => "tb_types_pkg.vhd");
110
2
      check_equal(bit_data3'left, bit_data3'low, line_num => 110, file_name => "tb_types_pkg.vhd");
111
3
      check_equal(bit_data3'right, bit_data3'high, line_num => 111, file_name => "tb_types_pkg.vhd");
112
113
7
    elsif run("test_count_ones") then
114
2
      check_equal(count_ones(bit_data3), 3, line_num => 114, file_name => "tb_types_pkg.vhd");
115
3
      check_equal(count_ones(byte_data1), 12, line_num => 115, file_name => "tb_types_pkg.vhd");
116
117
    end if;
118
119
118
    test_runner_cleanup(runner);
120
  end process;
121
122
end architecture;