forked from gardners/c65gs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpu_test.vhdl
224 lines (187 loc) · 6.93 KB
/
cpu_test.vhdl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
library ieee;
USE ieee.std_logic_1164.ALL;
use ieee.numeric_std.all;
use work.all;
use work.debugtools.all;
entity cpu_test is
end cpu_test;
architecture behavior of cpu_test is
signal pixelclock : std_logic := '0';
signal cpuclock : std_logic := '0';
signal ioclock : std_logic := '0';
signal clock50mhz : std_logic := '0';
signal reset : std_logic := '0';
signal irq : std_logic := '1';
signal nmi : std_logic := '1';
signal vsync : std_logic;
signal hsync : std_logic;
signal vgared : unsigned(3 downto 0);
signal vgagreen : unsigned(3 downto 0);
signal vgablue : unsigned(3 downto 0);
signal slowram_data : std_logic_vector(15 downto 0);
signal led0 : std_logic;
signal led1 : std_logic;
signal led2 : std_logic;
signal led3 : std_logic;
signal sw : std_logic_vector(15 downto 0) := (others => '0');
signal btn : std_logic_vector(4 downto 0) := (others => '0');
signal UART_TXD : std_logic;
signal RsRx : std_logic;
signal sseg_ca : std_logic_vector(7 downto 0);
signal sseg_an : std_logic_vector(7 downto 0);
component machine is
Port ( pixelclock : STD_LOGIC;
cpuclock : STD_LOGIC;
clock50mhz : in STD_LOGIC;
ioclock : STD_LOGIC;
uartclock : STD_LOGIC;
btnCpuReset : in STD_LOGIC;
irq : in STD_LOGIC;
nmi : in STD_LOGIC;
----------------------------------------------------------------------
-- VGA output
----------------------------------------------------------------------
vsync : out STD_LOGIC;
hsync : out STD_LOGIC;
vgared : out UNSIGNED (3 downto 0);
vgagreen : out UNSIGNED (3 downto 0);
vgablue : out UNSIGNED (3 downto 0);
---------------------------------------------------------------------------
-- IO lines to the ethernet controller
---------------------------------------------------------------------------
eth_mdio : inout std_logic;
eth_mdc : out std_logic;
eth_reset : out std_logic;
eth_rxd : in unsigned(1 downto 0);
eth_txd : out unsigned(1 downto 0);
eth_txen : out std_logic;
eth_rxdv : in std_logic;
eth_rxer : in std_logic;
eth_interrupt : in std_logic;
-------------------------------------------------------------------------
-- Lines for the SDcard interface itself
-------------------------------------------------------------------------
cs_bo : out std_logic;
sclk_o : out std_logic;
mosi_o : out std_logic;
miso_i : in std_logic;
aclMISO : in std_logic;
aclMOSI : out std_logic;
aclSS : out std_logic;
aclInt1 : in std_logic;
aclInt2 : in std_logic;
ampPWM : out std_logic;
ampSD : out std_logic;
micData : in std_logic;
micClk : out std_logic;
micLRSel : out std_logic;
tmpSDA : out std_logic;
tmpSCL : out std_logic;
tmpInt : in std_logic;
tmpCT : in std_logic;
--------------------------------------------------------------------
-- Slow RAM interface: null for now
--------------------------------------------------------------------
slowram_addr : out std_logic_vector(22 downto 0);
slowram_we : out std_logic;
slowram_ce : out std_logic;
slowram_oe : out std_logic;
slowram_lb : out std_logic;
slowram_ub : out std_logic;
slowram_data : inout std_logic_vector(15 downto 0);
----------------------------------------------------------------------
-- PS/2 adapted USB keyboard & joystick connector.
-- For now we will use a keyrah adapter to connect to the keyboard.
----------------------------------------------------------------------
ps2data : in std_logic;
ps2clock : in std_logic;
----------------------------------------------------------------------
-- Debug interfaces on Nexys4 board
----------------------------------------------------------------------
led0 : out std_logic;
led1 : out std_logic;
led2 : out std_logic;
led3 : out std_logic;
sw : in std_logic_vector(15 downto 0);
btn : in std_logic_vector(4 downto 0);
UART_TXD : out std_logic;
RsRx : in std_logic;
sseg_ca : out std_logic_vector(7 downto 0);
sseg_an : out std_logic_vector(7 downto 0)
);
end component;
begin
core0: machine
port map (
pixelclock => pixelclock,
cpuclock => cpuclock,
clock50mhz => clock50mhz,
ioclock => cpuclock,
uartclock => ioclock,
btnCpuReset => reset,
irq => '1',
nmi => '1',
ps2data => '1',
ps2clock => '1',
miso_i => '1',
aclMISO => '1',
aclInt1 => '0',
aclInt2 => '0',
micData => '0',
tmpInt => '0',
tmpCT => '0',
eth_rxd => "00",
eth_rxdv => '0',
eth_rxer => '0',
eth_interrupt => '0',
slowram_data => slowram_data,
vsync => vsync,
hsync => hsync,
vgared => vgared,
vgagreen => vgagreen,
vgablue => vgablue,
led0 => led0,
led1 => led1,
led2 => led2,
led3 => led3,
sw => sw,
btn => btn,
uart_txd => uart_txd,
rsrx => rsrx,
sseg_ca => sseg_ca,
sseg_an => sseg_an);
process
begin -- process tb
report "beginning simulation" severity note;
slowram_data <= (others => 'Z');
for i in 1 to 2000000 loop
pixelclock <= '0'; cpuclock <= '0'; ioclock <= '0';
wait for 5 ns;
pixelclock <= '1'; cpuclock <= '0'; ioclock <= '0';
wait for 5 ns;
pixelclock <= '0'; cpuclock <= '0'; ioclock <= '0';
wait for 5 ns;
pixelclock <= '1'; cpuclock <= '0'; ioclock <= '0';
wait for 5 ns;
pixelclock <= '0'; cpuclock <= '1'; ioclock <= '1';
wait for 5 ns;
pixelclock <= '1'; cpuclock <= '1'; ioclock <= '1';
wait for 5 ns;
pixelclock <= '0'; cpuclock <= '1'; ioclock <= '1';
wait for 5 ns;
pixelclock <= '1'; cpuclock <= '1'; ioclock <= '1';
wait for 5 ns;
reset <= '1';
end loop; -- i
assert false report "End of simulation" severity failure;
end process;
process
begin
for i in 1 to 20000000 loop
clock50mhz <= '0';
wait for 10 ns;
clock50mhz <= '1';
wait for 10 ns;
end loop;
end process;
end behavior;