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 2

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

powered by: WebSVN 2.1.0

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