1 |
19 |
dilbert57 |
--===========================================================================----
|
2 |
|
|
--
|
3 |
|
|
-- S Y N T H E Z I A B L E System09 - SOC.
|
4 |
|
|
--
|
5 |
|
|
-- www.OpenCores.Org - September 2003
|
6 |
|
|
-- This core adheres to the GNU public license
|
7 |
|
|
--
|
8 |
|
|
-- File name : System09.vhd
|
9 |
|
|
--
|
10 |
|
|
-- Purpose : Top level file for 6809 compatible system on a chip
|
11 |
|
|
-- Designed with Xilinx XC3S200 Spartan 3 FPGA.
|
12 |
|
|
-- Implemented With Digilent Xilinx Starter FPGA board,
|
13 |
|
|
--
|
14 |
|
|
-- Dependencies : ieee.Std_Logic_1164
|
15 |
|
|
-- ieee.std_logic_unsigned
|
16 |
|
|
-- ieee.std_logic_arith
|
17 |
|
|
-- ieee.numeric_std
|
18 |
|
|
--
|
19 |
|
|
-- Uses : mon_rom (sys09bug_rom4k_b16.vhd) Monitor ROM
|
20 |
|
|
-- cpu09 (cpu09.vhd) CPU core
|
21 |
|
|
-- dat_ram (datram.vhd) Dynamic Address Translation
|
22 |
|
|
-- acia_6850 (acia_6850.vhd) ACIA (UART)
|
23 |
|
|
-- (acia_rx.vhd)
|
24 |
|
|
-- (acia_tx.vhd)
|
25 |
|
|
-- keyboard (keyboard.vhd) PS/2 Keyboard
|
26 |
|
|
-- (ps2_keyboard.vhd)
|
27 |
|
|
-- (keymap_rom)
|
28 |
|
|
-- vdu8 (vdu8.vhd) Video Display Unit
|
29 |
|
|
-- (char_rom2K_b16.vhd)
|
30 |
|
|
-- (ram2k_b16.vhd)
|
31 |
|
|
-- seven_segment (SevenSegment.vhd) Seven Segment Display
|
32 |
|
|
--
|
33 |
|
|
-- Author : John E. Kent
|
34 |
|
|
-- dilbert57@opencores.org
|
35 |
|
|
--
|
36 |
|
|
--===========================================================================----
|
37 |
|
|
--
|
38 |
|
|
-- Revision History:
|
39 |
|
|
--===========================================================================--
|
40 |
|
|
-- Version 0.1 - 20 March 2003
|
41 |
|
|
-- Version 0.2 - 30 March 2003
|
42 |
|
|
-- Version 0.3 - 29 April 2003
|
43 |
|
|
-- Version 0.4 - 29 June 2003
|
44 |
|
|
--
|
45 |
|
|
-- Version 0.5 - 19 July 2003
|
46 |
|
|
-- prints out "Hello World"
|
47 |
|
|
--
|
48 |
|
|
-- Version 0.6 - 5 September 2003
|
49 |
|
|
-- Runs SBUG
|
50 |
|
|
--
|
51 |
|
|
-- Version 1.0- 6 Sep 2003 - John Kent
|
52 |
|
|
-- Inverted SysClk
|
53 |
|
|
-- Initial release to Open Cores
|
54 |
|
|
--
|
55 |
|
|
-- Version 1.1 - 17 Jan 2004 - John Kent
|
56 |
|
|
-- Updated miniUart.
|
57 |
|
|
--
|
58 |
|
|
-- Version 1.2 - 25 Jan 2004 - John Kent
|
59 |
|
|
-- removed signals "test_alu" and "test_cc"
|
60 |
|
|
-- Trap hardware re-instated.
|
61 |
|
|
--
|
62 |
|
|
-- Version 1.3 - 11 Feb 2004 - John Kent
|
63 |
|
|
-- Designed forked off to produce System09_VDU
|
64 |
|
|
-- Added VDU component
|
65 |
|
|
-- VDU runs at 25MHz and divides the clock by 2 for the CPU
|
66 |
|
|
-- UART Runs at 57.6 Kbps
|
67 |
|
|
--
|
68 |
|
|
-- Version 2.0 - 2 September 2004 - John Kent
|
69 |
|
|
-- ported to Digilent Xilinx Spartan3 starter board
|
70 |
|
|
-- removed Compaact Flash and Trap Logic.
|
71 |
|
|
-- Replaced SBUG with KBug9s
|
72 |
|
|
--
|
73 |
|
|
-- Version 2.1 - 21 November 2006 - John Kent
|
74 |
|
|
-- Replaced KBug9s with Sys09bug 1.0
|
75 |
|
|
-- Inverted bottom nybble of DAT register outputs
|
76 |
|
|
-- Changed ROM & I/O decoding to be compatible with SWTPc
|
77 |
|
|
-- Upped the serial baud rate to 115.2 KBd
|
78 |
|
|
-- added multiple global clock buffers
|
79 |
|
|
-- (Uart would not operate correctly)
|
80 |
|
|
--
|
81 |
|
|
-- Version 2.2 - 22 December 2006 - John Kent
|
82 |
|
|
-- Increased CPU clock from 12.5MHz to 25 MHz.
|
83 |
|
|
-- Removed some of the global clock buffers
|
84 |
|
|
-- Added LED output register
|
85 |
|
|
-- Changed address decoding to 4K Blocks
|
86 |
|
|
--
|
87 |
|
|
-- Vesrion 2.3 - 1 June 2007 - John Kent
|
88 |
|
|
-- Updated VDU & ACIA
|
89 |
|
|
-- Changed decoding for Sys09Bug
|
90 |
|
|
--
|
91 |
|
|
--===========================================================================--
|
92 |
|
|
library ieee;
|
93 |
|
|
use ieee.std_logic_1164.all;
|
94 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
95 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
96 |
|
|
use ieee.numeric_std.all;
|
97 |
|
|
|
98 |
|
|
entity My_System09 is
|
99 |
|
|
port(
|
100 |
|
|
SysClk : in Std_Logic; -- System Clock input
|
101 |
|
|
Reset_sw : in Std_logic; -- Master Reset input (active low)
|
102 |
|
|
nmi_sw : in Std_logic;
|
103 |
|
|
|
104 |
|
|
-- Memory Interface signals
|
105 |
|
|
ram_addr : out Std_Logic_Vector(17 downto 0);
|
106 |
|
|
ram_wen : out Std_Logic;
|
107 |
|
|
ram_oen : out Std_Logic;
|
108 |
|
|
|
109 |
|
|
ram1_cen : out Std_Logic;
|
110 |
|
|
ram1_ubn : out Std_Logic;
|
111 |
|
|
ram1_lbn : out Std_Logic;
|
112 |
|
|
ram1_data : inout Std_Logic_Vector(15 downto 0);
|
113 |
|
|
|
114 |
|
|
ram2_cen : out Std_Logic;
|
115 |
|
|
ram2_ubn : out Std_Logic;
|
116 |
|
|
ram2_lbn : out Std_Logic;
|
117 |
|
|
ram2_data : inout Std_Logic_Vector(15 downto 0);
|
118 |
|
|
|
119 |
|
|
-- PS/2 Keyboard
|
120 |
|
|
ps2c : inout Std_logic;
|
121 |
|
|
ps2d : inout Std_Logic;
|
122 |
|
|
|
123 |
|
|
-- Uart Interface
|
124 |
|
|
rxd : in Std_Logic;
|
125 |
|
|
txd : out Std_Logic;
|
126 |
|
|
|
127 |
|
|
-- CRTC output signals
|
128 |
|
|
vs : out Std_Logic;
|
129 |
|
|
hs : out Std_Logic;
|
130 |
|
|
blue : out std_logic;
|
131 |
|
|
green : out std_logic;
|
132 |
|
|
red : out std_logic;
|
133 |
|
|
|
134 |
|
|
-- LEDS & Switches
|
135 |
|
|
leds : out std_logic_vector(7 downto 0);
|
136 |
|
|
switches : in std_logic_vector(7 downto 0);
|
137 |
|
|
|
138 |
|
|
-- seven segment display
|
139 |
|
|
segments : out std_logic_vector(7 downto 0);
|
140 |
|
|
digits : out std_logic_vector(3 downto 0)
|
141 |
|
|
);
|
142 |
|
|
end My_System09;
|
143 |
|
|
|
144 |
|
|
-------------------------------------------------------------------------------
|
145 |
|
|
-- Architecture for System09
|
146 |
|
|
-------------------------------------------------------------------------------
|
147 |
|
|
architecture my_computer of My_System09 is
|
148 |
|
|
-----------------------------------------------------------------------------
|
149 |
|
|
-- constants
|
150 |
|
|
-----------------------------------------------------------------------------
|
151 |
|
|
constant SYS_Clock_Frequency : integer := 50000000; -- FPGA System Clock
|
152 |
|
|
constant VGA_Clock_Frequency : integer := 25000000; -- VGA Pixel Clock
|
153 |
|
|
constant CPU_Clock_Frequency : integer := 25000000; -- CPU Clock
|
154 |
|
|
constant BAUD_Rate : integer := 57600; -- Baud Rate
|
155 |
|
|
constant ACIA_Clock_Frequency : integer := BAUD_Rate * 16;
|
156 |
|
|
|
157 |
|
|
type hold_state_type is ( hold_release_state, hold_request_state );
|
158 |
|
|
|
159 |
|
|
-----------------------------------------------------------------------------
|
160 |
|
|
-- Signals
|
161 |
|
|
-----------------------------------------------------------------------------
|
162 |
|
|
-- BOOT ROM
|
163 |
|
|
signal rom_cs : Std_logic;
|
164 |
|
|
signal rom_data_out : Std_Logic_Vector(7 downto 0);
|
165 |
|
|
|
166 |
|
|
-- FLEX9 RAM
|
167 |
|
|
signal flex_cs : Std_logic;
|
168 |
|
|
signal flex_data_out : Std_Logic_Vector(7 downto 0);
|
169 |
|
|
|
170 |
|
|
-- UART Interface signals
|
171 |
|
|
signal acia_clk : std_logic;
|
172 |
|
|
signal acia_data_out : Std_Logic_Vector(7 downto 0);
|
173 |
|
|
signal acia_cs : Std_Logic;
|
174 |
|
|
signal acia_irq : Std_Logic;
|
175 |
|
|
signal DCD_n : Std_Logic;
|
176 |
|
|
signal RTS_n : Std_Logic;
|
177 |
|
|
signal CTS_n : Std_Logic;
|
178 |
|
|
|
179 |
|
|
-- keyboard port
|
180 |
|
|
signal keyboard_data_out : std_logic_vector(7 downto 0);
|
181 |
|
|
signal keyboard_cs : std_logic;
|
182 |
|
|
signal keyboard_irq : std_logic;
|
183 |
|
|
|
184 |
|
|
-- LEDs
|
185 |
|
|
signal leds_data_out : std_logic_vector(7 downto 0);
|
186 |
|
|
signal leds_cs : std_logic;
|
187 |
|
|
|
188 |
|
|
-- RAM
|
189 |
|
|
signal ram_cs : std_logic; -- memory chip select
|
190 |
|
|
signal ram_data_out : std_logic_vector(7 downto 0);
|
191 |
|
|
signal ram1_ce : std_logic;
|
192 |
|
|
signal ram1_ub : std_logic;
|
193 |
|
|
signal ram1_lb : std_logic;
|
194 |
|
|
signal ram2_ce : std_logic;
|
195 |
|
|
signal ram2_ub : std_logic;
|
196 |
|
|
signal ram2_lb : std_logic;
|
197 |
|
|
signal ram_we : std_logic;
|
198 |
|
|
signal ram_oe : std_logic;
|
199 |
|
|
|
200 |
|
|
-- CPU Interface signals
|
201 |
|
|
signal cpu_reset : Std_Logic;
|
202 |
|
|
signal cpu_clk : Std_Logic;
|
203 |
|
|
signal cpu_rw : std_logic;
|
204 |
|
|
signal cpu_vma : std_logic;
|
205 |
|
|
signal cpu_halt : std_logic;
|
206 |
|
|
signal cpu_hold : std_logic;
|
207 |
|
|
signal cpu_firq : std_logic;
|
208 |
|
|
signal cpu_irq : std_logic;
|
209 |
|
|
signal cpu_nmi : std_logic;
|
210 |
|
|
signal cpu_addr : std_logic_vector(15 downto 0);
|
211 |
|
|
signal cpu_data_in : std_logic_vector(7 downto 0);
|
212 |
|
|
signal cpu_data_out : std_logic_vector(7 downto 0);
|
213 |
|
|
|
214 |
|
|
-- Dynamic Address Translation
|
215 |
|
|
signal dat_cs : std_logic;
|
216 |
|
|
signal dat_addr : std_logic_vector(7 downto 0);
|
217 |
|
|
|
218 |
|
|
-- Video Display Unit
|
219 |
|
|
signal vdu_cs : std_logic;
|
220 |
|
|
signal vdu_data_out : std_logic_vector(7 downto 0);
|
221 |
|
|
signal vga_clk : std_logic;
|
222 |
|
|
|
223 |
|
|
-- 7 Segment Display
|
224 |
|
|
signal seg_cs : std_logic;
|
225 |
|
|
signal seg_data_out : std_logic_vector(7 downto 0);
|
226 |
|
|
|
227 |
|
|
-- System Clock Prescaler
|
228 |
|
|
signal clk_count : std_logic;
|
229 |
|
|
|
230 |
|
|
-----------------------------------------------------------------
|
231 |
|
|
--
|
232 |
|
|
-- CPU09 CPU core
|
233 |
|
|
--
|
234 |
|
|
-----------------------------------------------------------------
|
235 |
|
|
|
236 |
|
|
component cpu09
|
237 |
|
|
port (
|
238 |
|
|
clk : in std_logic;
|
239 |
|
|
rst : in std_logic;
|
240 |
|
|
rw : out std_logic; -- Asynchronous memory interface
|
241 |
|
|
vma : out std_logic;
|
242 |
|
|
address : out std_logic_vector(15 downto 0);
|
243 |
|
|
data_in : in std_logic_vector(7 downto 0);
|
244 |
|
|
data_out : out std_logic_vector(7 downto 0);
|
245 |
|
|
halt : in std_logic;
|
246 |
|
|
hold : in std_logic;
|
247 |
|
|
irq : in std_logic;
|
248 |
|
|
nmi : in std_logic;
|
249 |
|
|
firq : in std_logic
|
250 |
|
|
);
|
251 |
|
|
end component;
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
----------------------------------------
|
255 |
|
|
--
|
256 |
|
|
-- 4KByte Block RAM Monitor ROM
|
257 |
|
|
--
|
258 |
|
|
----------------------------------------
|
259 |
|
|
component mon_rom
|
260 |
|
|
Port (
|
261 |
|
|
clk : in std_logic;
|
262 |
|
|
rst : in std_logic;
|
263 |
|
|
cs : in std_logic;
|
264 |
|
|
rw : in std_logic;
|
265 |
|
|
addr : in std_logic_vector (11 downto 0);
|
266 |
|
|
rdata : out std_logic_vector (7 downto 0);
|
267 |
|
|
wdata : in std_logic_vector (7 downto 0)
|
268 |
|
|
);
|
269 |
|
|
end component;
|
270 |
|
|
|
271 |
|
|
----------------------------------------
|
272 |
|
|
--
|
273 |
|
|
-- 8KBytes Block RAM for FLEX9
|
274 |
|
|
-- $C000 - $DFFF
|
275 |
|
|
--
|
276 |
|
|
----------------------------------------
|
277 |
|
|
component flex_ram
|
278 |
|
|
Port (
|
279 |
|
|
clk : in std_logic;
|
280 |
|
|
rst : in std_logic;
|
281 |
|
|
cs : in std_logic;
|
282 |
|
|
rw : in std_logic;
|
283 |
|
|
addr : in std_logic_vector (12 downto 0);
|
284 |
|
|
rdata : out std_logic_vector (7 downto 0);
|
285 |
|
|
wdata : in std_logic_vector (7 downto 0)
|
286 |
|
|
);
|
287 |
|
|
end component;
|
288 |
|
|
|
289 |
|
|
----------------------------------------
|
290 |
|
|
--
|
291 |
|
|
-- Dynamic Address Translation Registers
|
292 |
|
|
--
|
293 |
|
|
----------------------------------------
|
294 |
|
|
component dat_ram
|
295 |
|
|
port (
|
296 |
|
|
clk : in std_logic;
|
297 |
|
|
rst : in std_logic;
|
298 |
|
|
cs : in std_logic;
|
299 |
|
|
rw : in std_logic;
|
300 |
|
|
addr_lo : in std_logic_vector(3 downto 0);
|
301 |
|
|
addr_hi : in std_logic_vector(3 downto 0);
|
302 |
|
|
data_in : in std_logic_vector(7 downto 0);
|
303 |
|
|
data_out : out std_logic_vector(7 downto 0)
|
304 |
|
|
);
|
305 |
|
|
end component;
|
306 |
|
|
|
307 |
|
|
-----------------------------------------------------------------
|
308 |
|
|
--
|
309 |
|
|
-- Open Cores Mini UART
|
310 |
|
|
--
|
311 |
|
|
-----------------------------------------------------------------
|
312 |
|
|
|
313 |
|
|
component ACIA_6850
|
314 |
|
|
port (
|
315 |
|
|
clk : in Std_Logic; -- System Clock
|
316 |
|
|
rst : in Std_Logic; -- Reset input (active high)
|
317 |
|
|
cs : in Std_Logic; -- miniUART Chip Select
|
318 |
|
|
rw : in Std_Logic; -- Read / Not Write
|
319 |
|
|
irq : out Std_Logic; -- Interrupt
|
320 |
|
|
Addr : in Std_Logic; -- Register Select
|
321 |
|
|
DataIn : in Std_Logic_Vector(7 downto 0); -- Data Bus In
|
322 |
|
|
DataOut : out Std_Logic_Vector(7 downto 0); -- Data Bus Out
|
323 |
|
|
RxC : in Std_Logic; -- Receive Baud Clock
|
324 |
|
|
TxC : in Std_Logic; -- Transmit Baud Clock
|
325 |
|
|
RxD : in Std_Logic; -- Receive Data
|
326 |
|
|
TxD : out Std_Logic; -- Transmit Data
|
327 |
|
|
DCD_n : in Std_Logic; -- Data Carrier Detect
|
328 |
|
|
CTS_n : in Std_Logic; -- Clear To Send
|
329 |
|
|
RTS_n : out Std_Logic -- Request To send
|
330 |
|
|
);
|
331 |
|
|
end component;
|
332 |
|
|
|
333 |
|
|
-----------------------------------------------------------------
|
334 |
|
|
--
|
335 |
|
|
-- ACIA Clock divider
|
336 |
|
|
--
|
337 |
|
|
-----------------------------------------------------------------
|
338 |
|
|
|
339 |
|
|
component ACIA_Clock
|
340 |
|
|
generic (
|
341 |
|
|
SYS_Clock_Frequency : integer := SYS_Clock_Frequency;
|
342 |
|
|
ACIA_Clock_Frequency : integer := ACIA_Clock_Frequency
|
343 |
|
|
);
|
344 |
|
|
port (
|
345 |
|
|
clk : in Std_Logic; -- System Clock Input
|
346 |
|
|
ACIA_clk : out Std_logic -- ACIA Clock output
|
347 |
|
|
);
|
348 |
|
|
end component;
|
349 |
|
|
|
350 |
|
|
|
351 |
|
|
----------------------------------------
|
352 |
|
|
--
|
353 |
|
|
-- PS/2 Keyboard
|
354 |
|
|
--
|
355 |
|
|
----------------------------------------
|
356 |
|
|
|
357 |
|
|
component keyboard
|
358 |
|
|
generic(
|
359 |
|
|
KBD_Clock_Frequency : integer := CPU_Clock_Frequency
|
360 |
|
|
);
|
361 |
|
|
port(
|
362 |
|
|
clk : in std_logic;
|
363 |
|
|
rst : in std_logic;
|
364 |
|
|
cs : in std_logic;
|
365 |
|
|
rw : in std_logic;
|
366 |
|
|
addr : in std_logic;
|
367 |
|
|
data_in : in std_logic_vector(7 downto 0);
|
368 |
|
|
data_out : out std_logic_vector(7 downto 0);
|
369 |
|
|
irq : out std_logic;
|
370 |
|
|
kbd_clk : inout std_logic;
|
371 |
|
|
kbd_data : inout std_logic
|
372 |
|
|
);
|
373 |
|
|
end component;
|
374 |
|
|
|
375 |
|
|
----------------------------------------
|
376 |
|
|
--
|
377 |
|
|
-- Video Display Unit.
|
378 |
|
|
--
|
379 |
|
|
----------------------------------------
|
380 |
|
|
component vdu8
|
381 |
|
|
generic(
|
382 |
|
|
VDU_CLOCK_FREQUENCY : integer := CPU_Clock_Frequency; -- HZ
|
383 |
|
|
VGA_CLOCK_FREQUENCY : integer := VGA_Clock_Frequency; -- HZ
|
384 |
|
|
VGA_HOR_CHARS : integer := 80; -- CHARACTERS
|
385 |
|
|
VGA_VER_CHARS : integer := 25; -- CHARACTERS
|
386 |
|
|
VGA_PIXELS_PER_CHAR : integer := 8; -- PIXELS
|
387 |
|
|
VGA_LINES_PER_CHAR : integer := 16; -- LINES
|
388 |
|
|
VGA_HOR_BACK_PORCH : integer := 40; -- PIXELS
|
389 |
|
|
VGA_HOR_SYNC : integer := 96; -- PIXELS
|
390 |
|
|
VGA_HOR_FRONT_PORCH : integer := 24; -- PIXELS
|
391 |
|
|
VGA_VER_BACK_PORCH : integer := 13; -- LINES
|
392 |
|
|
VGA_VER_SYNC : integer := 1; -- LINES
|
393 |
|
|
VGA_VER_FRONT_PORCH : integer := 36 -- LINES
|
394 |
|
|
);
|
395 |
|
|
port(
|
396 |
|
|
-- control register interface
|
397 |
|
|
vdu_clk : in std_logic; -- CPU Clock - 12.5MHz
|
398 |
|
|
vdu_rst : in std_logic;
|
399 |
|
|
vdu_cs : in std_logic;
|
400 |
|
|
vdu_rw : in std_logic;
|
401 |
|
|
vdu_addr : in std_logic_vector(2 downto 0);
|
402 |
|
|
vdu_data_in : in std_logic_vector(7 downto 0);
|
403 |
|
|
vdu_data_out : out std_logic_vector(7 downto 0);
|
404 |
|
|
|
405 |
|
|
-- vga port connections
|
406 |
|
|
vga_clk : in std_logic; -- VGA Pixel Clock - 25 MHz
|
407 |
|
|
vga_red_o : out std_logic;
|
408 |
|
|
vga_green_o : out std_logic;
|
409 |
|
|
vga_blue_o : out std_logic;
|
410 |
|
|
vga_hsync_o : out std_logic;
|
411 |
|
|
vga_vsync_o : out std_logic
|
412 |
|
|
);
|
413 |
|
|
end component;
|
414 |
|
|
|
415 |
|
|
----------------------------------------
|
416 |
|
|
--
|
417 |
|
|
-- Seven Segment Display driver
|
418 |
|
|
--
|
419 |
|
|
----------------------------------------
|
420 |
|
|
|
421 |
|
|
component seven_segment is
|
422 |
|
|
port (
|
423 |
|
|
clk : in std_logic;
|
424 |
|
|
rst : in std_logic;
|
425 |
|
|
cs : in std_logic;
|
426 |
|
|
rw : in std_logic;
|
427 |
|
|
addr : in std_logic_vector(1 downto 0);
|
428 |
|
|
data_in : in std_logic_vector(7 downto 0);
|
429 |
|
|
data_out : out std_logic_vector(7 downto 0);
|
430 |
|
|
segments : out std_logic_vector(7 downto 0);
|
431 |
|
|
digits : out std_logic_vector(3 downto 0)
|
432 |
|
|
);
|
433 |
|
|
end component;
|
434 |
|
|
|
435 |
|
|
component BUFG
|
436 |
|
|
port (
|
437 |
|
|
i : in std_logic;
|
438 |
|
|
o : out std_logic
|
439 |
|
|
);
|
440 |
|
|
end component;
|
441 |
|
|
|
442 |
|
|
begin
|
443 |
|
|
-----------------------------------------------------------------------------
|
444 |
|
|
-- Instantiation of internal components
|
445 |
|
|
-----------------------------------------------------------------------------
|
446 |
|
|
|
447 |
|
|
my_cpu : cpu09 port map (
|
448 |
|
|
clk => cpu_clk,
|
449 |
|
|
rst => cpu_reset,
|
450 |
|
|
rw => cpu_rw,
|
451 |
|
|
vma => cpu_vma,
|
452 |
|
|
address => cpu_addr(15 downto 0),
|
453 |
|
|
data_in => cpu_data_in,
|
454 |
|
|
data_out => cpu_data_out,
|
455 |
|
|
halt => cpu_halt,
|
456 |
|
|
hold => cpu_hold,
|
457 |
|
|
irq => cpu_irq,
|
458 |
|
|
nmi => cpu_nmi,
|
459 |
|
|
firq => cpu_firq
|
460 |
|
|
);
|
461 |
|
|
|
462 |
|
|
my_rom : mon_rom port map (
|
463 |
|
|
clk => cpu_clk,
|
464 |
|
|
rst => cpu_reset,
|
465 |
|
|
cs => rom_cs,
|
466 |
|
|
rw => '1',
|
467 |
|
|
addr => cpu_addr(11 downto 0),
|
468 |
|
|
rdata => rom_data_out,
|
469 |
|
|
wdata => cpu_data_out
|
470 |
|
|
);
|
471 |
|
|
|
472 |
|
|
my_flex : flex_ram port map (
|
473 |
|
|
clk => cpu_clk,
|
474 |
|
|
rst => cpu_reset,
|
475 |
|
|
cs => flex_cs,
|
476 |
|
|
rw => cpu_rw,
|
477 |
|
|
addr => cpu_addr(12 downto 0),
|
478 |
|
|
rdata => flex_data_out,
|
479 |
|
|
wdata => cpu_data_out
|
480 |
|
|
);
|
481 |
|
|
|
482 |
|
|
my_dat : dat_ram port map (
|
483 |
|
|
clk => cpu_clk,
|
484 |
|
|
rst => cpu_reset,
|
485 |
|
|
cs => dat_cs,
|
486 |
|
|
rw => cpu_rw,
|
487 |
|
|
addr_hi => cpu_addr(15 downto 12),
|
488 |
|
|
addr_lo => cpu_addr(3 downto 0),
|
489 |
|
|
data_in => cpu_data_out,
|
490 |
|
|
data_out => dat_addr(7 downto 0)
|
491 |
|
|
);
|
492 |
|
|
|
493 |
|
|
my_acia : ACIA_6850 port map (
|
494 |
|
|
clk => cpu_clk,
|
495 |
|
|
rst => cpu_reset,
|
496 |
|
|
cs => acia_cs,
|
497 |
|
|
rw => cpu_rw,
|
498 |
|
|
irq => acia_irq,
|
499 |
|
|
Addr => cpu_addr(0),
|
500 |
|
|
Datain => cpu_data_out,
|
501 |
|
|
DataOut => acia_data_out,
|
502 |
|
|
RxC => acia_clk,
|
503 |
|
|
TxC => acia_clk,
|
504 |
|
|
RxD => rxd,
|
505 |
|
|
TxD => txd,
|
506 |
|
|
DCD_n => dcd_n,
|
507 |
|
|
CTS_n => cts_n,
|
508 |
|
|
RTS_n => rts_n
|
509 |
|
|
);
|
510 |
|
|
|
511 |
|
|
|
512 |
|
|
----------------------------------------
|
513 |
|
|
--
|
514 |
|
|
-- ACIA Clock
|
515 |
|
|
--
|
516 |
|
|
----------------------------------------
|
517 |
|
|
my_ACIA_Clock : ACIA_Clock
|
518 |
|
|
generic map(
|
519 |
|
|
SYS_Clock_Frequency => SYS_Clock_Frequency,
|
520 |
|
|
ACIA_Clock_Frequency => ACIA_Clock_Frequency
|
521 |
|
|
)
|
522 |
|
|
port map(
|
523 |
|
|
clk => SysClk,
|
524 |
|
|
acia_clk => acia_clk
|
525 |
|
|
);
|
526 |
|
|
|
527 |
|
|
|
528 |
|
|
----------------------------------------
|
529 |
|
|
--
|
530 |
|
|
-- PS/2 Keyboard Interface
|
531 |
|
|
--
|
532 |
|
|
----------------------------------------
|
533 |
|
|
my_keyboard : keyboard
|
534 |
|
|
generic map (
|
535 |
|
|
KBD_Clock_Frequency => CPU_Clock_frequency
|
536 |
|
|
)
|
537 |
|
|
port map(
|
538 |
|
|
clk => cpu_clk,
|
539 |
|
|
rst => cpu_reset,
|
540 |
|
|
cs => keyboard_cs,
|
541 |
|
|
rw => cpu_rw,
|
542 |
|
|
addr => cpu_addr(0),
|
543 |
|
|
data_in => cpu_data_out(7 downto 0),
|
544 |
|
|
data_out => keyboard_data_out(7 downto 0),
|
545 |
|
|
irq => keyboard_irq,
|
546 |
|
|
kbd_clk => ps2c,
|
547 |
|
|
kbd_data => ps2d
|
548 |
|
|
);
|
549 |
|
|
|
550 |
|
|
----------------------------------------
|
551 |
|
|
--
|
552 |
|
|
-- Video Display Unit instantiation
|
553 |
|
|
--
|
554 |
|
|
----------------------------------------
|
555 |
|
|
my_vdu : vdu8
|
556 |
|
|
generic map(
|
557 |
|
|
VDU_CLOCK_FREQUENCY => CPU_Clock_Frequency, -- HZ
|
558 |
|
|
VGA_CLOCK_FREQUENCY => VGA_Clock_Frequency, -- HZ
|
559 |
|
|
VGA_HOR_CHARS => 80, -- CHARACTERS
|
560 |
|
|
VGA_VER_CHARS => 25, -- CHARACTERS
|
561 |
|
|
VGA_PIXELS_PER_CHAR => 8, -- PIXELS
|
562 |
|
|
VGA_LINES_PER_CHAR => 16, -- LINES
|
563 |
|
|
VGA_HOR_BACK_PORCH => 40, -- PIXELS
|
564 |
|
|
VGA_HOR_SYNC => 96, -- PIXELS
|
565 |
|
|
VGA_HOR_FRONT_PORCH => 24, -- PIXELS
|
566 |
|
|
VGA_VER_BACK_PORCH => 13, -- LINES
|
567 |
|
|
VGA_VER_SYNC => 1, -- LINES
|
568 |
|
|
VGA_VER_FRONT_PORCH => 36 -- LINES
|
569 |
|
|
)
|
570 |
|
|
port map(
|
571 |
|
|
|
572 |
|
|
-- Control Registers
|
573 |
|
|
vdu_clk => cpu_clk, -- 12.5 MHz System Clock in
|
574 |
|
|
vdu_rst => cpu_reset,
|
575 |
|
|
vdu_cs => vdu_cs,
|
576 |
|
|
vdu_rw => cpu_rw,
|
577 |
|
|
vdu_addr => cpu_addr(2 downto 0),
|
578 |
|
|
vdu_data_in => cpu_data_out,
|
579 |
|
|
vdu_data_out => vdu_data_out,
|
580 |
|
|
|
581 |
|
|
-- vga port connections
|
582 |
|
|
vga_clk => vga_clk, -- 25 MHz VDU pixel clock
|
583 |
|
|
vga_red_o => red,
|
584 |
|
|
vga_green_o => green,
|
585 |
|
|
vga_blue_o => blue,
|
586 |
|
|
vga_hsync_o => hs,
|
587 |
|
|
vga_vsync_o => vs
|
588 |
|
|
);
|
589 |
|
|
|
590 |
|
|
|
591 |
|
|
----------------------------------------
|
592 |
|
|
--
|
593 |
|
|
-- Seven Segment Display instantiation
|
594 |
|
|
--
|
595 |
|
|
----------------------------------------
|
596 |
|
|
|
597 |
|
|
my_seg : seven_segment port map (
|
598 |
|
|
clk => cpu_clk,
|
599 |
|
|
rst => cpu_reset,
|
600 |
|
|
cs => seg_cs,
|
601 |
|
|
rw => cpu_rw,
|
602 |
|
|
addr => cpu_addr(1 downto 0),
|
603 |
|
|
data_in => cpu_data_out,
|
604 |
|
|
data_out => seg_data_out,
|
605 |
|
|
segments => segments,
|
606 |
|
|
digits => digits
|
607 |
|
|
);
|
608 |
|
|
|
609 |
|
|
|
610 |
|
|
vga_clk_buffer : BUFG port map(
|
611 |
|
|
i => clk_count,
|
612 |
|
|
o => vga_clk
|
613 |
|
|
);
|
614 |
|
|
|
615 |
|
|
cpu_clk_buffer : BUFG port map(
|
616 |
|
|
i => clk_count,
|
617 |
|
|
o => cpu_clk
|
618 |
|
|
);
|
619 |
|
|
|
620 |
|
|
--
|
621 |
|
|
-- Clock divider
|
622 |
|
|
-- Assumes 50 MHz system clock
|
623 |
|
|
-- 25MHz pixel clock
|
624 |
|
|
-- 25MHz CPU clock
|
625 |
|
|
--
|
626 |
|
|
sys09_clock : process( SysClk, clk_count )
|
627 |
|
|
begin
|
628 |
|
|
if SysClk'event and SysClk='0' then
|
629 |
|
|
clk_count <= not clk_count;
|
630 |
|
|
end if;
|
631 |
|
|
end process;
|
632 |
|
|
|
633 |
|
|
----------------------------------------------------------------------
|
634 |
|
|
--
|
635 |
|
|
-- Process to decode memory map
|
636 |
|
|
--
|
637 |
|
|
----------------------------------------------------------------------
|
638 |
|
|
|
639 |
|
|
mem_decode: process( cpu_clk, Reset_sw,
|
640 |
|
|
cpu_addr, cpu_rw, cpu_vma,
|
641 |
|
|
dat_cs, dat_addr,
|
642 |
|
|
rom_data_out,
|
643 |
|
|
acia_data_out,
|
644 |
|
|
keyboard_data_out,
|
645 |
|
|
vdu_data_out,
|
646 |
|
|
seg_data_out,
|
647 |
|
|
leds_data_out,
|
648 |
|
|
flex_data_out,
|
649 |
|
|
ram_data_out
|
650 |
|
|
)
|
651 |
|
|
begin
|
652 |
|
|
if cpu_addr( 15 downto 8 ) = "11111111" then
|
653 |
|
|
cpu_data_in <= rom_data_out;
|
654 |
|
|
dat_cs <= cpu_vma; -- write DAT
|
655 |
|
|
rom_cs <= cpu_vma; -- read ROM
|
656 |
|
|
acia_cs <= '0';
|
657 |
|
|
keyboard_cs <= '0';
|
658 |
|
|
vdu_cs <= '0';
|
659 |
|
|
seg_cs <= '0';
|
660 |
|
|
leds_cs <= '0';
|
661 |
|
|
flex_cs <= '0';
|
662 |
|
|
ram_cs <= '0';
|
663 |
|
|
else
|
664 |
|
|
case dat_addr(3 downto 0) is
|
665 |
|
|
--
|
666 |
|
|
-- Monitor ROM $F000 - $FFFF
|
667 |
|
|
--
|
668 |
|
|
when "1111" => -- $XF000 - $XFFFF
|
669 |
|
|
cpu_data_in <= rom_data_out;
|
670 |
|
|
dat_cs <= '0'; -- write DAT
|
671 |
|
|
rom_cs <= cpu_vma; -- read ROM
|
672 |
|
|
acia_cs <= '0';
|
673 |
|
|
keyboard_cs <= '0';
|
674 |
|
|
vdu_cs <= '0';
|
675 |
|
|
seg_cs <= '0';
|
676 |
|
|
leds_cs <= '0';
|
677 |
|
|
flex_cs <= '0';
|
678 |
|
|
ram_cs <= '0';
|
679 |
|
|
|
680 |
|
|
--
|
681 |
|
|
-- IO Devices $E000 - $EFFF
|
682 |
|
|
--
|
683 |
|
|
when "1110" => -- $XE000 - $XEFFF
|
684 |
|
|
dat_cs <= '0';
|
685 |
|
|
rom_cs <= '0';
|
686 |
|
|
case cpu_addr(7 downto 4) is
|
687 |
|
|
--
|
688 |
|
|
-- UART / ACIA ($E000 - $E00F)
|
689 |
|
|
--
|
690 |
|
|
when "0000" =>
|
691 |
|
|
cpu_data_in <= acia_data_out;
|
692 |
|
|
acia_cs <= cpu_vma;
|
693 |
|
|
keyboard_cs <= '0';
|
694 |
|
|
vdu_cs <= '0';
|
695 |
|
|
seg_cs <= '0';
|
696 |
|
|
leds_cs <= '0';
|
697 |
|
|
|
698 |
|
|
--
|
699 |
|
|
-- Reserved - FD1771 FDC ($E010 - $E01F) (SWTPC)
|
700 |
|
|
--
|
701 |
|
|
|
702 |
|
|
--
|
703 |
|
|
-- Keyboard port ($E020 - $E02F)
|
704 |
|
|
--
|
705 |
|
|
when "0010" =>
|
706 |
|
|
cpu_data_in <= keyboard_data_out;
|
707 |
|
|
acia_cs <= '0';
|
708 |
|
|
keyboard_cs <= cpu_vma;
|
709 |
|
|
vdu_cs <= '0';
|
710 |
|
|
seg_cs <= '0';
|
711 |
|
|
leds_cs <= '0';
|
712 |
|
|
|
713 |
|
|
--
|
714 |
|
|
-- VDU port ($E030 - $E03F)
|
715 |
|
|
--
|
716 |
|
|
when "0011" =>
|
717 |
|
|
cpu_data_in <= vdu_data_out;
|
718 |
|
|
acia_cs <= '0';
|
719 |
|
|
keyboard_cs <= '0';
|
720 |
|
|
vdu_cs <= cpu_vma;
|
721 |
|
|
seg_cs <= '0';
|
722 |
|
|
leds_cs <= '0';
|
723 |
|
|
|
724 |
|
|
--
|
725 |
|
|
-- Reserved - Compact Flash ($E040 - $E04F) (B5-X300)
|
726 |
|
|
--
|
727 |
|
|
|
728 |
|
|
--
|
729 |
|
|
-- Reserved - Timer ($E050 - $E05F) (B5-X300)
|
730 |
|
|
--
|
731 |
|
|
|
732 |
|
|
--
|
733 |
|
|
-- Reserved - Bus Trap Logic ($E060 - $E06F) (B5-X300)
|
734 |
|
|
--
|
735 |
|
|
|
736 |
|
|
--
|
737 |
|
|
-- Reserved - I/O port ($E070 - $E07F) (B5-X300)
|
738 |
|
|
--
|
739 |
|
|
|
740 |
|
|
--
|
741 |
|
|
-- Reserved - PTM 6840 ($E080 - $E08F) (SWTPC)
|
742 |
|
|
--
|
743 |
|
|
|
744 |
|
|
--
|
745 |
|
|
-- Reserved - PIA Timer ($E090 - $E09F) (SWTPC)
|
746 |
|
|
--
|
747 |
|
|
|
748 |
|
|
--
|
749 |
|
|
-- Read Switched port ($E0A0 - $E0AF)
|
750 |
|
|
-- Write LEDS
|
751 |
|
|
--
|
752 |
|
|
when "1010" =>
|
753 |
|
|
cpu_data_in <= leds_data_out;
|
754 |
|
|
acia_cs <= '0';
|
755 |
|
|
keyboard_cs <= '0';
|
756 |
|
|
vdu_cs <= '0';
|
757 |
|
|
seg_cs <= '0';
|
758 |
|
|
leds_cs <= cpu_vma;
|
759 |
|
|
|
760 |
|
|
--
|
761 |
|
|
-- 7 segment display port ($E0B0 - $E0BF)
|
762 |
|
|
--
|
763 |
|
|
when "1011" =>
|
764 |
|
|
cpu_data_in <= seg_data_out;
|
765 |
|
|
acia_cs <= '0';
|
766 |
|
|
keyboard_cs <= '0';
|
767 |
|
|
vdu_cs <= '0';
|
768 |
|
|
seg_cs <= cpu_vma;
|
769 |
|
|
leds_cs <= '0';
|
770 |
|
|
|
771 |
|
|
|
772 |
|
|
when others => -- $EXC0 to $EXFF
|
773 |
|
|
cpu_data_in <= "00000000";
|
774 |
|
|
acia_cs <= '0';
|
775 |
|
|
keyboard_cs <= '0';
|
776 |
|
|
vdu_cs <= '0';
|
777 |
|
|
seg_cs <= '0';
|
778 |
|
|
leds_cs <= '0';
|
779 |
|
|
end case;
|
780 |
|
|
flex_cs <= '0';
|
781 |
|
|
ram_cs <= '0';
|
782 |
|
|
--
|
783 |
|
|
-- FLEX RAM $0C000 - $0DFFF
|
784 |
|
|
--
|
785 |
|
|
when "1100" | "1101" => -- $0C000 - $0DFFF
|
786 |
|
|
if dat_addr(7 downto 4) = "0000" then
|
787 |
|
|
cpu_data_in <= flex_data_out;
|
788 |
|
|
flex_cs <= cpu_vma;
|
789 |
|
|
ram_cs <= '0';
|
790 |
|
|
else
|
791 |
|
|
cpu_data_in <= ram_data_out;
|
792 |
|
|
flex_cs <= '0';
|
793 |
|
|
ram_cs <= cpu_vma;
|
794 |
|
|
end if;
|
795 |
|
|
dat_cs <= '0';
|
796 |
|
|
rom_cs <= '0';
|
797 |
|
|
acia_cs <= '0';
|
798 |
|
|
keyboard_cs <= '0';
|
799 |
|
|
vdu_cs <= '0';
|
800 |
|
|
seg_cs <= '0';
|
801 |
|
|
leds_cs <= '0';
|
802 |
|
|
--
|
803 |
|
|
-- Everything else is RAM
|
804 |
|
|
--
|
805 |
|
|
when others =>
|
806 |
|
|
cpu_data_in <= ram_data_out;
|
807 |
|
|
rom_cs <= '0';
|
808 |
|
|
ram_cs <= cpu_vma;
|
809 |
|
|
dat_cs <= '0';
|
810 |
|
|
acia_cs <= '0';
|
811 |
|
|
keyboard_cs <= '0';
|
812 |
|
|
vdu_cs <= '0';
|
813 |
|
|
seg_cs <= '0';
|
814 |
|
|
leds_cs <= '0';
|
815 |
|
|
flex_cs <= '0';
|
816 |
|
|
end case;
|
817 |
|
|
end if;
|
818 |
|
|
end process;
|
819 |
|
|
|
820 |
|
|
|
821 |
|
|
--
|
822 |
|
|
-- 1M byte SRAM Control
|
823 |
|
|
-- Processes to read and write memory based on bus signals
|
824 |
|
|
--
|
825 |
|
|
ram_process: process( cpu_clk,
|
826 |
|
|
cpu_addr, cpu_rw, cpu_vma, cpu_data_out,
|
827 |
|
|
dat_addr, ram_cs,
|
828 |
|
|
ram1_ce, ram1_ub, ram1_lb, ram1_data,
|
829 |
|
|
ram2_ce, ram2_ub, ram2_lb, ram2_data,
|
830 |
|
|
ram_we, ram_oe )
|
831 |
|
|
begin
|
832 |
|
|
ram_we <= (not cpu_rw) and cpu_clk;
|
833 |
|
|
ram_oe <= cpu_rw and cpu_clk;
|
834 |
|
|
ram_wen <= not ram_we;
|
835 |
|
|
ram_oen <= not ram_oe;
|
836 |
|
|
|
837 |
|
|
ram1_ce <= ram_cs and (not cpu_addr(1));
|
838 |
|
|
ram1_ub <= not cpu_addr(0);
|
839 |
|
|
ram1_lb <= cpu_addr(0);
|
840 |
|
|
ram1_cen <= not ram1_ce;
|
841 |
|
|
ram1_ubn <= not ram1_ub;
|
842 |
|
|
ram1_lbn <= not ram1_lb;
|
843 |
|
|
|
844 |
|
|
ram2_ce <= ram_cs and cpu_addr(1);
|
845 |
|
|
ram2_ub <= not cpu_addr(0);
|
846 |
|
|
ram2_lb <= cpu_addr(0);
|
847 |
|
|
ram2_cen <= not ram2_ce;
|
848 |
|
|
ram2_ubn <= not ram2_ub;
|
849 |
|
|
ram2_lbn <= not ram2_lb;
|
850 |
|
|
|
851 |
|
|
ram_addr(17 downto 10) <= dat_addr(7 downto 0);
|
852 |
|
|
ram_addr(9 downto 0) <= cpu_addr(11 downto 2);
|
853 |
|
|
|
854 |
|
|
if ram_we = '1' and ram1_ce = '1' and ram1_lb = '1' then
|
855 |
|
|
ram1_data(7 downto 0) <= cpu_data_out;
|
856 |
|
|
else
|
857 |
|
|
ram1_data(7 downto 0) <= "ZZZZZZZZ";
|
858 |
|
|
end if;
|
859 |
|
|
|
860 |
|
|
if ram_we = '1' and ram1_ce = '1' and ram1_ub = '1' then
|
861 |
|
|
ram1_data(15 downto 8) <= cpu_data_out;
|
862 |
|
|
else
|
863 |
|
|
ram1_data(15 downto 8) <= "ZZZZZZZZ";
|
864 |
|
|
end if;
|
865 |
|
|
|
866 |
|
|
if ram_we = '1' and ram2_ce = '1' and ram2_lb = '1' then
|
867 |
|
|
ram2_data(7 downto 0) <= cpu_data_out;
|
868 |
|
|
else
|
869 |
|
|
ram2_data(7 downto 0) <= "ZZZZZZZZ";
|
870 |
|
|
end if;
|
871 |
|
|
|
872 |
|
|
if ram_we = '1' and ram2_ce = '1' and ram2_ub = '1' then
|
873 |
|
|
ram2_data(15 downto 8) <= cpu_data_out;
|
874 |
|
|
else
|
875 |
|
|
ram2_data(15 downto 8) <= "ZZZZZZZZ";
|
876 |
|
|
end if;
|
877 |
|
|
|
878 |
|
|
case cpu_addr(1 downto 0) is
|
879 |
|
|
when "00" =>
|
880 |
|
|
ram_data_out <= ram1_data(15 downto 8);
|
881 |
|
|
when "01" =>
|
882 |
|
|
ram_data_out <= ram1_data(7 downto 0);
|
883 |
|
|
when "10" =>
|
884 |
|
|
ram_data_out <= ram2_data(15 downto 8);
|
885 |
|
|
when others =>
|
886 |
|
|
ram_data_out <= ram2_data(7 downto 0);
|
887 |
|
|
end case;
|
888 |
|
|
end process;
|
889 |
|
|
|
890 |
|
|
--
|
891 |
|
|
-- LEDS output register
|
892 |
|
|
--
|
893 |
|
|
leds_output : process( cpu_clk, cpu_reset, switches )
|
894 |
|
|
begin
|
895 |
|
|
if cpu_reset = '1' then
|
896 |
|
|
leds <= "00000000";
|
897 |
|
|
elsif cpu_clk'event and cpu_clk='0' then
|
898 |
|
|
if leds_cs = '1' and cpu_rw = '0' then
|
899 |
|
|
leds <= cpu_data_out;
|
900 |
|
|
end if;
|
901 |
|
|
end if;
|
902 |
|
|
leds_data_out <= switches;
|
903 |
|
|
end process;
|
904 |
|
|
|
905 |
|
|
--
|
906 |
|
|
-- Interrupts and other bus control signals
|
907 |
|
|
--
|
908 |
|
|
interrupts : process( Reset_sw,
|
909 |
|
|
acia_irq,
|
910 |
|
|
keyboard_irq,
|
911 |
|
|
nmi_sw
|
912 |
|
|
)
|
913 |
|
|
begin
|
914 |
|
|
cpu_reset <= Reset_sw; -- CPU reset is active high
|
915 |
|
|
cpu_firq <= keyboard_irq;
|
916 |
|
|
cpu_nmi <= nmi_sw;
|
917 |
|
|
cpu_irq <= acia_irq;
|
918 |
|
|
cpu_halt <= '0';
|
919 |
|
|
cpu_hold <= '0';
|
920 |
|
|
|
921 |
|
|
DCD_n <= '0';
|
922 |
|
|
CTS_n <= '0';
|
923 |
|
|
end process;
|
924 |
|
|
|
925 |
|
|
|
926 |
|
|
end my_computer; --===================== End of architecture =======================--
|
927 |
|
|
|