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

Subversion Repositories System11

[/] [System11/] [trunk/] [rtl/] [vhdl/] [testbench5.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 dilbert57
--===========================================================================--
2
--
3
-- CPU11 Microprocessor Test Bench 5
4
--
5
-- CPU11, ROM & RAM test
6
--
7
-- John Kent 21st October 2002
8
--
9
--
10
-------------------------------------------------------------------------------
11
library ieee;
12
   use ieee.std_logic_1164.all;
13
   use IEEE.STD_LOGIC_ARITH.ALL;
14
   use IEEE.STD_LOGIC_UNSIGNED.ALL;
15
   use ieee.numeric_std.all;
16
 
17
entity my_testbench5 is
18
end my_testbench5;
19
 
20
-------------------------------------------------------------------------------
21
-- Architecture for CPU11 Testbench 5
22
-------------------------------------------------------------------------------
23
architecture behavior of my_testbench5 is
24
  -----------------------------------------------------------------------------
25
  -- Signals
26
  -----------------------------------------------------------------------------
27
  signal uart_irq    : Std_Logic;
28
  signal timer_irq   : std_logic;
29
 
30
  -- Sequencer Interface signals
31
  signal SysClk      : Std_Logic;
32
  signal cpu_reset   : Std_Logic;
33
  signal cpu_rw      : std_logic;
34
  signal cpu_vma     : std_logic;
35
  signal cpu_addr    : Std_Logic_Vector(15 downto 0);
36
  signal cpu_data_in : Std_Logic_Vector(7 downto 0);
37
  signal cpu_data_out: Std_Logic_Vector(7 downto 0);
38
  signal rom_data_out: Std_Logic_Vector(7 downto 0);
39
  signal ram0_data_out: Std_Logic_Vector(7 downto 0);
40
  signal ram0_cs      : std_logic;
41
  signal ram1_data_out: Std_Logic_Vector(7 downto 0);
42
  signal ram1_cs      : std_logic;
43
  signal ram2_data_out: Std_Logic_Vector(7 downto 0);
44
  signal ram2_cs      : std_logic;
45
  signal ram3_data_out: Std_Logic_Vector(7 downto 0);
46
  signal ram3_cs      : std_logic;
47
  signal ram4_data_out: Std_Logic_Vector(7 downto 0);
48
  signal ram4_cs      : std_logic;
49
  signal ram5_data_out: Std_Logic_Vector(7 downto 0);
50
  signal ram5_cs      : std_logic;
51
  signal ram6_data_out: Std_Logic_Vector(7 downto 0);
52
  signal ram6_cs      : std_logic;
53
  signal ram7_data_out: Std_Logic_Vector(7 downto 0);
54
  signal ram7_cs      : std_logic;
55
 
56
component cpu11
57
  port (
58
    data_in:  in        std_logic_vector(7 downto 0);
59
         data_out: out std_logic_vector(7 downto 0);
60
    address:  out       std_logic_vector(15 downto 0);
61
    vma:             out        std_logic;
62
    rw:      out        std_logic;              -- Asynchronous memory interface
63
    rst:             in std_logic;
64
         clk:        in std_logic;
65
         irq:      in  std_logic;
66
         xirq:     in  std_logic
67
  );
68
end component;
69
 
70
component my_ram
71
        port (
72
         clk       : in  std_logic;
73
    rst       : in  std_logic;
74
    cs        : in  std_logic;
75
    rw        : in  std_logic;
76
    addr      : in  std_logic_vector(3 downto 0);
77
         data_in   : in  std_logic_vector(7 downto 0);
78
         data_out  : out std_logic_vector(7 downto 0)
79
         );
80
end component;
81
 
82
 
83
component boot_rom
84
  port (
85
    addr  : in  Std_Logic_Vector(9 downto 0);  -- 1K byte boot rom
86
         data  : out Std_Logic_Vector(7 downto 0)
87
  );
88
end component;
89
 
90
begin
91
cpu : cpu11  port map (
92
    data_in   => cpu_data_in,
93
         data_out  => cpu_data_out,
94
    address   => cpu_addr(15 downto 0),
95
    vma       => cpu_vma,
96
    rw       => cpu_rw,
97
    rst      => cpu_reset,
98
         clk         => SysClk,
99
         irq       => uart_irq,
100
         xirq      => timer_irq
101
  );
102
 
103
sram0 : my_ram port map (
104
         clk       => SysClk,
105
    rst       => cpu_reset,
106
    cs        => ram0_cs,
107
    rw        => cpu_rw,
108
    addr      => cpu_addr(3 downto 0),
109
         data_in   => cpu_data_out,
110
         data_out  => ram0_data_out
111
         );
112
 
113
sram1 : my_ram port map (
114
         clk       => SysClk,
115
    rst       => cpu_reset,
116
    cs        => ram1_cs,
117
    rw        => cpu_rw,
118
    addr      => cpu_addr(3 downto 0),
119
         data_in   => cpu_data_out,
120
         data_out  => ram1_data_out
121
         );
122
 
123
sram2 : my_ram port map (
124
         clk       => SysClk,
125
    rst       => cpu_reset,
126
    cs        => ram2_cs,
127
    rw        => cpu_rw,
128
    addr      => cpu_addr(3 downto 0),
129
         data_in   => cpu_data_out,
130
         data_out  => ram2_data_out
131
         );
132
 
133
sram3 : my_ram port map (
134
         clk       => SysClk,
135
    rst       => cpu_reset,
136
    cs        => ram3_cs,
137
    rw        => cpu_rw,
138
    addr      => cpu_addr(3 downto 0),
139
         data_in   => cpu_data_out,
140
         data_out  => ram3_data_out
141
         );
142
 
143
sram4 : my_ram port map (
144
         clk       => SysClk,
145
    rst       => cpu_reset,
146
    cs        => ram4_cs,
147
    rw        => cpu_rw,
148
    addr      => cpu_addr(3 downto 0),
149
         data_in   => cpu_data_out,
150
         data_out  => ram4_data_out
151
         );
152
 
153
sram5 : my_ram port map (
154
         clk       => SysClk,
155
    rst       => cpu_reset,
156
    cs        => ram5_cs,
157
    rw        => cpu_rw,
158
    addr      => cpu_addr(3 downto 0),
159
         data_in   => cpu_data_out,
160
         data_out  => ram5_data_out
161
         );
162
 
163
sram6 : my_ram port map (
164
         clk       => SysClk,
165
    rst       => cpu_reset,
166
    cs        => ram6_cs,
167
    rw        => cpu_rw,
168
    addr      => cpu_addr(3 downto 0),
169
         data_in   => cpu_data_out,
170
         data_out  => ram6_data_out
171
         );
172
 
173
sram7 : my_ram port map (
174
         clk       => SysClk,
175
    rst       => cpu_reset,
176
    cs        => ram7_cs,
177
    rw        => cpu_rw,
178
    addr      => cpu_addr(3 downto 0),
179
         data_in   => cpu_data_out,
180
         data_out  => ram7_data_out
181
         );
182
 
183
  rom : boot_rom port map (
184
         addr       => cpu_addr(9 downto 0),
185
    data       => rom_data_out
186
         );
187
 
188
decode : process( cpu_addr, cpu_vma, rom_data_out,
189
                  ram0_data_out, ram1_data_out, ram2_data_out, ram3_data_out,
190
                                                ram4_data_out, ram5_data_out, ram6_data_out, ram7_data_out  )
191
begin
192
   ram0_cs <= '0';
193
   ram1_cs <= '0';
194
   ram2_cs <= '0';
195
   ram3_cs <= '0';
196
   ram4_cs <= '0';
197
   ram5_cs <= '0';
198
   ram6_cs <= '0';
199
   ram7_cs <= '0';
200
   case cpu_addr(15 downto 13) is
201
        when "111" =>
202
           cpu_data_in <= rom_data_out;
203
   when "101" =>
204
           case cpu_addr(6 downto 4 ) is
205
                when "000" =>
206
             cpu_data_in <= ram0_data_out;
207
                  ram0_cs <= cpu_vma;
208
                when "001" =>
209
             cpu_data_in <= ram1_data_out;
210
                  ram1_cs <= cpu_vma;
211
                when "010" =>
212
             cpu_data_in <= ram2_data_out;
213
                  ram2_cs <= cpu_vma;
214
                when "011" =>
215
             cpu_data_in <= ram3_data_out;
216
                  ram3_cs <= cpu_vma;
217
                when "100" =>
218
             cpu_data_in <= ram4_data_out;
219
                  ram4_cs <= cpu_vma;
220
                when "101" =>
221
             cpu_data_in <= ram5_data_out;
222
                  ram5_cs <= cpu_vma;
223
                when "110" =>
224
             cpu_data_in <= ram6_data_out;
225
                  ram6_cs <= cpu_vma;
226
                when "111" =>
227
             cpu_data_in <= ram7_data_out;
228
                  ram7_cs <= cpu_vma;
229
      when others =>
230
                  null;
231
      end case;
232
   when others =>
233
           cpu_data_in <= "00000000";
234
   end case;
235
end process;
236
 
237
  -- *** Test Bench - User Defined Section ***
238
   tb : PROCESS
239
        variable count : integer;
240
   BEGIN
241
 
242
        cpu_reset <= '0';
243
        SysClk <= '0';
244
   uart_irq <= '0';
245
        timer_irq <= '0';
246
 
247
                for count in 0 to 256 loop
248
                        SysClk <= '0';
249
                        if count = 0 then
250
                                cpu_reset <= '1';
251
                        elsif count = 1 then
252
                                cpu_reset <= '0';
253
                        end if;
254
                        wait for 100 ns;
255
                        SysClk <= '1';
256
                        wait for 100 ns;
257
                end loop;
258
 
259
      wait; -- will wait forever
260
   END PROCESS;
261
-- *** End Test Bench - User Defined Section ***
262
 
263
end behavior; --===================== End of architecture =======================--
264
 

powered by: WebSVN 2.1.0

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