source: Hardware/WARP_v3/Rev1.1/Config_CPLD/src/spi_boot_OpenCores_src/bench/vhdl/tb.vhd

Last change on this file was 1799, checked in by murphpo, 12 years ago

Adding WARP v3 hardware files (schematics, FPGA pinout, configuration CPLD source)

File size: 5.5 KB
Line 
1-------------------------------------------------------------------------------
2--
3-- SD/MMC Bootloader
4-- Testbench
5--
6-- $Id: tb.vhd 77 2009-04-01 19:53:14Z arniml $
7--
8-- Copyright (c) 2005, Arnim Laeuger (arniml@opencores.org)
9--
10-- All rights reserved, see COPYING.
11--
12-- Redistribution and use in source and synthezised forms, with or without
13-- modification, are permitted provided that the following conditions are met:
14--
15-- Redistributions of source code must retain the above copyright notice,
16-- this list of conditions and the following disclaimer.
17--
18-- Redistributions in synthesized form must reproduce the above copyright
19-- notice, this list of conditions and the following disclaimer in the
20-- documentation and/or other materials provided with the distribution.
21--
22-- Neither the name of the author nor the names of other contributors may
23-- be used to endorse or promote products derived from this software without
24-- specific prior written permission.
25--
26-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
30-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36-- POSSIBILITY OF SUCH DAMAGE.
37--
38-- Please report bugs to the author, but before you do so, please
39-- make sure that this is not a derivative work and that
40-- you have the latest version of this file.
41--
42-- The latest version of this file can be found at:
43--      http://www.opencores.org/projects.cgi/web/spi_boot/overview
44--
45-------------------------------------------------------------------------------
46
47entity tb is
48
49end tb;
50
51
52library ieee;
53use ieee.std_logic_1164.all;
54
55architecture behav of tb is
56
57  component tb_elem
58    generic (
59      chip_type_g   : string := "none";
60      has_sd_card_g : integer := 1
61    );
62    port (
63      clk_i   : in  std_logic;
64      reset_i : in  std_logic;
65      eos_o   : out boolean
66    );
67  end component;
68
69  constant period_c      : time := 100 ns;
70  constant reset_level_c : integer := 0;
71
72  signal clk_s   : std_logic;
73  signal reset_s : std_logic;
74
75  signal eos_full_s,
76         eos_mmc_s,
77         eos_sd_s,
78         eos_minimal_s : boolean;
79
80begin
81
82
83  -----------------------------------------------------------------------------
84  -- Testbench element including full featured chip
85  -----------------------------------------------------------------------------
86  tb_elem_full_b : tb_elem
87    generic map (
88      chip_type_g   => "Full Chip",
89      has_sd_card_g => 1
90    )
91    port map (
92      clk_i   => clk_s,
93      reset_i => reset_s,
94      eos_o   => eos_full_s
95    );
96
97
98  -----------------------------------------------------------------------------
99  -- Testbench element including MMC chip
100  -----------------------------------------------------------------------------
101  tb_elem_mmc_b : tb_elem
102    generic map (
103      chip_type_g   => "MMC Chip",
104      has_sd_card_g => 0
105    )
106    port map (
107      clk_i   => clk_s,
108      reset_i => reset_s,
109      eos_o   => eos_mmc_s
110    );
111
112
113  -----------------------------------------------------------------------------
114  -- Testbench element including SD chip
115  -----------------------------------------------------------------------------
116  tb_elem_sd_b : tb_elem
117    generic map (
118      chip_type_g   => "SD Chip",
119      has_sd_card_g => 1
120    )
121    port map (
122      clk_i   => clk_s,
123      reset_i => reset_s,
124      eos_o   => eos_sd_s
125    );
126
127
128  -----------------------------------------------------------------------------
129  -- Testbench element including cip with minimal features
130  -----------------------------------------------------------------------------
131  tb_elem_minimal_b : tb_elem
132    generic map (
133      chip_type_g   => "Minimal Chip",
134      has_sd_card_g => 0
135    )
136    port map (
137      clk_i   => clk_s,
138      reset_i => reset_s,
139      eos_o   => eos_minimal_s
140    );
141
142
143  -----------------------------------------------------------------------------
144  -- Clock Generator
145  -----------------------------------------------------------------------------
146  clk: process
147  begin
148    clk_s <= '0';
149    wait for period_c / 2;
150    clk_s <= '1';
151    wait for period_c / 2;
152  end process clk;
153
154
155  -----------------------------------------------------------------------------
156  -- Reset Generator
157  -----------------------------------------------------------------------------
158  reset: process
159  begin
160    if reset_level_c = 0 then
161      reset_s <= '0';
162    else
163      reset_s <= '1';
164    end if;
165
166    wait for period_c * 4 + 10 ns;
167
168    reset_s <= not reset_s;
169
170    wait;
171  end process reset;
172
173
174  -----------------------------------------------------------------------------
175  -- End Of Simulation Detection
176  -----------------------------------------------------------------------------
177  eos: process (eos_full_s,
178                eos_mmc_s,
179                eos_sd_s,
180                eos_minimal_s)
181  begin
182
183    if eos_full_s and eos_mmc_s and eos_sd_s and eos_minimal_s then
184      assert false
185        report "End of Simulation."
186        severity failure;
187    end if;
188
189  end process eos;
190
191end behav;
Note: See TracBrowser for help on using the repository browser.