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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [Testbench/] [testbench2.vhd] - Blame information for rev 113

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

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

powered by: WebSVN 2.1.0

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