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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_1/] [bench/] [vhdl/] [tb_t8048.vhd] - Blame information for rev 292

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 arniml
-------------------------------------------------------------------------------
2
--
3
-- The testbench for t8048.
4
--
5 282 arniml
-- $Id: tb_t8048.vhd,v 1.8 2008-04-28 22:10:13 arniml Exp $
6 8 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_t8048 is
50
 
51
end tb_t8048;
52
 
53 240 arniml
 
54 228 arniml
use work.t48_core_comp_pack.generic_ram_ena;
55 233 arniml
use work.t48_system_comp_pack.t8048;
56 8 arniml
 
57
use work.t48_tb_pack.all;
58
 
59
architecture behav of tb_t8048 is
60
 
61
  -- clock period, 11 MHz
62
  constant period_c : time := 90 ns;
63
 
64 233 arniml
  component lpm_rom
65
    generic (
66
      LPM_WIDTH           : positive;
67
      LPM_TYPE            : string    := "LPM_ROM";
68
      LPM_WIDTHAD         : positive;
69
      LPM_NUMWORDS        : natural   := 0;
70
      LPM_FILE            : string;
71
      LPM_ADDRESS_CONTROL : string    := "REGISTERED";
72
      LPM_OUTDATA         : string    := "REGISTERED";
73
      LPM_HINT            : string    := "UNUSED"
74
    );
75 8 arniml
    port (
76 233 arniml
      address             : in  std_logic_vector(LPM_WIDTHAD-1 downto 0);
77
      inclock             : in  std_logic;
78
      outclock            : in  std_logic;
79
      memenab             : in  std_logic;
80
      q                   : out std_logic_vector(LPM_WIDTH-1 downto 0)
81 8 arniml
    );
82
  end component;
83
 
84
  signal xtal_s          : std_logic;
85
  signal res_n_s         : std_logic;
86
  signal int_n_s         : std_logic;
87
  signal ale_s           : std_logic;
88
  signal psen_n_s        : std_logic;
89
  signal prog_n_s        : std_logic;
90
 
91 282 arniml
  signal t0_b : std_logic;
92
 
93 8 arniml
  signal p1_b : std_logic_vector( 7 downto 0);
94
  signal p2_b : std_logic_vector( 7 downto 0);
95
 
96
  signal db_b                : std_logic_vector( 7 downto 0);
97 233 arniml
  signal ext_mem_addr_s      : std_logic_vector(11 downto 0);
98 8 arniml
  signal ext_ram_data_from_s : std_logic_vector( 7 downto 0);
99
  signal ext_ram_we_s        : std_logic;
100 233 arniml
  signal ext_rom_data_s      : std_logic_vector( 7 downto 0);
101 8 arniml
  signal rd_n_s              : std_logic;
102
  signal wr_n_s              : std_logic;
103
 
104
  signal zero_s          : std_logic;
105
  signal one_s           : std_logic;
106
 
107
begin
108
 
109
  zero_s <= '0';
110
  one_s  <= '1';
111
 
112
  p2_b   <= (others => 'H');
113
  p1_b   <= (others => 'H');
114
 
115 233 arniml
  -----------------------------------------------------------------------------
116
  -- External ROM, 3k bytes
117
  -- Initialized by file t48_ext_rom.hex.
118
  -----------------------------------------------------------------------------
119
  ext_rom_b : lpm_rom
120
    generic map (
121
      LPM_WIDTH           => 8,
122
      LPM_TYPE            => "LPM_ROM",
123
      LPM_WIDTHAD         => 12,
124
      LPM_NUMWORDS        => 3 * (2 ** 10),
125
      LPM_FILE            => "rom_t48_ext.hex",
126
      LPM_ADDRESS_CONTROL => "REGISTERED",
127
      LPM_OUTDATA         => "UNREGISTERED",
128
      LPM_HINT            => "UNUSED"
129
    )
130
    port map (
131
      address  => ext_mem_addr_s,
132
      inclock  => xtal_s,
133
      outclock => zero_s,               -- unused
134
      memenab  => one_s,
135
      q        => ext_rom_data_s
136
    );
137
 
138 228 arniml
  ext_ram_b : generic_ram_ena
139 8 arniml
    generic map (
140 228 arniml
      addr_width_g => 8,
141
      data_width_g => 8
142 8 arniml
    )
143
    port map (
144 233 arniml
      clk_i => xtal_s,
145
      a_i   => ext_mem_addr_s(7 downto 0),
146 228 arniml
      we_i  => ext_ram_we_s,
147
      ena_i => one_s,
148
      d_i   => db_b,
149
      d_o   => ext_ram_data_from_s
150 8 arniml
    );
151
 
152
  t8048_b : t8048
153
    port map (
154
      xtal_i    => xtal_s,
155
      reset_n_i => res_n_s,
156 282 arniml
      t0_b      => t0_b,
157 8 arniml
      int_n_i   => int_n_s,
158
      ea_i      => zero_s,
159
      rd_n_o    => rd_n_s,
160
      psen_n_o  => psen_n_s,
161
      wr_n_o    => wr_n_s,
162
      ale_o     => ale_s,
163
      db_b      => db_b,
164 68 arniml
      t1_i      => p1_b(1),
165 8 arniml
      p2_b      => p2_b,
166
      p1_b      => p1_b,
167
      prog_n_o  => prog_n_s
168
    );
169
 
170
 
