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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_1/] [bench/] [vhdl/] [tb_t8039.vhd] - Blame information for rev 228

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

Line No. Rev Author Line
1 67 arniml
-------------------------------------------------------------------------------
2
--
3
-- The testbench for t8039.
4
--
5 228 arniml
-- $Id: tb_t8039.vhd,v 1.3 2006-06-21 01:04:05 arniml Exp $
6 67 arniml
--
7
-- Copyright (c) 2004, Arnim Laeuger (arniml@opencores.org)
8
--
9
-- All rights reserved
10
--
11
-- Redistribution and use in source and synthezised forms, with or without
12
-- modification, are permitted provided that the following conditions are met:
13
--
14
-- Redistributions of source code must retain the above copyright notice,
15
-- this list of conditions and the following disclaimer.
16
--
17
-- Redistributions in synthesized form must reproduce the above copyright
18
-- notice, this list of conditions and the following disclaimer in the
19
-- documentation and/or other materials provided with the distribution.
20
--
21
-- Neither the name of the author nor the names of other contributors may
22
-- be used to endorse or promote products derived from this software without
23
-- specific prior written permission.
24
--
25
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
-- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
29
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
-- POSSIBILITY OF SUCH DAMAGE.
36
--
37
-- Please report bugs to the author, but before you do so, please
38
-- make sure that this is not a derivative work and that
39
-- you have the latest version of this file.
40
--
41
-- The latest version of this file can be found at:
42
--      http://www.opencores.org/cvsweb.shtml/t48/
43
--
44
-------------------------------------------------------------------------------
45
 
46
library ieee;
47
use ieee.std_logic_1164.all;
48
 
49
entity tb_t8039 is
50
 
51
end tb_t8039;
52
 
53 228 arniml
use work.t48_core_comp_pack.generic_ram_ena;
54
use work.t48_system_comp_pack.t8039;
55 67 arniml
 
56
use work.t48_tb_pack.all;
57
 
58
architecture behav of tb_t8039 is
59
 
60
  -- clock period, 11 MHz
61
  constant period_c : time := 90 ns;
62
 
63 228 arniml
  component lpm_rom
64
    generic (
65
      LPM_WIDTH           : positive;
66
      LPM_TYPE            : string    := "LPM_ROM";
67
      LPM_WIDTHAD         : positive;
68
      LPM_NUMWORDS        : natural   := 0;
69
      LPM_FILE            : string;
70
      LPM_ADDRESS_CONTROL : string    := "REGISTERED";
71
      LPM_OUTDATA         : string    := "REGISTERED";
72
      LPM_HINT            : string    := "UNUSED"
73
    );
74 67 arniml
    port (
75 228 arniml
      address             : in  std_logic_vector(LPM_WIDTHAD-1 downto 0);
76
      inclock             : in  std_logic;
77
      outclock            : in  std_logic;
78
      memenab             : in  std_logic;
79
      q                   : out std_logic_vector(LPM_WIDTH-1 downto 0)
80 67 arniml
    );
81
  end component;
82
 
83
  signal xtal_s          : std_logic;
84
  signal res_n_s         : std_logic;
85
  signal int_n_s         : std_logic;
86
  signal ale_s           : std_logic;
87
  signal psen_n_s        : std_logic;
88
  signal prog_n_s        : std_logic;
89
  signal rom_addr_s      : std_logic_vector(11 downto 0);
90
  signal rom_data_s      : std_logic_vector( 7 downto 0);
91
  signal ram_data_to_s   : std_logic_vector( 7 downto 0);
92
  signal ram_data_from_s : std_logic_vector( 7 downto 0);
93
  signal ram_addr_s      : std_logic_vector( 7 downto 0);
94
  signal ram_we_s        : std_logic;
95
 
96
  signal p1_b : std_logic_vector( 7 downto 0);
97
  signal p2_b : std_logic_vector( 7 downto 0);
98
 
99
  signal db_b                : std_logic_vector( 7 downto 0);
100
  signal ext_mem_addr_s      : std_logic_vector(11 downto 0);
101
  signal ext_ram_data_from_s : std_logic_vector( 7 downto 0);
102
  signal ext_ram_we_s        : std_logic;
103
  signal ext_rom_data_s      : std_logic_vector( 7 downto 0);
104
  signal rd_n_s              : std_logic;
105
  signal wr_n_s              : std_logic;
106
 
107
  signal zero_s          : std_logic;
108
  signal one_s           : std_logic;
109
 
110
begin
111
 
112
  zero_s <= '0';
113
  one_s  <= '1';
114
 
115
  p2_b   <= (others => 'H');
116
  p1_b   <= (others => 'H');
117
 
118 228 arniml
  -----------------------------------------------------------------------------
119
  -- External ROM, 4k bytes
120
  -- Initialized by file t3x_ext_rom.hex.
121
  -----------------------------------------------------------------------------
122
  ext_rom_b : lpm_rom
123 67 arniml
    generic map (
124 228 arniml
      LPM_WIDTH           => 8,
125
      LPM_TYPE            => "LPM_ROM",
126
      LPM_WIDTHAD         => 12,
127
      LPM_NUMWORDS        => 2 ** 12,
128
      LPM_FILE            => "rom_t3x_ext.hex",
129
      LPM_ADDRESS_CONTROL => "REGISTERED",
130
      LPM_OUTDATA         => "UNREGISTERED",
131
      LPM_HINT            => "UNUSED"
132 67 arniml
    )
