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