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

Subversion Repositories System68

[/] [System68/] [tags/] [arelease/] [vhdl/] [testbench1.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 dilbert57
--===========================================================================--
2
--
3
-- CPU68 Microprocessor Test Bench 1
4
-- Print out "Hello World" on the Uart
5
--
6
--
7
-- John Kent 21st October 2002
8
--
9
--
10
-------------------------------------------------------------------------------
11
library ieee;
12
   use ieee.std_logic_1164.all;
13
   use IEEE.STD_LOGIC_ARITH.ALL;
14
   use IEEE.STD_LOGIC_UNSIGNED.ALL;
15
   use ieee.numeric_std.all;
16
library work;
17
--   use work.UART_Def.all;
18
--   use work.typedefines.all;
19
--   use work.memory.all;
20
 
21
entity my_testbench is
22
end my_testbench;
23
 
24
-------------------------------------------------------------------------------
25
-- Architecture for memio Controller Unit
26
-------------------------------------------------------------------------------
27
architecture behavior of my_testbench is
28
  -----------------------------------------------------------------------------
29
  -- Signals
30
  -----------------------------------------------------------------------------
31
  signal uart_irq    : Std_Logic;
32
  signal timer_irq   : std_logic;
33
 
34
  -- CPU Interface signals
35
  signal SysClk      : Std_Logic;
36
  signal cpu_reset   : Std_Logic;
37
  signal cpu_rw      : Std_Logic;
38
  signal cpu_vma     : Std_Logic;
39
  signal cpu_addr    : Std_Logic_Vector(15 downto 0);
40
  signal cpu_data_in : Std_Logic_Vector(7 downto 0);
41
  signal cpu_data_out: Std_Logic_Vector(7 downto 0);
42
  signal cpu_alu     : Std_Logic_Vector(15 downto 0);
43
  signal cpu_cc      : Std_Logic_Vector(7 downto 0);
44
 
45
  constant width   : integer := 8;
46
  constant memsize : integer := 64;
47
 
48
  type rom_array is array(0 to memsize-1) of std_logic_vector(width-1 downto 0);
49
 
50
  constant rom_data : rom_array :=
51
  (
52
    "11001110", "11111111", "11101000", -- E000 - CE E028  RESET LDX #MSG
53
         "10000110", "00010001",             -- E003 - 86 11          LDAA #$11
54
         "10110111", "10000000", "00000100", -- E005 - B7 8004        STAA UARTCR
55
    "10110110", "10000000", "00000100", -- E008 - B6 8004  POLL1 LDAA UARTCR
56
         "10000101", "00000010",             -- E00B - 85 02          BITA #TXBE
57
--       "00100111", "11111001",             -- E00D - 27 F9          BEQ POLL1
58
         "00100110", "11111001",             -- E00D - 26 F9          BNE POLL1
59
         "10100110", "00000000",             -- E00F - A6 00          LDAA 0,X
60
         "00100111", "00000110",             -- E011 - 27 06          BEQ POLL2
61
         "00001000",                         -- E013 - 08             INX
62
         "10110111", "10000000", "00000101", -- E014 - B7 8005        STA UARTDR
63
    "00100110", "11101111",             -- E017 - 26 EF          BNE POLL1
64
         "00001000", "10000000", "00000100", -- E019 - B6 8004  POLL2 LDAA UARTCR
65
         "10000101", "00000001",             -- E01C - 85 01          BITA #RXBF
66
         "00100111", "11111001",             -- E01E - 27 F9          BEQ POLL2
67
--       "00100110", "11111001",             -- E01E - 26 F9          BEQ POLL2
68
         "10110110", "10000000", "00000101", -- E020 - B6 8005        LDAA UARTDR
69
         "00100000", "11100000", "00000000", -- E023 - 7E E000        JMP RESET
70
         "00000000", "00000000",             -- E026 - 00 00          fcb $00,$00
71
    "01001000", "01100101", "01101100", -- E028 - 48 65 6c MSG   FCC "Hel"
72
         "01101100", "01101111", "00100000", -- E02B - 6c 6f 20       FCC "lo "
73
         "01010111", "01101111", "01110010", -- E02E - 57 6f 72       FCC "Wor"
74
    "01101100", "01100100",             -- E031 - 6c 64          FCC "ld"
75
    "00001010", "00001101", "00000000", -- E033 - 0a 0d 00       FCB LF,CR,NULL
76
    "00000000", "00000000",             -- E036 - 00 00          fcb null,null           
77
         "11100000", "00000000",             -- E038 - E0 00          fdb $E000 ; Timer irq
78
         "11100000", "00000000",             -- E03A - E0 00          fdb $E000 ; Ext IRQ
79
         "11100000", "00000000",             -- E03C - E0 00          fcb $E000 ; SWI
80
         "11100000", "00000000"              -- E03E - E0 00          fdb $E000 ; Reset
81
         );
82
 
83
component cpu68
84
  port (
85
         clk:        in std_logic;
86
    rst:             in std_logic;
87
    rw:      out        std_logic;              -- Asynchronous memory interface
88
    vma:             out        std_logic;
89
    address:  out       std_logic_vector(15 downto 0);
90
    data_in:  in        std_logic_vector(7 downto 0);
91
         data_out: out std_logic_vector(7 downto 0);
92
         irq:      in  std_logic;
93
         nmi:      in  std_logic;
94
         test_alu: out std_logic_vector(15 downto 0);
95
         test_cc:  out std_logic_vector(7 downto 0)
96
  );
97
end component cpu68;
98
 
99
 
100
begin
101
cpu : cpu68  port map (
102
         clk         => SysClk,
103
    rst      => cpu_reset,
104
    rw       => cpu_rw,
105
    vma       => cpu_vma,
106
    address   => cpu_addr(15 downto 0),
107
    data_in   => cpu_data_in,
108
         data_out  => cpu_data_out,
109
         irq       => uart_irq,
110
         nmi       => timer_irq,
111
         test_alu  => cpu_alu,
112
         test_cc   => cpu_cc
113
  );
114
 
115
  -- *** Test Bench - User Defined Section ***
116
   tb : PROCESS
117
        variable count : integer;
118
   BEGIN
119
 
120
        cpu_reset <= '0';
121
        SysClk <= '0';
122
   uart_irq <= '0';
123
        timer_irq <= '0';
124
 
125
                for count in 0 to 256 loop
126
                        SysClk <= '0';
127
                        if count = 0 then
128
                                cpu_reset <= '1';
129
                        elsif count = 1 then
130
                                cpu_reset <= '0';
131
                        end if;
132
                        wait for 100 ns;
133
                        SysClk <= '1';
134
                        wait for 100 ns;
135
                end loop;
136
 
137
      wait; -- will wait forever
138
   END PROCESS;
139
-- *** End Test Bench - User Defined Section ***
140
 
141
 
142
  rom : PROCESS( cpu_addr )
143
  begin
144
    cpu_data_in <= rom_data(conv_integer(cpu_addr(5 downto 0)));
145
  end process;
146
 
147
end behavior; --===================== End of architecture =======================--
148
 

powered by: WebSVN 2.1.0

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