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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [Testbench/] [testbench1.vhd] - Blame information for rev 130

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

Line No. Rev Author Line
1 122 dilbert57
--===========================================================================--
2
--                                                                           --
3
--             TESTBENCH    testbench1 - CPU09 Testbench.                    --
4
--                                                                           --
5
--===========================================================================--
6 19 dilbert57
--
7
-- File name      : Testbench1.vhd
8
--
9
-- Purpose        : cpu09 Microprocessor Test Bench 1
10
--                  Contains ROM to print out "Hello World"
11
--                  on a none existant Uart
12
--
13
-- Dependencies   : ieee.Std_Logic_1164
14
--                  ieee.std_logic_unsigned
15
--                  ieee.std_logic_arith
16
--                  ieee.numeric_std
17
--
18
-- Uses           : cpu09    (cpu09.vhd)      CPU core
19
--                   
20
-- Author         : John E. Kent
21
--                  dilbert57@opencores.org      
22 122 dilbert57
-- 
23
--  Copyright (C) 2003 - 2010 John Kent
24
--
25
--  This program is free software: you can redistribute it and/or modify
26
--  it under the terms of the GNU General Public License as published by
27
--  the Free Software Foundation, either version 3 of the License, or
28
--  (at your option) any later version.
29
--
30
--  This program is distributed in the hope that it will be useful,
31
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
32
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33
--  GNU General Public License for more details.
34
--
35
--  You should have received a copy of the GNU General Public License
36
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
37
--
38
--===========================================================================--
39
--                                                                           --
40
--                                Revision History                           --
41
--                                                                           --
42
--===========================================================================--
43 19 dilbert57
--
44 122 dilbert57
-- Rev  Date       Author     Changes
45
-- 0.1  2003-04-12 John Kent  First version
46
-- 1.0  2003-09-06 John Kent  Initial release to Opencores.org
47
-- 1.1  2004-01-25 John Kent  removed "test_alu" and "test_cc" from CPU component
48
-- 1.2  2011-10-09 John Kent  updated for acia6850
49 19 dilbert57
--
50
--===========================================================================--
51
 
52
library ieee;
53
   use ieee.std_logic_1164.all;
54
   use IEEE.STD_LOGIC_ARITH.ALL;
55
   use IEEE.STD_LOGIC_UNSIGNED.ALL;
56
   use ieee.numeric_std.all;
57 122 dilbert57
--library work;
58 19 dilbert57
--   use work.UART_Def.all;
59
--   use work.typedefines.all;
60
--   use work.memory.all;
61
 
62 122 dilbert57
entity my_testbench1 is
63
end my_testbench1;
64 19 dilbert57
 
65
-------------------------------------------------------------------------------
66
-- Architecture for memio Controller Unit
67
-------------------------------------------------------------------------------
68 122 dilbert57
architecture behavior of my_testbench1 is
69 19 dilbert57
  -----------------------------------------------------------------------------
70
  -- Signals
71
  -----------------------------------------------------------------------------
72
  -- CPU Interface signals
73
  signal SysClk      : Std_Logic;
74
  signal cpu_reset   : Std_Logic;
75
  signal cpu_rw      : Std_Logic;
76
  signal cpu_vma     : Std_Logic;
77
  signal cpu_addr    : Std_Logic_Vector(15 downto 0);
78
  signal cpu_data_in : Std_Logic_Vector(7 downto 0);
79
  signal cpu_data_out: Std_Logic_Vector(7 downto 0);
80
  signal cpu_irq     : Std_Logic;
81
  signal cpu_nmi     : std_logic;
82
  signal cpu_firq    : Std_Logic;
83
 
84
 
85
  constant width   : integer := 8;
86
  constant memsize : integer := 64;
87
 
88
  type rom_array is array(0 to memsize-1) of std_logic_vector(width-1 downto 0);
89
 
90
  constant rom_data : rom_array :=