133
    port map (
134 228 arniml
      address  => ext_mem_addr_s,
135
      inclock  => xtal_s,
136
      outclock => zero_s,               -- unused
137
      memenab  => one_s,
138
      q        => ext_rom_data_s
139 67 arniml
    );
140
 
141 228 arniml
  ext_ram_b : generic_ram_ena
142 67 arniml
    generic map (
143 228 arniml
      addr_width_g => 8,
144
      data_width_g => 8
145 67 arniml
    )
146
    port map (
147 228 arniml
      clk_i => xtal_s,
148
      a_i   => ext_mem_addr_s(7 downto 0),
149
      we_i  => ext_ram_we_s,
150
      ena_i => one_s,
151
      d_i   => db_b,
152
      d_o   => ext_ram_data_from_s
153 67 arniml
    );
154
 
155
  t8039_b : t8039
156
    port map (
157
      xtal_i    => xtal_s,
158
      reset_n_i => res_n_s,
159
      t0_b      => p1_b(0),
160
      int_n_i   => int_n_s,
161
      ea_i      => one_s,
162
      rd_n_o    => rd_n_s,
163
      psen_n_o  => psen_n_s,
164
      wr_n_o    => wr_n_s,
165
      ale_o     => ale_s,
166
      db_b      => db_b,
167
      t1_i      => p1_b(1),
168
      p2_b      => p2_b,
169
      p1_b      => p1_b,
170
      prog_n_o  => prog_n_s
171
    );
172
 
173
 
174
  -----------------------------------------------------------------------------
175
  -- Read from external memory
176
  --
177
  db_b <=   ext_rom_data_s
178
          when psen_n_s = '0' else
179
            (others => 'Z');
180
  db_b <=   ext_ram_data_from_s
181
          when rd_n_s = '0' else
182
            (others => 'Z');
183
  --
184
  -----------------------------------------------------------------------------
185
 
186
 
187
  -----------------------------------------------------------------------------
188
  -- External memory access signals
189
  --
190
  ext_mem: process (wr_n_s,
191
                    ale_s,
192
                    p2_b,
193
                    db_b)
194
  begin
195 202 arniml
    ext_mem_addr_s(11 downto 8) <= To_X01Z(p2_b(3 downto 0));
196 67 arniml
 
197
    if ale_s = '1' then
198
      if not is_X(db_b) then
199
        ext_mem_addr_s(7 downto 0) <= db_b;
200
      else
201
        ext_mem_addr_s(7 downto 0) <= (others => '0');
202
      end if;
203
    end if;
204
 
205
    if wr_n_s'event and wr_n_s = '1' then
206
      ext_ram_we_s <= '1';
207
    end if;
208
 
209
--    if clk_s'event then
210
--      ext_ram_we_s <= '0';
211
--    end if;
212
 
213
  end process ext_mem;
214
  --
215
  -----------------------------------------------------------------------------
216
 
217
  -----------------------------------------------------------------------------
218
  -- The clock generator
219
  --
220
  clk_gen: process
221
  begin
222
    xtal_s <= '0';
223
    wait for period_c/2;
224
    xtal_s <= '1';
225
    wait for period_c/2;
226
  end process clk_gen;
227
  --
228
  -----------------------------------------------------------------------------
229
 
230
 
231
  -----------------------------------------------------------------------------
232
  -- The reset generator
233
  --
234
  res_gen: process
235
  begin
236
    res_n_s <= '0';
237
    wait for 5 * period_c;
238
    res_n_s <= '1';
239
    wait;
240
  end process res_gen;
241
  --
242
  -----------------------------------------------------------------------------
243
 
244
 
245
  -----------------------------------------------------------------------------
246
  -- The interrupt generator
247
  --
248
  int_gen: process
249
  begin
250
    int_n_s <= '1';
251
    wait for 750 * period_c;
252
    int_n_s <= '0';
253
    wait for  45 * period_c;
254
  end process int_gen;
255
  --
256
  -----------------------------------------------------------------------------
257
 
258
 
259
  -----------------------------------------------------------------------------
260
  -- End of simulation detection
261
  --
262
  eos: process
263
  begin
264
 
265
    outer: loop
266
      wait on tb_accu_s;
267
      if tb_accu_s = "10101010" then
268
        wait on tb_accu_s;
269
        if tb_accu_s = "01010101" then
270
          wait on tb_accu_s;
271
          if tb_accu_s = "00000001" then
272
            -- wait for instruction strobe of this move
273
            wait until tb_istrobe_s'event and tb_istrobe_s = '1';
274
            -- wait for next strobe
275
            wait until tb_istrobe_s'event and tb_istrobe_s = '1';
276
            assert false
277
              report "Simulation Result: PASS."
278
              severity note;
279
          else
280
            assert false
281
              report "Simulation Result: FAIL."
282
              severity note;
283
          end if;
284
 
285
          assert false
286
            report "End of simulation reached."
287
            severity failure;
288
 
289
        end if;
290
      end if;
291
    end loop;
292
 
293
  end process eos;
294
  --
295
  -----------------------------------------------------------------------------
296
 
297
end behav;
298
 
299
 
300
-------------------------------------------------------------------------------
301
-- File History:
302
--
303
-- $Log: not supported by cvs2svn $
304 228 arniml
-- Revision 1.2  2005/11/01 21:22:28  arniml
305
-- fix address assignment
306
--
307 202 arniml
-- Revision 1.1  2004/04/18 19:00:07  arniml
308
-- initial check-in
309
--
310 67 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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