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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [Testbench/] [testbench5.vhd] - Blame information for rev 138

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

Line No. Rev Author Line
1 122 dilbert57
--===========================================================================--
2
--                                                                           --
3
--             TESTBENCH    testbench5 - CPU09 Testbench.                    --
4
--                                                                           --
5
--===========================================================================--
6 19 dilbert57
--
7
-- File name      : Testbench5.vhd
8
--
9 122 dilbert57
-- Purpose        : cpu09 Microprocessor Test Bench 5
10 19 dilbert57
--                  Contains ROM to test interrupts
11
--
12
-- Dependencies   : ieee.Std_Logic_1164
13
--                  ieee.std_logic_unsigned
14
--                  ieee.std_logic_arith
15
--                  ieee.numeric_std
16
--
17 122 dilbert57
-- Uses           : cpu09    (..\VHDL\cpu09.vhd)              CPU core
18 19 dilbert57
--                   
19
-- Author         : John E. Kent
20
--                  dilbert57@opencores.org      
21 122 dilbert57
-- 
22
--  Copyright (C) 2003 - 2011 John Kent
23
--
24
--  This program is free software: you can redistribute it and/or modify
25
--  it under the terms of the GNU General Public License as published by
26
--  the Free Software Foundation, either version 3 of the License, or
27
--  (at your option) any later version.
28
--
29
--  This program is distributed in the hope that it will be useful,
30
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
31
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
--  GNU General Public License for more details.
33
--
34
--  You should have received a copy of the GNU General Public License
35
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
36
--
37
--===========================================================================--
38
--                                                                           --
39
--                                Revision History                           --
40
--                                                                           --
41
--===========================================================================--
42 19 dilbert57
--
43 122 dilbert57
-- Rev  Date       Author     Changes
44
-- 0.1  2003-04-12 John Kent  First version
45
-- 1.0  2003-09-06 John Kent  Initial release to Opencores.org
46
-- 1.1  2004-02-25 John kent  removed test_alu and test_cc signals from CPU component.
47
-- 1.2  2011-10-09 John Kent  renamed address to addr on CPU component, updated header
48 19 dilbert57
--
49
--===========================================================================--
50
 
51
library ieee;
52
   use ieee.std_logic_1164.all;
53
   use IEEE.STD_LOGIC_ARITH.ALL;
54
   use IEEE.STD_LOGIC_UNSIGNED.ALL;
55
   use ieee.numeric_std.all;
56
 
57
entity my_testbench5 is
58
end my_testbench5;
59
 
60
-------------------------------------------------------------------------------
61
-- Architecture for  test bench for cpu09
62
-------------------------------------------------------------------------------
63
architecture behavior of my_testbench5 is
64
  -----------------------------------------------------------------------------
65
  -- Signals
66
  -----------------------------------------------------------------------------
67
  signal cpu_irq    : std_Logic;
68
  signal cpu_firq   : std_logic;
69
  signal cpu_nmi    : std_logic;
70
 
71
  -- CPU Interface signals
72
  signal SysClk      : Std_Logic;
73
  signal cpu_reset   : Std_Logic;
74
  signal cpu_rw      : Std_Logic;
75
  signal cpu_vma     : Std_Logic;
76
  signal cpu_addr    : Std_Logic_Vector(15 downto 0);
77
  signal cpu_data_in : Std_Logic_Vector(7 downto 0);
78
  signal cpu_data_out: Std_Logic_Vector(7 downto 0);
79
 
80
  constant width   : integer := 8;
81
  constant memsize : integer := 128;
82
 
83
  type rom_array is array(0 to memsize-1) of std_logic_vector(width-1 downto 0);
84
 
85
  constant rom_data : rom_array :=
86
  (
87
         x"10", x"CE", x"F8", x"30", -- F800 - 10CE F830 RESET   LDS #$F830
88
                x"CE", x"20", x"00", -- F804 -   CE 2000         LDU #$2000
89
                x"8E", x"F8", x"02", -- F807 -   8E 5000         LDX #$F802
90
         x"10", x"8E", x"80", x"00", -- F80A - 108E 8000         LDY #$8000
91
                x"86", x"55",        -- F80E -   86 55           LDA #$55
92
                          x"C6", x"F0",        -- F810 -   C6 F0           LDB #$F0
93
                          x"97", x"40",        -- F812 -   97 40           STA <$40
94
                          x"B7", x"90", x"00", -- F814 -   B7 9000         STA $9000
95
                          x"A7", x"09",        -- F817 -   A7 09           STA 9,X ($F80B)
96
                          x"A7", x"29",        -- F819 -   A7 29           STA 9,Y ($8009)
97
                          x"A7", x"49",        -- F81B -   A7 49           STA 9,U ($2009)
98
                          x"A7", x"69",        -- F81D -   A7 69           STA 9,S ($F839)
99
                          x"A7", x"80",        -- F81F -   A7 80           STA ,X+ ($F802)
100
                          x"A7", x"81",        -- F821 -   A7 81           STA ,X++     ($F803)
101
                          x"A7", x"91",        -- F823 -   A7 91           STA [,X++] ($2000)
102
                          x"A7", x"82",        -- F825 -   A7 82           STA ,-X ($F806)
103
                          x"A7", x"83",        -- F827 -   A7 83           STA ,--X     ($F804)
104
                          x"A7", x"93",        -- F829 -   A7 93           STA [,--X] ($2000)
105
                          x"A7", x"84",        -- F82B -   A7 84           STA ,X ($F802)
106
                          x"A7", x"94",        -- F82D -   A7 94           STA [,X] ($F830)
107
                          x"A7", x"85",        -- F82F -   A7 85           STA B,X ($F7F2)
108
                          x"A7", x"95",        -- F831 -   A7 95           STA [B,X] ($01A7)
109
                          x"A7", x"86",        -- F833 -   A7 86           STA A,X ($F857)
110
                          x"A7", x"96",        -- F835 -   A7 96           STA [A,X] ($A78C)
111
                          x"A7", x"88", x"FF", -- F837 -   A7 88 FF        STA -1,X ($F831)
112
                          x"A7", x"88", x"01", -- F83A -   A7 88 01        STA 1,X ($F833)
113
                          x"A7", x"98", x"FF", -- F83D -   A7 98 FF        STA [-1,X] ([$F801])
114
                          x"A7", x"98", x"01", -- F840 -   A7 98 01        STA [1,X] ([$F803])
115
         x"A7", x"89", x"FF", x"FF", -- F843 -   A7 89 FFFF      STA -1,X ($F801)
116
         x"A7", x"89", x"00", x"01", -- F847 -   A7 89 0001      STA 1,X ($F803)
117
         x"A7", x"99", x"FF", x"FF", -- F84B -   A7 99 FFFF      STA [-1,X] ([$F801])
118
         x"A7", x"99", x"00", x"01", -- F84F -   A7 99 0001      STA [1,X] ([$F803])
119
                          x"A7", x"8B",        -- F853 -   A7 8B           STA D,X ($4BF2)
120
                          x"A7", x"9B",        -- F855 -   A7 9B           STA [D,X] ([$4BF2]))
