GCC Code Coverage Report
Directory: generated/vunit_out/preprocessed/ Exec Total Coverage
File: generated/vunit_out/preprocessed/axi/tb_axi_lite_pipeline.vhd Lines: 43 43 100.0 %
Date: 2021-06-12 04:12:08 Branches: 165 234 70.5 %

Line Branch Exec Source
1
6
-- -------------------------------------------------------------------------------------------------
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
use vunit_lib.memory_pkg.all;
15
context vunit_lib.vunit_context;
16
context vunit_lib.vc_context;
17
18
library osvvm;
19
use osvvm.RandomPkg.all;
20
21
library bfm;
22
23
use work.axi_pkg.all;
24
use work.axi_lite_pkg.all;
25
26
27



























10
entity tb_axi_lite_pipeline is
28
  generic (
29
1
    runner_cfg : string
30


201
  );
31







538
end entity;
32
69
33




401
architecture tb of tb_axi_lite_pipeline is
34
70
35
66
  constant data_width : integer := 32;
36


134
  constant addr_width : integer := 24;
37
1
  constant num_words : integer := 2048;
38
137
39

6
  constant clk_period : time := 7 ns;
40
41
1
  signal clk : std_logic := '0';
42
43
401
  signal master_m2s, slave_m2s : axi_lite_m2s_t := axi_lite_m2s_init;
44
137
  signal master_s2m, slave_s2m : axi_lite_s2m_t := axi_lite_s2m_init;
45
46
1
  constant axi_lite_master : bus_master_t := new_bus(
47
    data_length => data_width,
48
    address_length => master_m2s.read.ar.addr'length
49
  );
50
51
1
  constant memory : memory_t := new_memory;
52
2
  constant axi_lite_read_slave, axi_lite_write_slave : axi_slave_t := new_axi_slave(
53
    memory => memory,
54
    address_fifo_depth => 8,
55
    write_response_fifo_depth => 8,
56
    address_stall_probability => 0.3,
57
    data_stall_probability => 0.3,
58
    write_response_stall_probability => 0.3,
59
    min_response_latency => 8 * clk_period,
60
    max_response_latency => 16 * clk_period,
61
    logger => get_logger("axi_lite_slave_slave")
62
  );
63
64
begin
65
66
155427
  test_runner_watchdog(runner, 1 ms);
67
68





188199
  clk <= not clk after clk_period / 2;
69
70
71
  ------------------------------------------------------------------------------
72
1
  main : process
73
1
    variable rnd : RandomPType;
74
33
    variable data : std_logic_vector(data_width - 1 downto 0);
75
1
    variable address : integer;
76
5
    variable buf : buffer_t;
77
  begin
78
3
    test_runner_setup(runner, runner_cfg);
79
2
    rnd.InitSeed(rnd'instance_name);
80
81
1
    buf := allocate(memory, 4 * num_words);
82
83
1
    for idx in 0 to num_words - 1 loop
84
2048
      address := 4 * idx;
85
2048
      data := rnd.RandSlv(data'length);
86
87
       -- Call is non-blocking. I.e. we will build up a queue of writes.
88

6144
      write_bus(net, axi_lite_master, address, data);
89

4096
      set_expected_word(memory, address, data);
90

10239
      wait until rising_edge(clk);
91
    end loop;
92
93
1
    for idx in 0 to num_words - 1 loop
94
2048
      address := 4 * idx;
95

2048
      data := read_word(memory, address, 4);
96
97

12289
      check_bus(net, axi_lite_master, address, data);
98
    end loop;
99
100
22537
    test_runner_cleanup(runner);
101
  end process;
102
103
104
  ------------------------------------------------------------------------------
105
1
  axi_lite_master_inst : entity bfm.axi_lite_master
106
    generic map (
107
      bus_handle => axi_lite_master
108
    )
109
    port map (
110
      clk => clk,
111
      --
112
      axi_lite_m2s => master_m2s,
113
      axi_lite_s2m => master_s2m
114
    );
115
116
117
  ------------------------------------------------------------------------------
118
1
  axi_lite_slave_inst : entity bfm.axi_lite_slave
119
    generic map (
120
      axi_read_slave => axi_lite_read_slave,
121
      axi_write_slave => axi_lite_write_slave,
122
      data_width => data_width
123
    )
124
    port map (
125
      clk => clk,
126
      --
127
      axi_lite_read_m2s => slave_m2s.read,
128
      axi_lite_read_s2m => slave_s2m.read,
129
      --
130
      axi_lite_write_m2s => slave_m2s.write,
131
      axi_lite_write_s2m => slave_s2m.write
132
    );
133
134
135
  ------------------------------------------------------------------------------
136
1
  dut : entity work.axi_lite_pipeline
137
    generic map (
138
      data_width => data_width,
139
      addr_width => addr_width
140
    )
141
    port map (
142
      clk => clk,
143
      --
144
      master_m2s => master_m2s,
145
      master_s2m => master_s2m,
146
      --
147
      slave_m2s => slave_m2s,
148
      slave_s2m => slave_s2m
149
    );
150
151
end architecture;