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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [Testbench/] [testbench3.vhd] - Blame information for rev 173

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

Line No. Rev Author Line
1 122 dilbert57
--===========================================================================--
2
--                                                                           --
3
--             TESTBENCH    testbench3 - CPU09 Testbench.                    --
4
--                                                                           --
5
--===========================================================================--
6 19 dilbert57
--
7
-- File name      : Testbench3.vhd
8
--
9
-- Purpose        : cpu09 Microprocessor Test Bench 3
10
--                  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
-- Uses           : cpu09    (cpu09.vhd)      CPU core
18
--                   
19
-- Author         : John E. Kent
20
--                  dilbert57@opencores.org      
21 122 dilbert57
-- 
22
--  Copyright (C) 2003 - 2010 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-26 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_testbench3 is
58
end my_testbench3;
59
 
60
-------------------------------------------------------------------------------
61
-- Architecture for memio Controller Unit
62
-------------------------------------------------------------------------------
63
architecture behavior of my_testbench3 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 := 64;
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
         "00010000", "11001110", "11111000", "00110000", -- F800 - 10CE F830 RET1    LDS #STACK
88
         "00111111",                                     -- F804 -   3F              SWI
89
         "00010000", "00111111",                         -- F805 - 103F      SWIVEC  SWI2
90
         "00010001", "00111111",                         -- F807 - 113F      SWI2VEC SWI3
91
         "00111011",                                     -- F809 -   3B      SWI3VEC RTI
92
         "00100000", "11111110",                         -- F80A -   20 FE           BRA *
93
         "10110001",                                     -- F80C -   B1      STACK3 FCB $B1 ; CC
94
         "00110010",                                     -- F80D -   32             FCB $32 ; ACCA
95
         "00110011",                                     -- F8OE -   33             FCB $33 ; ACCB
96
         "00110100",                                     -- F8OF -   34             FCB $34 ; DPR
97
         "00110101", "00110110",                         -- F810 - 3536             FDB $3536 ; IX
98
    "00110111", "00111000",                         -- F812 - 3738             FDB $3738 ; IY
99
    "00111001", "00111010",                         -- F814 - 393A             FDB $393A ; UP
100
         "11111000", "00001001",                         -- F816 - F809             FDB SWI3VEC ; PC
101
         "10100001",                                     -- F818 -   A1      STACK2 FCB $A1 ; CC
102
         "00100010",                                     -- F819 -   22             FCB $22 ; ACCA
103
         "00100011",                                     -- F81A -   23             FCB $23 ; ACCB
104
         "00100100",                                     -- F81B -   24             FCB $24 ; DPR
105
         "00100101", "00100110",                         -- F81C - 2526             FDB $2526 ; IX
106
    "00100111", "00101000",                         -- F81E - 2728             FDB $2728 ; IY
107
    "00101001", "00101010",                         -- F820 - 292A             FDB $292A ; UP
108
         "11111000", "00001001",                         -- F822 - F809             FDB SWI3VEC ; PC
109
         "10010001",                                     -- F824 -   91      STACK1 FCB $91 ; CC
110
         "00010010",                                     -- F825 -   12             FCB $12 ; ACCA
111
         "00010011",                                     -- F826 -   13             FCB $13 ; ACCB
112
         "00010100",                                     -- F827 -   14             FCB $14 ; DPR
113
         "00010101", "00010110",                         -- F828 - 1516             FDB $1516 ; IX
114
    "00010111", "00011000",                         -- F82A - 1718             FDB $1718 ; IY
115
    "00011001", "00011010",                         -- F82C - 191A             FDB $191A ; UP
116
         "11111000", "00000000",                         -- F82E - F800             FDB RESET ; PC
117
                                                                                                                                         -- F830             STACK  EQU *
118
                                                                                                                                         --
119
                                                                                                                                         -- Interrupt Cectors Start Here
120
                                                                                                                                         --
121
         "11111000", "00000000",                         -- F830 - F800             FDB RESET ; RESV
122
    "11111000", "00001001",                         -- F832 - F809             FDB SWIVEC3 ; SWI3
123
         "11111000", "00000111",                         -- F834 - F807             FDB SWIVEC2 ; SWI2
124
         "11111000", "00000000",                         -- F836 - F800             fdb RESET ; FIRQ
125
         "11111000", "00000000",                         -- F838 - F800             fdb RESET ; IRQ
126
         "11111000", "00000101",                         -- F83A - F805             fdb SWIVEC ; SWI
127
         "11111000", "00000000",                         -- F83C - F800             fcb RESET ; NMI
128
         "11111000", "00000000"                          -- F83E - F800             fdb RESET ; Reset
129
         );
130
 
131
component cpu09
132
  port (
133
         clk:        in std_logic;
134
    rst:             in std_logic;
135
    rw:      out        std_logic;              -- Asynchronous memory interface
136
    vma:             out        std_logic;
137 122 dilbert57
    addr:     out       std_logic_vector(15 downto 0);
138 19 dilbert57
    data_in:  in        std_logic_vector(7 downto 0);
139
         data_out: out std_logic_vector(7 downto 0);
140
         halt:     in  std_logic;
141
         hold:     in  std_logic;
142
         irq:      in  std_logic;
143
         nmi:      in  std_logic;
144
         firq:     in  std_logic
145
  );
146
end component cpu09;
147
 
148
 
149
begin
150
cpu : cpu09  port map (
151
         clk         => SysClk,
152
    rst      => cpu_reset,
153
    rw       => cpu_rw,
154
    vma       => cpu_vma,
155 122 dilbert57
    addr      => cpu_addr(15 downto 0),
156 19 dilbert57
    data_in   => cpu_data_in,
157
         data_out  => cpu_data_out,
158
         halt      => '0',
159
         hold      => '0',
160
         irq       => cpu_irq,
161
         nmi       => cpu_nmi,
162
         firq      => cpu_firq
163
  );
164
 
165
  -- *** Test Bench - User Defined Section ***
166
   tb : PROCESS
167
        variable count : integer;
168
   BEGIN
169
 
170
        cpu_reset <= '0';
171
        SysClk <= '0';
172
   cpu_irq <= '0';
173
   cpu_nmi <= '0';
174
        cpu_firq <= '0';
175
 
176
                for count in 0 to 512 loop
177
                        SysClk <= '0';
178
                        if count = 0 then
179
                                cpu_reset <= '1';
180
                        elsif count = 1 then
181
                                cpu_reset <= '0';
182
                        end if;
183
                        wait for 100 ns;
184
                        SysClk <= '1';
185
                        wait for 100 ns;
186
                end loop;
187
 
188
      wait; -- will wait forever
189
   END PROCESS;
190
-- *** End Test Bench - User Defined Section ***
191
 
192
 
193
  rom : PROCESS( cpu_addr )
194
  begin
195
    cpu_data_in <= rom_data(conv_integer(cpu_addr(5 downto 0)));
196
  end process;
197
 
198
end behavior; --===================== End of architecture =======================--
199
 

powered by: WebSVN 2.1.0

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