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

Subversion Repositories System09

[/] [System09/] [tags/] [V10/] [rtl/] [vhdl/] [testbench1.vhd] - Blame information for rev 201

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

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

powered by: WebSVN 2.1.0

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