121
                          x"A7", x"8C", x"FF", -- F857 -   A7 8C FF        STA -1,X ($F801)
122
                          x"A7", x"8C", x"01", -- F85A -   A7 8C 01        STA 1,X ($F803)
123
                          x"A7", x"9C", x"FF", -- F85D -   A7 9C FF        STA [-1,X] ([$F801])
124
                          x"A7", x"9C", x"01", -- F860 -   A7 9C 01        STA [1,X] ([$F803])
125
         x"A7", x"8D", x"FF", x"FF", -- F863 -   A7 8D FFFF      STA -1,X ($F801)
126
         x"A7", x"8D", x"00", x"01", -- F867 -   A7 8D 0001      STA 1,X ($F803)
127
         x"A7", x"9D", x"FF", x"FF", -- F86B -   A7 9D FFFF      STA [-1,X] ([$F801])
128
         x"A7", x"9D", x"00", x"01", -- F86F -   A7 9D 0001      STA [1,X] ([$F803])
129
         x"A7", x"8F", x"A0", x"00", -- F873 -   A7 8F A000      STA $A000
130
         x"A7", x"9F", x"A0", x"00", -- F877 -   A7 9F A000      STA [$A000]
131
                          x"7E", x"F8", x"00", -- F87B -   7E F800         JMP RESET
132
                x"F8", x"00"         -- F87E -      F800         fdb RESET ; Reset
133
         );
134
 
135
component cpu09
136
  port (
137
         clk:        in std_logic;
138
    rst:             in std_logic;
139
    rw:      out        std_logic;              -- Asynchronous memory interface
140
    vma:             out        std_logic;
141 122 dilbert57
    addr:     out       std_logic_vector(15 downto 0);
142 19 dilbert57
    data_in:  in        std_logic_vector(7 downto 0);
143
         data_out: out std_logic_vector(7 downto 0);
144
         halt:     in  std_logic;
145
         hold:     in  std_logic;
146
         irq:      in  std_logic;
147
         nmi:      in  std_logic;
148
         firq:     in  std_logic
149
  );
150
end component cpu09;
151
 
152
 
153
begin
154
cpu : cpu09  port map (
155
         clk         => SysClk,
156
    rst      => cpu_reset,
157
    rw       => cpu_rw,
158
    vma       => cpu_vma,
159 122 dilbert57
    addr      => cpu_addr(15 downto 0),
160 19 dilbert57
    data_in   => cpu_data_in,
161
         data_out  => cpu_data_out,
162
         halt      => '0',
163
         hold      => '0',
164
         irq       => cpu_irq,
165
         nmi       => cpu_nmi,
166
         firq      => cpu_firq
167
  );
168
 
169
  -- *** Test Bench - User Defined Section ***
170
   tb : PROCESS
171
        variable count : integer;
172
   BEGIN
173
 
174
        cpu_reset <= '0';
175
        SysClk <= '0';
176
   cpu_irq <= '0';
177
   cpu_nmi <= '0';
178
        cpu_firq <= '0';
179
 
180
                for count in 0 to 512 loop
181
                        SysClk <= '0';
182
                        if count = 0 then
183
                                cpu_reset <= '1';
184
                        elsif count = 1 then
185
                                cpu_reset <= '0';
186
                        end if;
187
                        wait for 100 ns;
188
                        SysClk <= '1';
189
                        wait for 100 ns;
190
                end loop;
191
 
192
      wait; -- will wait forever
193
   END PROCESS;
194
-- *** End Test Bench - User Defined Section ***
195
 
196
 
197
  rom : PROCESS( cpu_addr )
198
  begin
199
    cpu_data_in <= rom_data(conv_integer(cpu_addr(6 downto 0)));
200
  end process;
201
 
202
end behavior; --===================== End of architecture =======================--
203
 

powered by: WebSVN 2.1.0

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