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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [Testbench/] [testbench1.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    tesetbench1 - CPU09 Testbench.
4
--
5
--  www.OpenCores.Org - September 2003
6
--  This core adheres to the GNU public license  
7
--
8
-- File name      : Testbench1.vhd
9
--
10
-- Purpose        : cpu09 Microprocessor Test Bench 1
11
--                  Contains ROM to print out "Hello World"
12
--                  on a none existant Uart
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
-- library work;
46
--   use work.UART_Def.all;
47
--   use work.typedefines.all;
48
--   use work.memory.all;
49
 
50
entity my_testbench is
51
end my_testbench;
52
 
53
-------------------------------------------------------------------------------
54
-- Architecture for memio Controller Unit
55
-------------------------------------------------------------------------------
56
architecture behavior of my_testbench is
57
  -----------------------------------------------------------------------------
58
  -- Signals
59
  -----------------------------------------------------------------------------
60
  -- CPU Interface signals
61
  signal SysClk      : Std_Logic;
62
  signal cpu_reset   : Std_Logic;
63
  signal cpu_rw      : Std_Logic;
64
  signal cpu_vma     : Std_Logic;
65
  signal cpu_addr    : Std_Logic_Vector(15 downto 0);
66
  signal cpu_data_in : Std_Logic_Vector(7 downto 0);
67
  signal cpu_data_out: Std_Logic_Vector(7 downto 0);
68
  signal cpu_irq     : Std_Logic;
69
  signal cpu_nmi     : std_logic;
70
  signal cpu_firq    : Std_Logic;
71
 
72
 
73
  constant width   : integer := 8;
74
  constant memsize : integer := 64;
75
 
76
  type rom_array is array(0 to memsize-1) of std_logic_vector(width-1 downto 0);
77
 
78
  constant rom_data : rom_array :=
79
  (
80
    "10001110", "11111000", "00101000", -- F800 - 8E F828  RESET LDX #MSG
81
         "10000110", "00010001",             -- F803 - 86 11          LDA #$11
82
         "10110111", "11100000", "00000100", -- F805 - B7 E004        STA UARTCR
83
    "10110110", "11100000", "00000100", -- F808 - B6 E004  POLL1 LDA UARTCR
84
         "10000101", "00000010",             -- F80B - 85 02          BITA #TXBE
85
         "00100110", "11111001",             -- F80D - 26 F9          BNE POLL1
86
         "10100110", "10000000",             -- F80F - A6 80          LDA ,X+
87
         "00100111", "00000110",             -- F811 - 27 06          BEQ POLL2
88
         "00010010",                         -- F813 - 12             NOP
89
         "10110111", "11100000", "00000101", -- F814 - B7 E005        STA UARTDR
90
    "00100110", "11101111",             -- F817 - 26 EF          BNE POLL1
91
         "10110110", "11100000", "00000100", -- F819 - B6 E004  POLL2 LDA UARTCR
92
         "10000101", "00000001",             -- F81C - 85 01          BITA #RXBF
93
         "00100111", "11111001",             -- F81E - 27 F9          BEQ POLL2
94
         "10110110", "11100000", "00000101", -- F820 - B6 E005        LDA UARTDR
95
         "01111110", "11111000", "00000000", -- F823 - 7E F800        JMP RESET
96
         "00000000", "00000000",             -- F826 - 00 00          fcb $00,$00
97
    "01001000", "01100101", "01101100", -- F828 - 48 65 6c MSG   FCC "Hel"
98
         "01101100", "01101111", "00100000", -- F82B - 6c 6f 20       FCC "lo "
99
         "01010111", "01101111", "01110010", -- F82E - 57 6f 72       FCC "Wor"
100
    "01101100", "01100100",             -- F831 - 6c 64          FCC "ld"
101
    "00001010", "00001101", "00000000", -- F833 - 0a 0d 00       FCB LF,CR,NULL
102
    "00000000", "00000000",             -- F836 - 00 00          fcb null,null           
103
         "11111000", "00000000",             -- F838 - F8 00          fdb $F800 ; Timer irq
104
         "11111000", "00000000",             -- F83A - F8 00          fdb $F800 ; Ext IRQ
105
         "11111000", "00000000",             -- F83C - F8 00          fcb $F800 ; SWI
106
         "11111000", "00000000"              -- F83E - F8 00          fdb $F800 ; Reset
107
         );
108
 
109
component cpu09
110
  port (
111
         clk:        in std_logic;
112
    rst:             in std_logic;
113
    rw:      out        std_logic;              -- Asynchronous memory interface
114
    vma:             out        std_logic;
115
    address:  out       std_logic_vector(15 downto 0);
116
    data_in:  in        std_logic_vector(7 downto 0);
117
         data_out: out std_logic_vector(7 downto 0);
118
         halt:     in  std_logic;
119
         hold:     in  std_logic;
120
         irq:      in  std_logic;
121
         nmi:      in  std_logic;
122
         firq:     in  std_logic
123
  );
124
end component cpu09;
125
 
126
 
127
begin
128
cpu : cpu09  port map (
129
         clk         => SysClk,
130
    rst      => cpu_reset,
131
    rw       => cpu_rw,
132
    vma       => cpu_vma,
133
    address   => cpu_addr(15 downto 0),
134
    data_in   => cpu_data_in,
135
         data_out  => cpu_data_out,
136
         halt      => '0',
137
         hold      => '0',
138
         irq       => cpu_irq,
139
         nmi       => cpu_nmi,
140
         firq      => cpu_firq
141
  );
142
 
143
  -- *** Test Bench - User Defined Section ***
144
   tb : PROCESS
145
        variable count : integer;
146
   BEGIN
147
 
148
        cpu_reset <= '0';
149
        SysClk <= '0';
150
   cpu_irq <= '0';
151
   cpu_nmi <= '0';
152
        cpu_firq <= '0';
153
 
154
                for count in 0 to 512 loop
155
                        SysClk <= '0';
156
                        if count = 0 then
157
                                cpu_reset <= '1';
158
                        elsif count = 1 then
159
                                cpu_reset <= '0';
160
                        end if;
161
                        wait for 100 ns;
162
                        SysClk <= '1';
163
                        wait for 100 ns;
164
                end loop;
165
 
166
      wait; -- will wait forever
167
   END PROCESS;
168
-- *** End Test Bench - User Defined Section ***
169
 
170
 
171
  rom : PROCESS( cpu_addr )
172
  begin
173
    cpu_data_in <= rom_data(conv_integer(cpu_addr(5 downto 0)));
174
  end process;
175
 
176
end behavior; --===================== End of architecture =======================--
177
 

powered by: WebSVN 2.1.0

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