171 233 arniml
  -----------------------------------------------------------------------------
172
  -- Read from external memory
173
  --
174
  db_b <=   ext_rom_data_s
175
          when psen_n_s = '0' else
176
            (others => 'Z');
177
  db_b <=   ext_ram_data_from_s
178
          when rd_n_s = '0' else
179
            (others => 'Z');
180
  --
181
  -----------------------------------------------------------------------------
182 8 arniml
 
183 233 arniml
 
184 8 arniml
  -----------------------------------------------------------------------------
185
  -- External RAM access signals
186
  --
187
  ext_ram: process (wr_n_s,
188
                    ale_s,
189 233 arniml
                    p2_b,
190 8 arniml
                    db_b)
191
  begin
192 240 arniml
    -- lowest 1k of external ROM is not used
193 233 arniml
    ext_mem_addr_s(11 downto 8) <= To_X01Z(p2_b(3 downto 0));
194
 
195 8 arniml
    if ale_s'event and ale_s = '0' then
196
      if not is_X(db_b) then
197 233 arniml
        ext_mem_addr_s(7 downto 0) <= db_b;
198 8 arniml
      else
199 233 arniml
        ext_mem_addr_s(7 downto 0) <= (others => '0');
200 8 arniml
      end if;
201
    end if;
202
 
203
    if wr_n_s'event and wr_n_s = '1' then
204 233 arniml
      ext_ram_we_s <= '0';
205
    end if;
206
    if wr_n_s'event and wr_n_s = '0' then
207 8 arniml
      ext_ram_we_s <= '1';
208
    end if;
209
 
210
  end process ext_ram;
211
  --
212
  -----------------------------------------------------------------------------
213
 
214 282 arniml
  t0_b <= p1_b(0);
215
 
216 8 arniml
  -----------------------------------------------------------------------------
217
  -- The clock generator
218
  --
219
  clk_gen: process
220
  begin
221
    xtal_s <= '0';
222
    wait for period_c/2;
223
    xtal_s <= '1';
224
    wait for period_c/2;
225
  end process clk_gen;
226
  --
227
  -----------------------------------------------------------------------------
228
 
229
 
230
  -----------------------------------------------------------------------------
231
  -- The reset generator
232
  --
233
  res_gen: process
234
  begin
235
    res_n_s <= '0';
236
    wait for 5 * period_c;
237
    res_n_s <= '1';
238
    wait;
239
  end process res_gen;
240
  --
241
  -----------------------------------------------------------------------------
242
 
243
 
244
  -----------------------------------------------------------------------------
245
  -- The interrupt generator
246
  --
247
  int_gen: process
248
  begin
249
    int_n_s <= '1';
250
    wait for 750 * period_c;
251
    int_n_s <= '0';
252
    wait for  45 * period_c;
253
  end process int_gen;
254
  --
255
  -----------------------------------------------------------------------------
256
 
257
 
258
  -----------------------------------------------------------------------------
259
  -- End of simulation detection
260
  --
261
  eos: process
262
  begin
263
 
264
    outer: loop
265
      wait on tb_accu_s;
266
      if tb_accu_s = "10101010" then
267
        wait on tb_accu_s;
268
        if tb_accu_s = "01010101" then
269
          wait on tb_accu_s;
270
          if tb_accu_s = "00000001" then
271 56 arniml
            -- wait for instruction strobe of this move
272
            wait until tb_istrobe_s'event and tb_istrobe_s = '1';
273
            -- wait for next strobe
274
            wait until tb_istrobe_s'event and tb_istrobe_s = '1';
275 8 arniml
            assert false
276 19 arniml
              report "Simulation Result: PASS."
277 8 arniml
              severity note;
278
          else
279
            assert false
280 19 arniml
              report "Simulation Result: FAIL."
281 8 arniml
              severity note;
282
          end if;
283
 
284
          assert false
285
            report "End of simulation reached."
286
            severity failure;
287
 
288
        end if;
289
      end if;
290
    end loop;
291
 
292
  end process eos;
293
  --
294
  -----------------------------------------------------------------------------
295
 
296
end behav;
297
 
298
 
299
-------------------------------------------------------------------------------
300
-- File History:
301
--
302
-- $Log: not supported by cvs2svn $
303 282 arniml
-- Revision 1.7  2006/06/24 00:51:50  arniml
304
-- comment added about lower 1k of external ROM
305
--
306 240 arniml
-- Revision 1.6  2006/06/22 00:21:28  arniml
307
-- added external ROM
308
--
309 233 arniml
-- Revision 1.5  2006/06/21 01:04:05  arniml
310
-- replaced syn_ram and syn_rom with generic_ram_ena and t48_rom/t49_rom/t3x_rom
311
--
312 228 arniml
-- Revision 1.4  2004/04/18 19:00:58  arniml
313
-- connect T0 and T1 to P1
314
--
315 68 arniml
-- Revision 1.3  2004/04/14 20:57:44  arniml
316
-- wait for instruction strobe after final end-of-simulation detection
317
-- this ensures that the last mov instruction is part of the dump and
318
-- enables 100% matching with i8039 simulator
319
--
320 56 arniml
-- Revision 1.2  2004/03/26 22:39:28  arniml
321
-- enhance simulation result string
322
--
323 19 arniml
-- Revision 1.1  2004/03/24 21:42:10  arniml
324
-- initial check-in
325
--
326 8 arniml
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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