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

Subversion Repositories System09

[/] [System09/] [tags/] [V10/] [rtl/] [vhdl/] [testbench2.vhd] - Blame information for rev 201

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

Line No. Rev Author Line
1 2 dilbert57
--===========================================================================----
2
--
3
--  T E S T B E N C H    tesetbench2 - CPU09 Testbench.
4
--
5
--  www.OpenCores.Org - September 2003
6
--  This core adheres to the GNU public license  
7
--
8
-- File name      : Testbench2.vhd
9
--
10
-- Purpose        : cpu09 Microprocessor Test Bench 2
11
--                  Contains ROM to read sector from
12
--                  a none existant Compact Flash module
13
--
14
-- Dependencies   : ieee.Std_Logic_1164
15
--                  ieee.std_logic_unsigned
16
--                  ieee.std_logic_arith
17
--                  ieee.numeric_std
18
--
19
-- Uses           : cpu09    (cpu09.vhd)      CPU core
20
--                   
21
-- Author         : John E. Kent
22
--                  dilbert57@opencores.org      
23
--
24
--===========================================================================----
25
--
26
-- Revision History:
27
--===========================================================================--
28
--
29
-- Version 0.1 - 12st April 2003 - John Kent 
30
-- First version
31
--
32
-- Version 1.0- 6 Sep 2003 - John Kent
33
-- Initial release to Open Cores
34
--
35
--===========================================================================--
36
 
37
library ieee;
38
   use ieee.std_logic_1164.all;
39
   use IEEE.STD_LOGIC_ARITH.ALL;
40
   use IEEE.STD_LOGIC_UNSIGNED.ALL;
41
   use ieee.numeric_std.all;
42
 
43
entity my_testbench is
44
end my_testbench;
45
 
46
-------------------------------------------------------------------------------
47
-- Architecture for memio Controller Unit
48
-------------------------------------------------------------------------------
49
architecture behavior of my_testbench is
50
  -----------------------------------------------------------------------------
51
  -- Signals
52
  -----------------------------------------------------------------------------
53
 
54
  -- CPU Interface signals
55
  signal SysClk      : Std_Logic;
56
  signal cpu_reset   : Std_Logic;
57
  signal cpu_rw      : Std_Logic;
58
  signal cpu_vma     : Std_Logic;
59
  signal cpu_addr    : Std_Logic_Vector(15 downto 0);
60
  signal cpu_data_in : Std_Logic_Vector(7 downto 0);
61
  signal cpu_data_out: Std_Logic_Vector(7 downto 0);
62
  signal cpu_alu     : Std_Logic_Vector(15 downto 0);
63
  signal cpu_cc      : Std_Logic_Vector(7 downto 0);
64
  signal cpu_irq     : Std_Logic;
65
  signal cpu_nmi     : Std_Logic;
66
  signal cpu_firq    : std_logic;
67
 
68
  constant width   : integer := 8;
69
  constant memsize : integer := 128;
70
 
71
  type rom_array is array(0 to memsize-1) of std_logic_vector(width-1 downto 0);
72
 
73
  constant rom_data : rom_array :=
