tsfpga VHDL coverage


Directory: generated/vunit_out/preprocessed/
File: generated/vunit_out/preprocessed/common/addr_pkg.vhd
Date: 2021-07-25 04:08:32
Exec Total Coverage
Lines: 16 16 100.0%
Branches: 34 54 63.0%

Line Branch Exec Source
1
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23 times.
✓ Branch 7 taken 2 times.
6426 -- -------------------------------------------------------------------------------------------------
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 math;
14 use math.math_pkg.all;
15
16
17 package addr_pkg is
18
19 50 constant addr_width : integer := 32;
20 subtype addr_t is unsigned(addr_width - 1 downto 0);
21 type addr_vec_t is array (integer range <>) of addr_t;
22
23 type addr_and_mask_t is record
24 addr : addr_t;
25 mask : addr_t;
26 end record;
27 type addr_and_mask_vec_t is array (integer range <>) of addr_and_mask_t;
28
29 function addr_bits_needed(addrs : addr_and_mask_vec_t) return positive;
30
31 function match(addr : unsigned; addr_and_mask : addr_and_mask_t) return boolean;
32
33 function decode(addr : unsigned; addrs : addr_and_mask_vec_t) return integer;
34
35 end package;
36
37 package body addr_pkg is
38
39 function addr_bits_needed(addrs : addr_and_mask_vec_t) return positive is
40 36 variable result : positive := 1;
41 begin
42 -- Return the number of bits that are needed to decode and handle the addresses.
43
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 for addr_idx in addrs'range loop
44
8/12
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✓ Branch 6 taken 62 times.
✓ Branch 7 taken 18 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 80 times.
✓ Branch 11 taken 62 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 62 times.
✗ Branch 14 not taken.
160 result := maximum(result, num_bits_needed(addrs(addr_idx).mask));
45 end loop;
46 36 return result;
47 end function;
48
49 function match(addr : unsigned; addr_and_mask : addr_and_mask_t) return boolean is
50 4556 variable test_ok : boolean := true;
51 begin
52
1/2
✓ Branch 0 taken 2278 times.
✗ Branch 1 not taken.
4556 for bit_idx in addr_and_mask.addr'range loop
53
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72896 times.
✓ Branch 4 taken 7020 times.
✓ Branch 5 taken 65876 times.
145792 if addr_and_mask.mask(bit_idx) then
54
7/10
✓ Branch 0 taken 4976 times.
✓ Branch 1 taken 2044 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4976 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4976 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4976 times.
✓ Branch 10 taken 70618 times.
✓ Branch 11 taken 2278 times.
145792 test_ok := test_ok and (addr(bit_idx) = addr_and_mask.addr(bit_idx));
55 end if;
56 end loop;
57
58 4556 return test_ok;
59 end function;
60
61 function decode(addr : unsigned; addrs : addr_and_mask_vec_t) return integer is
62 1648 constant decode_fail : integer := addrs'length;
63 begin
64
1/2
✓ Branch 0 taken 824 times.
✗ Branch 1 not taken.
1648 for addr_idx in addrs'range loop
65
4/6
✓ Branch 0 taken 2278 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2278 times.
✓ Branch 6 taken 815 times.
✓ Branch 7 taken 1463 times.
4556 if match(addr, addrs(addr_idx)) then
66
3/4
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 1454 times.
✗ Branch 3 not taken.
4556 return addr_idx;
67 end if;
68 end loop;
69
70
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
68 return decode_fail;
71 end function;
72
73 end package body;
74