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 18

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 14 sinx
----      $URL: file:///svn/vhdl_wb_tb/vhdl_wb_tb/trunk/bench/vhdl/tb_top.vhd $
31
---- $Revision: 18 $
32
----     $Date: 2018-08-01 11:56:15 +0200 (Wed, 01 Aug 2018) $
33
----   $Author: sinx $
34
----       $Id: tb_top.vhd 18 2018-08-01 09:56:15Z sinx $
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 5 sinx
  constant  wb_clock_period_g               : time     := 20.0 ns;   -- 50 mhz
81 2 sinx
  -----------------------------------------------------------------------------
82 5 sinx
  signal wb_bfm_out_s                 : wishbone_bfm_master_out_t; -- from testcase_top
83
  signal wb_bfm_in_s                  : wishbone_bfm_master_in_t;  -- to testcase_top
84 2 sinx
 
85 5 sinx
  signal wb_master_out_s              : wishbone_master_out_t;    -- from wb_decoder
86
  signal wb_master_in_s               : wishbone_master_in_t;    -- to wb_decoder
87 2 sinx
 
88
  constant number_of_wb_slaves_c      : integer := 2;
89 5 sinx
  signal wb_slaves_in_s               : wishbone_slave_in_array_t (number_of_wb_slaves_c-1 downto 0);
90
  signal wb_slaves_out_s              : wishbone_slave_out_array_t (number_of_wb_slaves_c-1 downto 0);
91 2 sinx
 
92 5 sinx
  signal wb_clock_s                   : std_logic := '0';
93
  signal wb_clock_locked_s            : std_logic := '0';
94
  signal wb_reset_p1_s                : std_logic := '1';
95
  signal wb_reset_p2_s                : std_logic := '1';
96
  signal wb_reset_s                   : std_logic := '1';
97 2 sinx
 
98
  constant number_of_stimulus_signals_c : integer := 8;
99
  constant number_of_verify_signals_c   : integer := 8;
100 5 sinx
  signal stimulus_s                   : std_logic_vector(number_of_stimulus_signals_c-1 downto 0);
101
  signal verify_s                     : std_logic_vector(number_of_verify_signals_c-1 downto 0);
102 2 sinx
  -----------------------------------------------------------------------------
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 5 sinx
    wb_clock_s        <= '0';
109
    wait for wb_clock_period_g/2;
110
    wb_clock_s        <= '1';
111
    wait for wb_clock_period_g/2;
112
    wb_clock_locked_s <= '1';
113 2 sinx
  end process;
114
  -----------------------------------------------------------------------------
115
  synchronize_reset_proc : process(all)
116
  begin
117 5 sinx
    if (wb_clock_locked_s = '0') then
118
      wb_reset_p1_s <= '1';
119
      wb_reset_p2_s <= '1';
120
    elsif (rising_edge(wb_clock_s)) then
121
      wb_reset_p1_s <= '0'; -- or tc_reset_s;
122
      wb_reset_p2_s <= wb_reset_p1_s;
123 2 sinx
    end if;
124
  end process;
125 5 sinx
  wb_reset_s   <= wb_reset_p2_s;
126 2 sinx
  -----------------------------------------------------------------------------
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 5 sinx
      wb_o                => wb_bfm_out_s,
131
      wb_i                => wb_bfm_in_s
132 2 sinx
      );
133
  -----------------------------------------------------------------------------
134
  -- splits the test case wb bus for all stimulation and verifier modules.
135 5 sinx
  -- decodes the given bits (decoded_address_msb_g:decoded_address_lsb_g) and#
136
  -- compares them to 0..n, with n=(number_of_ports_g-1)
137 2 sinx
  proc_readdata_decoder  : process (all)
138
    begin
139 5 sinx
      wb_bfm_in_s.dat <= (others => 'U');
140
      wb_bfm_in_s.ack <= '1';
141
      wb_bfm_in_s.clk <= wb_clock_s;
142
      wb_bfm_in_s.int <= '0';
143
      wb_bfm_in_s.rst <= wb_reset_s;
