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

Subversion Repositories t400

[/] [t400/] [trunk/] [bench/] [vhdl/] [tb_int.vhd] - Blame information for rev 179

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 63 arniml
-------------------------------------------------------------------------------
2
--
3
-- Testbench for interrupt evaluation.
4
--
5 179 arniml
-- $Id: tb_int.vhd 179 2009-04-01 19:48:38Z arniml $
6 63 arniml
--
7
-- Copyright (c) 2006 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/t400/
43
--
44
-------------------------------------------------------------------------------
45
 
46
entity tb_int is
47
 
48
end tb_int;
49
 
50
 
51
library ieee;
52
use ieee.std_logic_1164.all;
53
use ieee.numeric_std.all;
54
 
55
use work.t400_system_comp_pack.t420;
56
use work.tb_pack.all;
57
use work.t400_opt_pack.all;
58
 
59
architecture behav of tb_int is
60
 
61
  -- 210.4 kHz clock
62
  constant period_c : time := 4.75 us;
63
  signal   ck_s     : std_logic;
64
 
65
  signal reset_n_s  : std_logic;
66
 
67
  signal io_l_s     : std_logic_vector(7 downto 0);
68
  signal io_d_s     : std_logic_vector(3 downto 0);
69
  signal io_g_s     : std_logic_vector(3 downto 0);
70
  signal io_in_s    : std_logic_vector(3 downto 0);
71
 
72
  signal si_s,
73
         so_s,
74
         sk_s       : std_logic;
75
 
76
  signal vdd_8_s    : std_logic_vector(7 downto 0);
77
 
78
begin
79
 
80
 
81
  vdd_8_s   <= (others => '1');
82
  reset_n_s <= '1';
83
 
84
  -----------------------------------------------------------------------------
85
  -- DUT
86
  -----------------------------------------------------------------------------
87
  t420_b : t420
88
    generic map (
89 97 arniml
      opt_ck_div_g       => t400_opt_ck_div_4_c,
90
      opt_l_out_type_3_g => t400_opt_out_type_od_c,
91
      opt_l_out_type_2_g => t400_opt_out_type_od_c,
92
      opt_l_out_type_1_g => t400_opt_out_type_od_c,
93
      opt_l_out_type_0_g => t400_opt_out_type_od_c
94 63 arniml
    )
95
    port map (
96
      ck_i      => ck_s,
97
      ck_en_i   => vdd_8_s(0),
98
      reset_n_i => reset_n_s,
99
      cko_i     => io_in_s(2),
100
      si_i      => si_s,
101
      so_o      => so_s,
102
      sk_o      => sk_s,
103
      io_l_b    => io_l_s,
104
      io_d_o    => io_d_s,
105
      io_g_b    => io_g_s,
106
      io_in_i   => io_in_s
107
    );
108
 
109
  io_l_s  <= (others => 'H');
110
  io_d_s  <= (others => 'H');
111
  io_g_s  <= (others => 'H');
112
  io_in_s <= (others => 'H');
113
 
114
 
115
  -----------------------------------------------------------------------------
116
  -- Testbench elements
117
  -----------------------------------------------------------------------------
118
  tb_elems_b : tb_elems
119
    generic map (
120
      period_g  => period_c,
121
      d_width_g => 4,
122
      g_width_g => 4
123
    )
124
    port map (
125
      io_l_i  => vdd_8_s,
126
      io_d_i  => io_d_s,
127 78 arniml
      io_g_i  => vdd_8_s(3 downto 0),
128 63 arniml
      io_in_o => open,
129
      so_i    => so_s,
130
      si_o    => si_s,
131
      sk_i    => sk_s,
132
      ck_o    => ck_s
133
    );
134
 
135
 
136
  -----------------------------------------------------------------------------
137
  -- Process int
138
  --
139
  -- Purpose:
140
  --   Generates interrupts based on current PC.
141
  --
142
  int: process
143
    variable int_v : std_logic;
144
  begin
145
    loop
146
      wait until tb_pc_s'event;
147
      -- see if we need to generate an interrupt
148
      case to_integer(tb_pc_s) is
149
        when 16#030# =>
150
          int_v := '0';
151
        when 16#0b0# =>
152
          int_v := '0';
153
        when 16#1b0# =>
154
          int_v := '0';
155
        when 16#230# =>
156
          int_v := '0';
157
        when 16#2b0# =>
158
          int_v := '0';
159
        when 16#330# =>
160
          int_v := '0';
161
        when 16#3b0# =>
162
          int_v := '0';
163
        when others =>
164
          int_v := 'H';
165
      end case;
166
 
167
      io_in_s(1) <= int_v;
168
 
169
      if int_v = '0' then
170
        -- wait for appropriate interrupt active time
171
        wait for period_c * 4 * 3;        -- three instruction cycles
172
        io_in_s(1) <= 'H';
173
      end if;
174
    end loop;
175
  end process int;
176
  --
177
  -----------------------------------------------------------------------------
178
 
179 78 arniml
 
180
  -----------------------------------------------------------------------------
181
  -- MUX the nibbles of SA to L
182
  -----------------------------------------------------------------------------
183
  io_l_s(3 downto 0) <=   std_logic_vector(tb_sa_s(3 downto 0))
184
                        when io_g_s(1 downto 0) = "00" else
185
                          std_logic_vector(tb_sa_s(7 downto 4))
186
                        when io_g_s(1 downto 0) = "01" else
187
                          '0' & '0' & std_logic_vector(tb_sa_s(9 downto 8))
188
                        when io_g_s(1 downto 0) = "10" else
189
                          (others => 'H');
190
 
191 63 arniml
end behav;

powered by: WebSVN 2.1.0

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