tsfpga VHDL coverage


Directory: generated/vunit_out/preprocessed/
File: generated/vunit_out/preprocessed/reg_file/reg_file_pkg.vhd
Date: 2021-07-26 04:08:16
Exec Total Coverage
Lines: 19 19 100.0%
Branches: 58 90 64.4%

Line Branch Exec Source
1
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 15 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 19 times.
152764 -- -------------------------------------------------------------------------------------------------
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 common;
14 use common.addr_pkg.all;
15
16 library math;
17 use math.math_pkg.all;
18
19
20 package reg_file_pkg is
21
22 38 constant reg_width : integer := 32;
23 subtype reg_t is std_logic_vector(reg_width - 1 downto 0);
24 type reg_vec_t is array (integer range <>) of reg_t;
25
26 type reg_type_t is (
27 r, -- Bus can read a value that fabric provides
28 w, -- Bus can write a value that is available for fabric usage
29 r_w, -- Bus can write a value and read it back. The written value is available for fabric usage
30 wpulse, -- Bus can write a value that is asserted for one cycle in fabric
31 r_wpulse -- Bus can read a value that fabric provides. Bus can write a value that is asserted for one cycle in fabric
32 );
33
34 function is_read_type(reg_type : reg_type_t) return boolean;
35 function is_write_type(reg_type : reg_type_t) return boolean;
36 function is_write_pulse_type(reg_type : reg_type_t) return boolean;
37 function is_fabric_gives_value_type(reg_type : reg_type_t) return boolean;
38
39 type reg_definition_t is record
40 idx : integer;
41 reg_type : reg_type_t;
42 end record;
43 type reg_definition_vec_t is array (natural range <>) of reg_definition_t;
44
45 function get_highest_idx(regs : reg_definition_vec_t) return integer;
46 function get_addr_mask(regs : reg_definition_vec_t) return addr_t;
47 function to_addr_and_mask_vec(regs : reg_definition_vec_t) return addr_and_mask_vec_t;
48
49 end;
50
51 package body reg_file_pkg is
52
53 function is_read_type(reg_type : reg_type_t) return boolean is
54 begin
55
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 33 times.
96 return reg_type = r or reg_type = r_w or reg_type = r_wpulse;
56 end function;
57
58 function is_write_type(reg_type : reg_type_t) return boolean is
59 begin
60
6/6
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 56 times.
148 return reg_type = w or reg_type = r_w or reg_type = wpulse or reg_type = r_wpulse;
61 end function;
62
63 function is_write_pulse_type(reg_type : reg_type_t) return boolean is
64 begin
65
2/2
✓ Branch 0 taken 53377 times.
✓ Branch 1 taken 1187 times.
109128 return reg_type = wpulse or reg_type = r_wpulse;
66 end function;
67
68 function is_fabric_gives_value_type(reg_type : reg_type_t) return boolean is
69 begin
70
2/2
✓ Branch 0 taken 21021 times.
✓ Branch 1 taken 201 times.
42444 return reg_type = r or reg_type = r_wpulse;
71 end function;
72
73 function get_highest_idx(regs : reg_definition_vec_t) return integer is
74 begin
75
3/6
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46 times.
92 assert regs(0).idx = 0 severity failure;
76
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 46 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 46 times.
92 assert regs(regs'high).idx = regs'length - 1 severity failure;
77
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 46 times.
92 return regs(regs'high).idx;
78 end function;
79
80 function get_addr_mask(regs : reg_definition_vec_t) return addr_t is
81
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
92 constant num_bits : integer := num_bits_needed(get_highest_idx(regs));
82
2/2
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 46 times.
3036 variable result : addr_t := (others => '0');
83 begin
84 -- Lowest bits are always zero since registers are 32-bits i.e. four-byte aligned.
85
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46 times.
✓ Branch 8 taken 143 times.
✓ Branch 9 taken 46 times.
378 result(num_bits + 2 - 1 downto 2) := (others => '1');
86 92 return result;
87 end function;
88
89 function to_addr_and_mask_vec(regs : reg_definition_vec_t) return addr_and_mask_vec_t is
90 86 constant mask : addr_t := get_addr_mask(regs);
91
7/8
✗ Branch 1 not taken.
✓ Branch 2 taken 43 times.
✓ Branch 5 taken 413 times.
✓ Branch 6 taken 43 times.
✓ Branch 7 taken 13216 times.
✓ Branch 8 taken 413 times.
✓ Branch 9 taken 13216 times.
✓ Branch 10 taken 413 times.
53776 variable result : addr_and_mask_vec_t(regs'range);
92 begin
93
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
86 for list_idx in regs'range loop
94 -- Registers are 32-bits i.e. four-byte aligned, hence the multiplication.
95
6/12
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 413 times.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✓ Branch 15 taken 413 times.
✗ Branch 16 not taken.
826 result(list_idx).addr := to_unsigned(4 * regs(list_idx).idx, result(list_idx).addr'length);
96
5/8
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 413 times.
✓ Branch 6 taken 370 times.
✓ Branch 7 taken 43 times.
✓ Branch 8 taken 370 times.
✗ Branch 9 not taken.
826 result(list_idx).mask := mask;
97 end loop;
98
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
124 return result;
99 end function;
100
101 end;
102