91
  (
92
    "10001110", "11111000", "00101000", -- F800 - 8E F828  RESET LDX #MSG
93
         "10000110", "00010001",             -- F803 - 86 11          LDA #$11
94
         "10110111", "11100000", "00000100", -- F805 - B7 E004        STA UARTCR
95
    "10110110", "11100000", "00000100", -- F808 - B6 E004  POLL1 LDA UARTCR
96
         "10000101", "00000010",             -- F80B - 85 02          BITA #TXBE
97
         "00100110", "11111001",             -- F80D - 26 F9          BNE POLL1
98
         "10100110", "10000000",             -- F80F - A6 80          LDA ,X+
99
         "00100111", "00000110",             -- F811 - 27 06          BEQ POLL2
100
         "00010010",                         -- F813 - 12             NOP
101
         "10110111", "11100000", "00000101", -- F814 - B7 E005        STA UARTDR
102
    "00100110", "11101111",             -- F817 - 26 EF          BNE POLL1
103
         "10110110", "11100000", "00000100", -- F819 - B6 E004  POLL2 LDA UARTCR
104
         "10000101", "00000001",             -- F81C - 85 01          BITA #RXBF
105
         "00100111", "11111001",             -- F81E - 27 F9          BEQ POLL2
106
         "10110110", "11100000", "00000101", -- F820 - B6 E005        LDA UARTDR
107
         "01111110", "11111000", "00000000", -- F823 - 7E F800        JMP RESET
108
         "00000000", "00000000",             -- F826 - 00 00          fcb $00,$00
109
    "01001000", "01100101", "01101100", -- F828 - 48 65 6c MSG   FCC "Hel"
110
         "01101100", "01101111", "00100000", -- F82B - 6c 6f 20       FCC "lo "
111
         "01010111", "01101111", "01110010", -- F82E - 57 6f 72       FCC "Wor"
112
    "01101100", "01100100",             -- F831 - 6c 64          FCC "ld"
113
    "00001010", "00001101", "00000000", -- F833 - 0a 0d 00       FCB LF,CR,NULL
114
    "00000000", "00000000",             -- F836 - 00 00          fcb null,null           
115
         "11111000", "00000000",             -- F838 - F8 00          fdb $F800 ; Timer irq
116
         "11111000", "00000000",             -- F83A - F8 00          fdb $F800 ; Ext IRQ
117
         "11111000", "00000000",             -- F83C - F8 00          fcb $F800 ; SWI
118
         "11111000", "00000000"              -- F83E - F8 00          fdb $F800 ; Reset
119
         );
120
 
121
component cpu09
122
  port (
123
         clk:        in std_logic;
124
    rst:             in std_logic;
125
    vma:             out        std_logic;
126 122 dilbert57
    rw:       out       std_logic;              -- Asynchronous memory interface
127
    addr:     out       std_logic_vector(15 downto 0);
128 19 dilbert57
    data_in:  in        std_logic_vector(7 downto 0);
129
         data_out: out std_logic_vector(7 downto 0);
130
         halt:     in  std_logic;
131
         hold:     in  std_logic;
132
         irq:      in  std_logic;
133
         nmi:      in  std_logic;
134
         firq:     in  std_logic
135
  );
136
end component cpu09;
137
 
138
 
139
begin
140
cpu : cpu09  port map (
141 122 dilbert57
         clk          => SysClk,
142
    rst       => cpu_reset,
143 19 dilbert57
    vma       => cpu_vma,
144 122 dilbert57
    rw         => cpu_rw,
145
    addr      => cpu_addr(15 downto 0),
146 19 dilbert57
    data_in   => cpu_data_in,
147
         data_out  => cpu_data_out,
148
         halt      => '0',
149
         hold      => '0',
150
         irq       => cpu_irq,
151
         nmi       => cpu_nmi,
152
         firq      => cpu_firq
153
  );
154
 
155
  -- *** Test Bench - User Defined Section ***
156
   tb : PROCESS
157
        variable count : integer;
158
   BEGIN
159
 
160
        cpu_reset <= '0';
161
        SysClk <= '0';
162
   cpu_irq <= '0';
163
   cpu_nmi <= '0';
164
        cpu_firq <= '0';
165
 
166
                for count in 0 to 512 loop
167
                        SysClk <= '0';
168
                        if count = 0 then
169
                                cpu_reset <= '1';
170
                        elsif count = 1 then
171
                                cpu_reset <= '0';
172
                        end if;
173
                        wait for 100 ns;
174
                        SysClk <= '1';
175
                        wait for 100 ns;
176
                end loop;
177
 
178
      wait; -- will wait forever
179
   END PROCESS;
180
-- *** End Test Bench - User Defined Section ***
181
 
182
 
183
  rom : PROCESS( cpu_addr )
184
  begin
185
    cpu_data_in <= rom_data(conv_integer(cpu_addr(5 downto 0)));
186
  end process;
187
 
188
end behavior; --===================== End of architecture =======================--
189
 

powered by: WebSVN 2.1.0

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