GCC Code Coverage Report
Directory: generated/vunit_out/preprocessed/ Exec Total Coverage
File: generated/vunit_out/preprocessed/bfm/bfm_pkg.vhd Lines: 0 13 0.0 %
Date: 2021-06-12 04:12:08 Branches: 0 144 0.0 %

Line Branch Exec Source
1
-- -------------------------------------------------------------------------------------------------
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.numeric_std.all;
11
12
library vunit_lib;
13
context vunit_lib.vc_context;
14
context vunit_lib.vunit_context;
15
16
17
package bfm_pkg is
18
19
  -- Convenience method for getting vectors of BFM/VC elements.
20
  -- When doing e.g.
21
  --   constant my_masters : axi_stream_master_vec_t(0 to 1) :=
22
  --     (others => new_axi_stream_master(...));
23
  -- works well in some simulators (GHDL), meaning that the function is evaluated once for each
24
  -- element of the vector. In e.g. modelsim the function is only evaluated once, and all elements
25
  -- get the same value. Hence the need for this function.
26
27
  impure function get_new_queues(count : positive) return queue_vec_t;
28
29
  type axi_stream_master_vec_t is array (integer range <>) of axi_stream_master_t;
30
  impure function get_new_axi_stream_masters(
31
    count : positive;
32
    data_width : positive;
33
    logger_name : string;
34
    stall_config : stall_config_t
35
  ) return axi_stream_master_vec_t;
36
37
  type axi_stream_slave_vec_t is array (integer range <>) of axi_stream_slave_t;
38
  impure function get_new_axi_stream_slaves(
39
    count : positive;
40
    data_width : positive;
41
    logger_name : string;
42
    stall_config : stall_config_t
43
  ) return axi_stream_slave_vec_t;
44
45
end package;
46
47
package body bfm_pkg is
48
49
  impure function get_new_queues(count : positive) return queue_vec_t is
50
    variable result : queue_vec_t(0 to count - 1) := (others => null_queue);
51
  begin
52
    for queue_idx in result'range loop
53
      result(queue_idx) := new_queue;
54
    end loop;
55
    return result;
56
  end function;
57
58
  impure function get_new_axi_stream_masters(
59
    count : positive;
60
    data_width : positive;
61
    logger_name : string;
62
    stall_config : stall_config_t
63
  ) return axi_stream_master_vec_t is
64
    variable result : axi_stream_master_vec_t(0 to count - 1) := (others => null_axi_stream_master);
65
  begin
66
    for result_idx in result'range loop
67
      result(result_idx) := new_axi_stream_master(
68
        data_length => data_width,
69
        protocol_checker => new_axi_stream_protocol_checker(
70
          logger => get_logger(logger_name),
71
          data_length => data_width
72
        ),
73
        stall_config => stall_config
74
      );
75
    end loop;
76
    return result;
77
  end function;
78
79
  impure function get_new_axi_stream_slaves(
80
    count : positive;
81
    data_width : positive;
82
    logger_name : string;
83
    stall_config : stall_config_t
84
  ) return axi_stream_slave_vec_t is
85
    variable result : axi_stream_slave_vec_t(0 to count - 1) := (others => null_axi_stream_slave);
86
  begin
87
    for result_idx in result'range loop
88
      result(result_idx) := new_axi_stream_slave(
89
        data_length => data_width,
90
        protocol_checker => new_axi_stream_protocol_checker(
91
          logger => get_logger(logger_name),
92
          data_length => data_width
93
        ),
94
        stall_config => stall_config
95
      );
96
    end loop;
97
    return result;
98
  end function;
99
100
end package body;