74
  (
75
"00010000", -- $F800 LDS #$F878 (Point to dummy return to test stack)
76
"11001110",
77
"11111000",
78
"01111000",
79
"10000110", -- $F804 LDA #$E0 *** START
80
"11100000",
81
"00011111", -- $F806 TFR A,DPR
82
"10001011",
83
---------------------------
84
-- "10001101", -- $F80E BSR WAITRDY $F86A
85
-- "01100000",
86
"10001101", -- $F808 BSR $F874 -- test sub call
87
"01101010",
88
---------------------------
89
"10000110", -- $F80A LDA #$E0
90
"11100000",
91
"10010111", -- $F80C STA <$E016
92
"00010110",
93
---------------------------
94
-- "10001101", -- $F80E BSR WAITRDY $F86A
95
-- "01011010",
96
"10001101", -- $F80E BSR $F810
97
"00000000",
98
--------------------------
99
"10000110", -- $F810 LDA #$01
100
"00000001",
101
"10010111", -- $F812 STA <$E011
102
"00010001",
103
"10000110", -- $F814 LDA #$EF
104
"11101111",
105
"10010111", -- $F816 STA <$E017
106
"00010111",
107
--------------------------
108
-- "10001101", -- $F818 BSR WAITRDY $F86A
109
-- "01010000",
110
"10001101", -- $F818 BSR $F816
111
"00000000",
112
--------------------------
113
"00010000", -- $F81A LDY #$F800
114
"10001110",
115
"11111000",
116
"00000000",
117
"11000110", -- $F81E LDB #$7C
118
"01111100",
119
"10000110", -- $F820 LDA #$01 *** RDLP1
120
"00000001",
121
"10010111", -- $F822 STA <$E012
122
"00010010",
123
"11010111", -- $F824 STB <$E013
124
"00010011",
125
"10000110", -- $F826 LDA #$F4
126
"11110100",
127
"10010111", -- $F828 STA <$E014
128
"00010100",
129
"01001111", -- $F82A CLRA
130
"10010111", -- $F82B STA <$E015
131
"00010101",
132
"10001110", -- $F82D LDX #512
133
"00000010",
134
"00000000",
135
"10000110", -- $F830 LDA #$20
136
"00100000",
137
"10010111", -- $F832 STA <$E017
138
"00010111",
139
--------------------------
140
-- "10001101", -- $F834 BSR WAITRDY $F86A
141
-- "00110100",
142
"10001101", -- $F834 BSR *
143
"00000000",
144
--------------------------
145
"10010110", -- $F836 LDA <$E017 *** WAITDRQ
146
"00010111",
147
"10000101", -- $F838 BITA #$08
148
"00001000",
149
"00100111", -- $F83A BEQ WAITDRQ
150
"11111010",
151
"10010110", -- $F83C LDA <$E010
152
"00010000",
153
"10100111", -- $F83E STA ,Y+
154
"10100000",
155
"00110000", -- $F840 LEAX -1,X
156
"00011111",
157
"10001100", -- $F842 CMPX #$0000
158
"00000000",
159
"00000000",
160
"00100110", -- $F845 BNE RDLP2
161
"11110011",
162
--------------------------
163
-- "10001101", -- $F847 BSR WAITRDY $F86A
164
-- "00100001",
165
"10001101", -- $F847 BSR $F841
166
"00000000",
167
--------------------------
168
"01011100", -- $F849 INCB
169
"11000001", -- $F84A CMPB #$80
170
"10000000",
171
"00100110", -- $F84C BNE RDLP1
172
"11010110",
173
"10001110", -- $F84E LDX #$FF97
174
"11111111",
175
"10010111",
176
"00010000", -- $F851 LDY #$F000
177
"10001110",
178
"11110000",
179
"00000000",
180
"11000110", -- $F855 LDB #$61
181
"01100001",
182
"10100110", -- $F857 LDA 0,X+ *** MOVELP
183
"10000000",
184
"10100111", -- $F859 STA 0,Y+
185
"10100000",
186
"01011010", -- $F85B DECB
187
----------------------------
188
-- "00100110", -- $F85C BNE MOVELP
189
-- "11111001",
190
"00100110", --$F85C BNE $F861
191
"00000011",
192
----------------------------
193
"01111110", -- $F85E JMP $F000
194
"11110000",
195
"00000000",
196
"00001111", -- $F861 CLR <$E030 
197
"00110000",
198
"01001111", -- $F863 CLRA
199
"00011111", -- $F864 TFR A,DPR
200
"10001011",
201
"01101110", -- $F866 JMP [$FFFE]
202
"10011111",
203
"11111111",
204
"11111110",
205
--
206
-- Wait for Ready
207
--
208
"10010110", -- $F86A LDA <$E017 *** WAITRDY
209
"00010111",
210
"00101011", -- $F86C BMI WAITRDY
211
"11111100",
212
"10010110", -- $F86E LDA <$E017
213
"00010111",
214
"10000101", -- $F870 BITA #$40
215
"01000000",
216
"00100111", -- $F872 BNE WAITRQY
217
"11110110",
218
"00111001", -- $F874 RTS
219
"00010010", -- $F875 NOP
220
"11111000", -- $F876 FDB $F80A -- dummy sub return
221
"00001010",
222
"11111000", -- $F878 FDB $F800
223
"00000000",
224
"11111000", -- $F87A FDB $F800
225
"00000000",
226
"11111000", -- $F87C FDB $F800
227
"00000000",
228
"11111000", -- $F87E FDB $F800
229
"00000000"
230
         );
231
 
232
component cpu09
233
  port (
234
         clk:        in std_logic;
235
    rst:             in std_logic;
236
    rw:      out        std_logic;              -- Asynchronous memory interface
237
    vma:             out        std_logic;
238
    address:  out       std_logic_vector(15 downto 0);
239
    data_in:  in        std_logic_vector(7 downto 0);
240
         data_out: out std_logic_vector(7 downto 0);
241
         halt:     in  std_logic;
242
         hold:     in  std_logic;
243
         irq:      in  std_logic;
244
         nmi:      in  std_logic;
245
         firq:     in  std_logic;
246
         test_alu: out std_logic_vector(15 downto 0);
247
         test_cc:  out std_logic_vector(7 downto 0)
248
  );
249
end component cpu09;
250
 
251
 
252
begin
253
cpu : cpu09  port map (
254
         clk         => SysClk,
255
    rst      => cpu_reset,
256
    rw       => cpu_rw,
257
    vma       => cpu_vma,
258
    address   => cpu_addr(15 downto 0),
259
    data_in   => cpu_data_in,
260
         data_out  => cpu_data_out,
261
         halt      => '0',
262
         hold      => '0',
263
         irq       => cpu_irq,
264
         nmi       => cpu_nmi,
265
         firq      => cpu_firq,
266
         test_alu  => cpu_alu,
267
         test_cc   => cpu_cc
268
  );
269
 
270
  -- *** Test Bench - User Defined Section ***
271
   tb : PROCESS
272
        variable count : integer;
273
   BEGIN
274
 
275
        cpu_reset <= '0';
276
        SysClk <= '0';
277
   cpu_irq <= '0';
278
   cpu_nmi <= '0';
279
        cpu_firq <= '0';
280
 
281
                for count in 0 to 512 loop
282
                        SysClk <= '0';
283
                        if count = 0 then
284
                                cpu_reset <= '1';
285
                        elsif count = 1 then
286
                                cpu_reset <= '0';
287
                        end if;
288
                        wait for 100 ns;
289
                        SysClk <= '1';
290
                        wait for 100 ns;
291
                end loop;
292
 
293
      wait; -- will wait forever
294
   END PROCESS;
295
-- *** End Test Bench - User Defined Section ***
296
 
297
 
298
  rom : PROCESS( cpu_addr )
299
  begin
300
    cpu_data_in <= rom_data(conv_integer(cpu_addr(6 downto 0)));
301
  end process;
302
 
303
end behavior; --===================== End of architecture =======================--
304
 

powered by: WebSVN 2.1.0

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