OpenCores
URL https://opencores.org/ocsvn/vhdl_wb_tb/vhdl_wb_tb/trunk

Subversion Repositories vhdl_wb_tb

[/] [vhdl_wb_tb/] [trunk/] [bench/] [vhdl/] [tb_top.vhd] - Blame information for rev 4

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sinx
---------------------------------------------------------------------- 
2
----                                                              ---- 
3
----  VHDL Wishbone TESTBENCH                                     ---- 
4
----                                                              ---- 
5
----  This file is part of the vhdl_wb_tb project                 ---- 
6 4 sinx
----  https://opencores.org/project/vhdl_wb_tb                    ---- 
7 2 sinx
----                                                              ---- 
8 4 sinx
----  This file contains the highest (top) module for simulation. ----
9
----  Like tb_top it instantiates the core_top module and         ----
10
----  provides parameters/generics. Where the top module provides ---- 
11
----  parameters for synthesis this file provides parameters for  ----
12
----  simulation.                                                 ----
13
----                                                              ---- 
14 2 sinx
----  It instantiates the design under test (DUT), instantiates   ----
15
----  the stimulator module for test vector generation,           ----
16
----  instantiates the verifier module for result comparison,     ----
17
----  instantiates the test case top (testcase_top) bfm,          ----
18
----  interconnects all three components, generates DUT-external  ----
19
----  clocks and resets.                                          ----
20
----                                                              ---- 
21
----  To Do:                                                      ---- 
22
----   -                                                          ---- 
23
----                                                              ---- 
24
----  Author(s):                                                  ---- 
25 4 sinx
----      - Sinx, sinx@opencores.org                              ---- 
26 2 sinx
----                                                              ---- 
27
----------------------------------------------------------------------
28 4 sinx
----    SVN information
29
----
30
----      $URL:  $
31
---- $Revision:  $
32
----     $Date:  $
33
----   $Author:  $
34
----       $Id:  $
35 2 sinx
---------------------------------------------------------------------- 
36
----                                                              ---- 
37
---- Copyright (C) 2018 Authors and OPENCORES.ORG                 ---- 
38
----                                                              ---- 
39
---- This source file may be used and distributed without         ---- 
40
---- restriction provided that this copyright statement is not    ---- 
41
---- removed from the file and that any derivative work contains  ---- 
42
---- the original copyright notice and the associated disclaimer. ---- 
43
----                                                              ---- 
44
---- This source file is free software; you can redistribute it   ---- 
45
---- and/or modify it under the terms of the GNU Lesser General   ---- 
46
---- Public License as published by the Free Software Foundation; ---- 
47
---- either version 2.1 of the License, or (at your option) any   ---- 
48
---- later version.                                               ---- 
49
----                                                              ---- 
50
---- This source is distributed in the hope that it will be       ---- 
51
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
52
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
53
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
54
---- details.                                                     ---- 
55
----                                                              ---- 
56
---- You should have received a copy of the GNU Lesser General    ---- 
57
---- Public License along with this source; if not, download it   ---- 
58
---- from http://www.opencores.org/lgpl.shtml                     ---- 
59
----                                                              ---- 
60
----------------------------------------------------------------------
61
 
62
-- library -----------------------------------------------------------
63
library ieee;
64
use ieee.std_logic_1164.all;
65
use ieee.numeric_std.all;
66
library work;
67
use work.convert_pkg.all;
68
use work.wishbone_pkg.all;
69
use work.wishbone_bfm_pkg.all;
70
 
71
-- entity ------------------------------------------------------------
72
entity tb_top is
73
  -- empty entity, since this is the simulation top and all test cases are defined
74
  -- in the tc_xxx files.
75
end entity tb_top;
76
 
77 4 sinx
-- architecture ------------------------------------------------------
78 2 sinx
architecture rtl of tb_top is
79 4 sinx
  -----------------------------------------------------------------------------
80 2 sinx
  constant  g_wb_clock_period               : time     := 20.0 ns;   -- 50 mhz
81
  -----------------------------------------------------------------------------
82
  signal s_wb_bfm_out                 : wishbone_bfm_master_out_t; -- from testcase_top
83
  signal s_wb_bfm_in                  : wishbone_bfm_master_in_t;  -- to testcase_top
84
 
85
  signal s_wb_master_out              : wishbone_master_out_t;    -- from wb_decoder
86
  signal s_wb_master_in               : wishbone_master_in_t;    -- to wb_decoder
87
 
88
  constant number_of_wb_slaves_c      : integer := 2;
89
  signal s_wb_slaves_in               : wishbone_slave_in_array_t (number_of_wb_slaves_c-1 downto 0);
90
  signal s_wb_slaves_out              : wishbone_slave_out_array_t (number_of_wb_slaves_c-1 downto 0);
91
 
92
  signal s_wb_clock                   : std_logic := '0';
93
  signal s_wb_clock_locked            : std_logic := '0';
94
  signal s_wb_reset_p1                : std_logic := '1';
95
  signal s_wb_reset_p2                : std_logic := '1';
96
  signal s_wb_reset                   : std_logic := '1';
97
 
98
  constant number_of_stimulus_signals_c : integer := 8;
99
  constant number_of_verify_signals_c   : integer := 8;
100
  signal s_stimulus                   : std_logic_vector(number_of_stimulus_signals_c-1 downto 0);
101
  signal s_verify                     : std_logic_vector(number_of_verify_signals_c-1 downto 0);