144 18 sinx
      wb_bfm_in_s.tgd <= (others => '0');
145
      wb_bfm_in_s.err <= '0';
146
      wb_bfm_in_s.rty <= '0';
147 2 sinx
      for I in number_of_wb_slaves_c-1 downto 0 loop
148 5 sinx
        wb_slaves_in_s(I) <= work.wishbone_pkg.wb_master_out_idle_c; -- default values are init (idle) values
149
        wb_slaves_in_s(I).clk <= wb_clock_s;
150
        wb_slaves_in_s(I).rst <= wb_reset_s OR wb_bfm_out_s.rst;
151
        if ( wb_bfm_out_s.adr(31 downto 28) = to_std_logic_vector(I,4)) then -- decode the upper nibble for module decoding
152
          wb_bfm_in_s.dat <= wb_slaves_out_s(I).dat;
153
          wb_bfm_in_s.ack <= wb_slaves_out_s(I).ack;
154 18 sinx
          wb_bfm_in_s.tgd <= wb_slaves_out_s(I).tgd;
155
          wb_bfm_in_s.err <= wb_slaves_out_s(I).err;
156
          wb_bfm_in_s.rty <= wb_slaves_out_s(I).rty;
157 5 sinx
          wb_slaves_in_s(I).dat <= wb_bfm_out_s.dat;
158
          wb_slaves_in_s(I).tgd  <= wb_bfm_out_s.tgd;
159
          wb_slaves_in_s(I).adr  <= wb_bfm_out_s.adr;
160
          wb_slaves_in_s(I).cyc  <= wb_bfm_out_s.cyc;
161
          wb_slaves_in_s(I).lock <= wb_bfm_out_s.lock;
162
          wb_slaves_in_s(I).sel  <= wb_bfm_out_s.sel;
163
          wb_slaves_in_s(I).stb  <= wb_bfm_out_s.stb;
164
          wb_slaves_in_s(I).tga  <= wb_bfm_out_s.tga;
165
          wb_slaves_in_s(I).tgc  <= wb_bfm_out_s.tgc;
166
          wb_slaves_in_s(I).we   <= wb_bfm_out_s.we;
167 2 sinx
        end if;
168
      end loop;
169
  end process;
170
  -----------------------------------------------------------------------------
171
  -- instance of design under test
172
  core_top_inst : entity work.core_top
173
    generic map(
174 5 sinx
      number_of_in_signals_g              => number_of_stimulus_signals_c,
175
      number_of_out_signals_g             => number_of_verify_signals_c
176 2 sinx
      )
177
    port map(
178 5 sinx
      clock_i                             => wb_clock_s,
179
      reset_i                             => wb_reset_s,
180
      signals_i                           => stimulus_s,
181
      signals_o                           => verify_s
182 2 sinx
      );
183
  -----------------------------------------------------------------------------
184
  -- instance of stimulator
185
  stimulator_inst : entity work.stimulator
186
    generic map(
187 5 sinx
      number_of_signals_g                 => number_of_stimulus_signals_c
188 2 sinx
      )
189
    port map(
190 5 sinx
      wb_i                                => wb_slaves_in_s(0),
191
      wb_o                                => wb_slaves_out_s(0),
192
      signals_o                           => stimulus_s
193 2 sinx
      );
194
  -----------------------------------------------------------------------------
195
  -- instance of stimulator
196
  verifier_inst : entity work.verifier
197
    generic map(
198 5 sinx
      number_of_signals_g                 => number_of_verify_signals_c
199 2 sinx
      )
200
    port map(
201 5 sinx
      wb_i                                => wb_slaves_in_s(1),
202
      wb_o                                => wb_slaves_out_s(1),
203
      signals_i                           => verify_s
204 2 sinx
      );
205
  -----------------------------------------------------------------------------
206 4 sinx
end rtl;
207
----------------------------------------------------------------------
208
---- end of file                                                  ---- 
209
----------------------------------------------------------------------

powered by: WebSVN 2.1.0

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