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] - Rev 4
Go to most recent revision | Compare with Previous | Blame | View Log
---------------------------------------------------------------------- ---- ---- ---- VHDL Wishbone TESTBENCH ---- ---- ---- ---- This file is part of the vhdl_wb_tb project ---- ---- https://opencores.org/project/vhdl_wb_tb ---- ---- ---- ---- This file contains the highest (top) module for simulation. ---- ---- Like tb_top it instantiates the core_top module and ---- ---- provides parameters/generics. Where the top module provides ---- ---- parameters for synthesis this file provides parameters for ---- ---- simulation. ---- ---- ---- ---- It instantiates the design under test (DUT), instantiates ---- ---- the stimulator module for test vector generation, ---- ---- instantiates the verifier module for result comparison, ---- ---- instantiates the test case top (testcase_top) bfm, ---- ---- interconnects all three components, generates DUT-external ---- ---- clocks and resets. ---- ---- ---- ---- To Do: ---- ---- - ---- ---- ---- ---- Author(s): ---- ---- - Sinx, sinx@opencores.org ---- ---- ---- ---------------------------------------------------------------------- ---- SVN information ---- ---- $URL: $ ---- $Revision: $ ---- $Date: $ ---- $Author: $ ---- $Id: $ ---------------------------------------------------------------------- ---- ---- ---- Copyright (C) 2018 Authors and OPENCORES.ORG ---- ---- ---- ---- This source file may be used and distributed without ---- ---- restriction provided that this copyright statement is not ---- ---- removed from the file and that any derivative work contains ---- ---- the original copyright notice and the associated disclaimer. ---- ---- ---- ---- This source file is free software; you can redistribute it ---- ---- and/or modify it under the terms of the GNU Lesser General ---- ---- Public License as published by the Free Software Foundation; ---- ---- either version 2.1 of the License, or (at your option) any ---- ---- later version. ---- ---- ---- ---- This source is distributed in the hope that it will be ---- ---- useful, but WITHOUT ANY WARRANTY; without even the implied ---- ---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ---- ---- PURPOSE. See the GNU Lesser General Public License for more ---- ---- details. ---- ---- ---- ---- You should have received a copy of the GNU Lesser General ---- ---- Public License along with this source; if not, download it ---- ---- from http://www.opencores.org/lgpl.shtml ---- ---- ---- ---------------------------------------------------------------------- -- library ----------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; library work; use work.convert_pkg.all; use work.wishbone_pkg.all; use work.wishbone_bfm_pkg.all; -- entity ------------------------------------------------------------ entity tb_top is -- empty entity, since this is the simulation top and all test cases are defined -- in the tc_xxx files. end entity tb_top; -- architecture ------------------------------------------------------ architecture rtl of tb_top is ----------------------------------------------------------------------------- constant g_wb_clock_period : time := 20.0 ns; -- 50 mhz ----------------------------------------------------------------------------- signal s_wb_bfm_out : wishbone_bfm_master_out_t; -- from testcase_top signal s_wb_bfm_in : wishbone_bfm_master_in_t; -- to testcase_top signal s_wb_master_out : wishbone_master_out_t; -- from wb_decoder signal s_wb_master_in : wishbone_master_in_t; -- to wb_decoder constant number_of_wb_slaves_c : integer := 2; signal s_wb_slaves_in : wishbone_slave_in_array_t (number_of_wb_slaves_c-1 downto 0); signal s_wb_slaves_out : wishbone_slave_out_array_t (number_of_wb_slaves_c-1 downto 0); signal s_wb_clock : std_logic := '0'; signal s_wb_clock_locked : std_logic := '0'; signal s_wb_reset_p1 : std_logic := '1'; signal s_wb_reset_p2 : std_logic := '1'; signal s_wb_reset : std_logic := '1'; constant number_of_stimulus_signals_c : integer := 8; constant number_of_verify_signals_c : integer := 8; signal s_stimulus : std_logic_vector(number_of_stimulus_signals_c-1 downto 0); signal s_verify : std_logic_vector(number_of_verify_signals_c-1 downto 0); ----------------------------------------------------------------------------- begin ----------------------------------------------------------------------------- --clocks--------------------------------------------------------------------- wb_clock_generator : process -- required for test bench wb bus; 50mhz is standard begin s_wb_clock <= '0'; wait for g_wb_clock_period/2; s_wb_clock <= '1'; wait for g_wb_clock_period/2; s_wb_clock_locked <= '1'; end process; ----------------------------------------------------------------------------- synchronize_reset_proc : process(all) begin if (s_wb_clock_locked = '0') then s_wb_reset_p1 <= '1'; s_wb_reset_p2 <= '1'; elsif (rising_edge(s_wb_clock)) then s_wb_reset_p1 <= '0'; -- or s_tc_reset; s_wb_reset_p2 <= s_wb_reset_p1; end if; end process; s_wb_reset <= s_wb_reset_p2; ----------------------------------------------------------------------------- -- instance of test case "player"; runs tc_xxxx modules tc_top_inst : entity work.tc_top port map ( wb_o => s_wb_bfm_out, wb_i => s_wb_bfm_in ); ----------------------------------------------------------------------------- -- splits the test case wb bus for all stimulation and verifier modules. -- decodes the given bits (g_decoded_address_msb:g_decoded_address_lsb) and# -- compares them to 0..n, with n=(g_number_of_ports-1) proc_readdata_decoder : process (all) begin s_wb_bfm_in.dat <= (others => 'U'); s_wb_bfm_in.ack <= '1'; s_wb_bfm_in.clk <= s_wb_clock; s_wb_bfm_in.int <= '0'; s_wb_bfm_in.rst <= s_wb_reset; for I in number_of_wb_slaves_c-1 downto 0 loop s_wb_slaves_in(I) <= work.wishbone_pkg.wb_master_out_idle_c; -- default values are init (idle) values s_wb_slaves_in(I).clk <= s_wb_clock; s_wb_slaves_in(I).rst <= s_wb_reset OR s_wb_bfm_out.rst; if ( s_wb_bfm_out.adr(31 downto 28) = to_std_logic_vector(I,4)) then -- decode the upper nibble for module decoding s_wb_bfm_in.dat <= s_wb_slaves_out(I).dat; s_wb_bfm_in.ack <= s_wb_slaves_out(I).ack; s_wb_slaves_in(I).dat <= s_wb_bfm_out.dat; s_wb_slaves_in(I).tgd <= s_wb_bfm_out.tgd; s_wb_slaves_in(I).adr <= s_wb_bfm_out.adr; s_wb_slaves_in(I).cyc <= s_wb_bfm_out.cyc; s_wb_slaves_in(I).lock <= s_wb_bfm_out.lock; s_wb_slaves_in(I).sel <= s_wb_bfm_out.sel; s_wb_slaves_in(I).stb <= s_wb_bfm_out.stb; s_wb_slaves_in(I).tga <= s_wb_bfm_out.tga; s_wb_slaves_in(I).tgc <= s_wb_bfm_out.tgc; s_wb_slaves_in(I).we <= s_wb_bfm_out.we; end if; end loop; end process; ----------------------------------------------------------------------------- -- instance of design under test core_top_inst : entity work.core_top generic map( g_number_of_in_signals => number_of_stimulus_signals_c, g_number_of_out_signals => number_of_verify_signals_c ) port map( clock_i => s_wb_clock, reset_i => s_wb_reset, signals_i => s_stimulus, signals_o => s_verify ); ----------------------------------------------------------------------------- -- instance of stimulator stimulator_inst : entity work.stimulator generic map( g_number_of_signals => number_of_stimulus_signals_c ) port map( wb_i => s_wb_slaves_in(0), wb_o => s_wb_slaves_out(0), signals_o => s_stimulus ); ----------------------------------------------------------------------------- -- instance of stimulator verifier_inst : entity work.verifier generic map( g_number_of_signals => number_of_verify_signals_c ) port map( wb_i => s_wb_slaves_in(1), wb_o => s_wb_slaves_out(1), signals_i => s_verify ); ----------------------------------------------------------------------------- end rtl; ---------------------------------------------------------------------- ---- end of file ---- ----------------------------------------------------------------------
Go to most recent revision | Compare with Previous | Blame | View Log