102
  -----------------------------------------------------------------------------
103 4 sinx
begin
104 2 sinx
  -----------------------------------------------------------------------------
105
  --clocks---------------------------------------------------------------------
106
  wb_clock_generator : process -- required for test bench wb bus; 50mhz is standard
107
  begin
108
    s_wb_clock        <= '0';
109
    wait for g_wb_clock_period/2;
110
    s_wb_clock        <= '1';
111
    wait for g_wb_clock_period/2;
112
    s_wb_clock_locked <= '1';
113
  end process;
114
  -----------------------------------------------------------------------------
115
  synchronize_reset_proc : process(all)
116
  begin
117
    if (s_wb_clock_locked = '0') then
118
      s_wb_reset_p1 <= '1';
119
      s_wb_reset_p2 <= '1';
120
    elsif (rising_edge(s_wb_clock)) then
121
      s_wb_reset_p1 <= '0'; -- or s_tc_reset;
122
      s_wb_reset_p2 <= s_wb_reset_p1;
123
    end if;
124
  end process;
125
  s_wb_reset   <= s_wb_reset_p2;
126
  -----------------------------------------------------------------------------
127
  -- instance of test case "player"; runs tc_xxxx modules
128 4 sinx
  tc_top_inst : entity work.tc_top
129 2 sinx
    port map (
130
      wb_o                => s_wb_bfm_out,
131
      wb_i                => s_wb_bfm_in
132
      );
133
  -----------------------------------------------------------------------------
134
  -- splits the test case wb bus for all stimulation and verifier modules.
135
  -- decodes the given bits (g_decoded_address_msb:g_decoded_address_lsb) and#
136
  -- compares them to 0..n, with n=(g_number_of_ports-1)
137
  proc_readdata_decoder  : process (all)
138
    begin
139
      s_wb_bfm_in.dat <= (others => 'U');
140
      s_wb_bfm_in.ack <= '1';
141
      s_wb_bfm_in.clk <= s_wb_clock;
142
      s_wb_bfm_in.int <= '0';
143
      s_wb_bfm_in.rst <= s_wb_reset;
144
      for I in number_of_wb_slaves_c-1 downto 0 loop
145
        s_wb_slaves_in(I) <= work.wishbone_pkg.wb_master_out_idle_c; -- default values are init (idle) values
146
        s_wb_slaves_in(I).clk <= s_wb_clock;
147
        s_wb_slaves_in(I).rst <= s_wb_reset OR s_wb_bfm_out.rst;
148
        if ( s_wb_bfm_out.adr(31 downto 28) = to_std_logic_vector(I,4)) then -- decode the upper nibble for module decoding
149
          s_wb_bfm_in.dat <= s_wb_slaves_out(I).dat;
150
          s_wb_bfm_in.ack <= s_wb_slaves_out(I).ack;
151
          s_wb_slaves_in(I).dat <= s_wb_bfm_out.dat;
152
          s_wb_slaves_in(I).tgd  <= s_wb_bfm_out.tgd;
153
          s_wb_slaves_in(I).adr  <= s_wb_bfm_out.adr;
154
          s_wb_slaves_in(I).cyc  <= s_wb_bfm_out.cyc;
155
          s_wb_slaves_in(I).lock <= s_wb_bfm_out.lock;
156
          s_wb_slaves_in(I).sel  <= s_wb_bfm_out.sel;
157
          s_wb_slaves_in(I).stb  <= s_wb_bfm_out.stb;
158
          s_wb_slaves_in(I).tga  <= s_wb_bfm_out.tga;
159
          s_wb_slaves_in(I).tgc  <= s_wb_bfm_out.tgc;
160
          s_wb_slaves_in(I).we   <= s_wb_bfm_out.we;
161
        end if;
162
      end loop;
163
  end process;
164
  -----------------------------------------------------------------------------
165
  -- instance of design under test
166
  core_top_inst : entity work.core_top
167
    generic map(
168
      g_number_of_in_signals              => number_of_stimulus_signals_c,
169
      g_number_of_out_signals             => number_of_verify_signals_c
170
      )
171
    port map(
172
      clock_i                             => s_wb_clock,
173
      reset_i                             => s_wb_reset,
174
      signals_i                           => s_stimulus,
175
      signals_o                           => s_verify
176
      );
177
  -----------------------------------------------------------------------------
178
  -- instance of stimulator
179
  stimulator_inst : entity work.stimulator
180
    generic map(
181
      g_number_of_signals                 => number_of_stimulus_signals_c
182
      )
183
    port map(
184
      wb_i                                => s_wb_slaves_in(0),
185
      wb_o                                => s_wb_slaves_out(0),
186
      signals_o                           => s_stimulus
187
      );
188
  -----------------------------------------------------------------------------
189
  -- instance of stimulator
190
  verifier_inst : entity work.verifier
191
    generic map(
192
      g_number_of_signals                 => number_of_verify_signals_c
193
      )
194
    port map(
195
      wb_i                                => s_wb_slaves_in(1),
196
      wb_o                                => s_wb_slaves_out(1),
197
      signals_i                           => s_verify
198
      );
199
  -----------------------------------------------------------------------------
200 4 sinx
end rtl;
201
----------------------------------------------------------------------
202
---- end of file                                                  ---- 
203
----------------------------------------------------------------------

powered by: WebSVN 2.1.0

© copyright 1999-2020 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.