Line 1... |
Line 1... |
-- $Id: System09_Digilent_3S500E.vhd,v 1.1 2007-12-09 16:06:02 dilbert57 Exp $
|
-- $Id: System09_Digilent_3S500E.vhd,v 1.2 2008-01-08 01:59:09 dilbert57 Exp $
|
--===========================================================================----
|
--===========================================================================----
|
--
|
--
|
-- S Y N T H E Z I A B L E System09 - SOC.
|
-- S Y N T H E Z I A B L E System09 - SOC.
|
--
|
--
|
-- This core adheres to the GNU public license
|
-- This core adheres to the GNU public license
|
Line 65... |
Line 65... |
-- Version 3.0 - 22 April 2006 - John Kent
|
-- Version 3.0 - 22 April 2006 - John Kent
|
-- Port to Digilent Spartan 3E Starter board
|
-- Port to Digilent Spartan 3E Starter board
|
-- Removed keyboard, vdu, timer, and trap logic
|
-- Removed keyboard, vdu, timer, and trap logic
|
-- added PIA with counters attached.
|
-- added PIA with counters attached.
|
-- Uses 32Kbytes of internal Block RAM
|
-- Uses 32Kbytes of internal Block RAM
|
|
--
|
|
-- Version 4.0 - 8th April 2007 - John kent
|
|
-- Added VDU and PS/2 keyboard
|
|
-- Updated miniUART to ACIA6850
|
|
-- Reduce monitor ROM to 2KB
|
|
-- Re-assigned I/O port assignments so it is possible to run KBUG9
|
|
-- $E000 - ACIA
|
|
-- $E020 - Keyboard
|
|
-- $E030 - VDU
|
|
-- $E040 - Compact Flash (not implemented)
|
|
-- $E050 - Timer
|
|
-- $E060 - Bus trap
|
|
-- $E070 - Parallel I/O
|
|
--
|
--===========================================================================--
|
--===========================================================================--
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
Line 77... |
Line 91... |
entity My_System09 is
|
entity My_System09 is
|
port(
|
port(
|
CLK_50MHZ : in Std_Logic; -- System Clock input
|
CLK_50MHZ : in Std_Logic; -- System Clock input
|
BTN_SOUTH : in Std_Logic;
|
BTN_SOUTH : in Std_Logic;
|
|
|
|
-- PS/2 Keyboard
|
|
PS2_CLK : inout Std_logic;
|
|
PS2_DATA : inout Std_Logic;
|
|
|
|
-- CRTC output signals
|
|
VGA_VSYNC : out Std_Logic;
|
|
VGA_HSYNC : out Std_Logic;
|
|
VGA_BLUE : out std_logic;
|
|
VGA_GREEN : out std_logic;
|
|
VGA_RED : out std_logic;
|
|
|
-- Uart Interface
|
-- Uart Interface
|
RS232_DCE_RXD : in std_logic;
|
RS232_DCE_RXD : in std_logic;
|
RS232_DCE_TXD : out std_logic;
|
RS232_DCE_TXD : out std_logic;
|
|
|
-- LEDS & Switches
|
-- LEDS & Switches
|
Line 91... |
Line 116... |
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Architecture for System09
|
-- Architecture for System09
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
architecture my_computer of My_System09 is
|
architecture my_computer of My_System09 is
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
|
-- constants
|
|
-----------------------------------------------------------------------------
|
|
constant SYS_Clock_Frequency : integer := 50000000; -- FPGA System Clock
|
|
constant PIX_Clock_Frequency : integer := 25000000; -- VGA Pixel Clock
|
|
constant CPU_Clock_Frequency : integer := 25000000; -- CPU Clock
|
|
constant BAUD_Rate : integer := 57600; -- Baud Rate
|
|
constant ACIA_Clock_Frequency : integer := BAUD_Rate * 16;
|
|
|
|
-----------------------------------------------------------------------------
|
-- Signals
|
-- Signals
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
-- BOOT ROM
|
-- BOOT ROM
|
signal rom_cs : Std_logic;
|
signal rom_cs : Std_logic;
|
signal rom_data_out : Std_Logic_Vector(7 downto 0);
|
signal rom_data_out : Std_Logic_Vector(7 downto 0);
|
|
|
-- UART Interface signals
|
-- UART Interface signals
|
signal uart_data_out : Std_Logic_Vector(7 downto 0);
|
signal uart_data_out : Std_Logic_Vector(7 downto 0);
|
signal uart_cs : Std_Logic;
|
signal uart_cs : Std_Logic;
|
signal uart_irq : Std_Logic;
|
signal uart_irq : Std_Logic;
|
signal baudclk : Std_Logic;
|
signal uart_clk : Std_Logic;
|
|
signal rxbit : Std_Logic;
|
|
signal txbit : Std_Logic;
|
signal DCD_n : Std_Logic;
|
signal DCD_n : Std_Logic;
|
signal RTS_n : Std_Logic;
|
signal RTS_n : Std_Logic;
|
signal CTS_n : Std_Logic;
|
signal CTS_n : Std_Logic;
|
|
|
|
-- timer
|
|
signal timer_data_out : std_logic_vector(7 downto 0);
|
|
signal timer_cs : std_logic;
|
|
signal timer_irq : std_logic;
|
|
|
|
-- trap
|
|
signal trap_cs : std_logic;
|
|
signal trap_data_out : std_logic_vector(7 downto 0);
|
|
signal trap_irq : std_logic;
|
|
|
-- PIA Interface signals
|
-- PIA Interface signals
|
signal pia_data_out : Std_Logic_Vector(7 downto 0);
|
signal pia_data_out : Std_Logic_Vector(7 downto 0);
|
signal pia_cs : Std_Logic;
|
signal pia_cs : Std_Logic;
|
signal pia_irq_a : Std_Logic;
|
signal pia_irq_a : Std_Logic;
|
signal pia_irq_b : Std_Logic;
|
signal pia_irq_b : Std_Logic;
|
|
|
|
-- keyboard port
|
|
signal keyboard_data_out : std_logic_vector(7 downto 0);
|
|
signal keyboard_cs : std_logic;
|
|
signal keyboard_irq : std_logic;
|
|
|
|
-- Video Display Unit
|
|
signal pix_clk : std_logic;
|
|
signal vdu_cs : std_logic;
|
|
signal vdu_data_out : std_logic_vector(7 downto 0);
|
|
|
-- RAM
|
-- RAM
|
signal ram_cs : std_logic; -- memory chip select
|
signal ram_cs : std_logic; -- memory chip select
|
signal ram_data_out : std_logic_vector(7 downto 0);
|
signal ram_data_out : std_logic_vector(7 downto 0);
|
|
|
-- CPU Interface signals
|
-- CPU Interface signals
|
Line 130... |
Line 186... |
signal cpu_nmi : std_logic;
|
signal cpu_nmi : std_logic;
|
signal cpu_addr : std_logic_vector(15 downto 0);
|
signal cpu_addr : std_logic_vector(15 downto 0);
|
signal cpu_data_in : std_logic_vector(7 downto 0);
|
signal cpu_data_in : std_logic_vector(7 downto 0);
|
signal cpu_data_out : std_logic_vector(7 downto 0);
|
signal cpu_data_out : std_logic_vector(7 downto 0);
|
|
|
signal BaudCount : std_logic_vector(6 downto 0);
|
-- CLK_50MHZ clock divide by 2
|
|
signal clock_div : std_logic_vector(1 downto 0);
|
|
signal SysClk : std_logic;
|
|
signal Reset_n : std_logic;
|
signal CountL : std_logic_vector(23 downto 0);
|
signal CountL : std_logic_vector(23 downto 0);
|
-- CLK_50MHZ clock divide by 4
|
|
signal prescale : std_logic_vector(1 downto 0);
|
|
|
|
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
--
|
--
|
-- CPU09 CPU core
|
-- CPU09 CPU core
|
--
|
--
|
Line 164... |
Line 221... |
----------------------------------------
|
----------------------------------------
|
--
|
--
|
-- Block RAM Monitor ROM
|
-- Block RAM Monitor ROM
|
--
|
--
|
----------------------------------------
|
----------------------------------------
|
component rom_8k
|
component mon_rom
|
Port (
|
Port (
|
clk : in std_logic;
|
clk : in std_logic;
|
rst : in std_logic;
|
rst : in std_logic;
|
cs : in std_logic;
|
cs : in std_logic;
|
rw : in std_logic;
|
rw : in std_logic;
|
addr : in std_logic_vector (12 downto 0);
|
addr : in std_logic_vector (10 downto 0);
|
rdata : out std_logic_vector (7 downto 0);
|
rdata : out std_logic_vector (7 downto 0);
|
wdata : in std_logic_vector (7 downto 0)
|
wdata : in std_logic_vector (7 downto 0)
|
);
|
);
|
end component;
|
end component;
|
|
|
Line 213... |
Line 270... |
irqa : out std_logic;
|
irqa : out std_logic;
|
irqb : out std_logic
|
irqb : out std_logic
|
);
|
);
|
end component;
|
end component;
|
|
|
|
|
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
--
|
--
|
-- 6850 compatible UART (ACIA)
|
-- 6850 ACIA/UART
|
--
|
--
|
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
|
|
component miniUART
|
component ACIA_6850
|
port (
|
port (
|
clk : in Std_Logic; -- System Clock
|
clk : in Std_Logic; -- System Clock
|
rst : in Std_Logic; -- Reset input (active high)
|
rst : in Std_Logic; -- Reset input (active high)
|
cs : in Std_Logic; -- miniUART Chip Select
|
cs : in Std_Logic; -- miniUART Chip Select
|
rw : in Std_Logic; -- Read / Not Write
|
rw : in Std_Logic; -- Read / Not Write
|
Line 238... |
Line 296... |
DCD_n : in Std_Logic; -- Data Carrier Detect
|
DCD_n : in Std_Logic; -- Data Carrier Detect
|
CTS_n : in Std_Logic; -- Clear To Send
|
CTS_n : in Std_Logic; -- Clear To Send
|
RTS_n : out Std_Logic ); -- Request To send
|
RTS_n : out Std_Logic ); -- Request To send
|
end component;
|
end component;
|
|
|
|
-----------------------------------------------------------------
|
|
--
|
|
-- ACIA Clock divider
|
|
--
|
|
-----------------------------------------------------------------
|
|
|
|
component ACIA_Clock
|
|
generic (
|
|
SYS_Clock_Frequency : integer := SYS_Clock_Frequency;
|
|
ACIA_Clock_Frequency : integer := ACIA_Clock_Frequency
|
|
);
|
|
port (
|
|
clk : in Std_Logic; -- System Clock Input
|
|
ACIA_clk : out Std_logic -- ACIA Clock output
|
|
);
|
|
end component;
|
|
|
|
----------------------------------------
|
|
--
|
|
-- Timer module
|
|
--
|
|
----------------------------------------
|
|
|
|
component timer
|
|
port (
|
|
clk : in std_logic;
|
|
rst : in std_logic;
|
|
cs : in std_logic;
|
|
rw : in std_logic;
|
|
addr : in std_logic;
|
|
data_in : in std_logic_vector(7 downto 0);
|
|
data_out : out std_logic_vector(7 downto 0);
|
|
irq : out std_logic;
|
|
timer_in : in std_logic;
|
|
timer_out : out std_logic
|
|
);
|
|
end component;
|
|
|
|
------------------------------------------------------------
|
|
--
|
|
-- Bus Trap logic
|
|
--
|
|
------------------------------------------------------------
|
|
|
|
component trap
|
|
port (
|
|
clk : in std_logic;
|
|
rst : in std_logic;
|
|
cs : in std_logic;
|
|
rw : in std_logic;
|
|
vma : in std_logic;
|
|
addr : in std_logic_vector(15 downto 0);
|
|
data_in : in std_logic_vector(7 downto 0);
|
|
data_out : out std_logic_vector(7 downto 0);
|
|
irq : out std_logic
|
|
);
|
|
end component;
|
|
|
|
----------------------------------------
|
|
--
|
|
-- PS/2 Keyboard
|
|
--
|
|
----------------------------------------
|
|
|
|
component keyboard
|
|
generic(
|
|
KBD_Clock_Frequency : integer := CPU_Clock_Frequency
|
|
);
|
|
port(
|
|
clk : in std_logic;
|
|
rst : in std_logic;
|
|
cs : in std_logic;
|
|
rw : in std_logic;
|
|
addr : in std_logic;
|
|
data_in : in std_logic_vector(7 downto 0);
|
|
data_out : out std_logic_vector(7 downto 0);
|
|
irq : out std_logic;
|
|
kbd_clk : inout std_logic;
|
|
kbd_data : inout std_logic
|
|
);
|
|
end component;
|
|
|
|
----------------------------------------
|
|
--
|
|
-- Video Display Unit.
|
|
--
|
|
----------------------------------------
|
|
component vdu8
|
|
generic(
|
|
VDU_CLOCK_FREQUENCY : integer := CPU_Clock_Frequency; -- HZ
|
|
VGA_CLOCK_FREQUENCY : integer := PIX_Clock_Frequency; -- HZ
|
|
VGA_HOR_CHARS : integer := 80; -- CHARACTERS
|
|
VGA_VER_CHARS : integer := 25; -- CHARACTERS
|
|
VGA_PIXELS_PER_CHAR : integer := 8; -- PIXELS
|
|
VGA_LINES_PER_CHAR : integer := 16; -- LINES
|
|
VGA_HOR_BACK_PORCH : integer := 40; -- PIXELS
|
|
VGA_HOR_SYNC : integer := 96; -- PIXELS
|
|
VGA_HOR_FRONT_PORCH : integer := 24; -- PIXELS
|
|
VGA_VER_BACK_PORCH : integer := 13; -- LINES
|
|
VGA_VER_SYNC : integer := 1; -- LINES
|
|
VGA_VER_FRONT_PORCH : integer := 36 -- LINES
|
|
);
|
|
port(
|
|
-- control register interface
|
|
vdu_clk : in std_logic; -- CPU Clock - 12.5MHz
|
|
vdu_rst : in std_logic;
|
|
vdu_cs : in std_logic;
|
|
vdu_rw : in std_logic;
|
|
vdu_addr : in std_logic_vector(2 downto 0);
|
|
vdu_data_in : in std_logic_vector(7 downto 0);
|
|
vdu_data_out : out std_logic_vector(7 downto 0);
|
|
|
|
-- vga port connections
|
|
vga_clk : in std_logic; -- VGA Pixel Clock - 25 MHz
|
|
vga_red_o : out std_logic;
|
|
vga_green_o : out std_logic;
|
|
vga_blue_o : out std_logic;
|
|
vga_hsync_o : out std_logic;
|
|
vga_vsync_o : out std_logic
|
|
);
|
|
end component;
|
|
|
|
|
component BUFG
|
component BUFG
|
port (
|
port (
|
i: in std_logic;
|
i: in std_logic;
|
o: out std_logic
|
o: out std_logic
|
Line 266... |
Line 446... |
irq => cpu_irq,
|
irq => cpu_irq,
|
nmi => cpu_nmi,
|
nmi => cpu_nmi,
|
firq => cpu_firq
|
firq => cpu_firq
|
);
|
);
|
|
|
my_rom : rom_8k port map (
|
my_rom : mon_rom port map (
|
clk => cpu_clk,
|
clk => cpu_clk,
|
rst => cpu_reset,
|
rst => cpu_reset,
|
cs => rom_cs,
|
cs => rom_cs,
|
rw => '1',
|
rw => '1',
|
addr => cpu_addr(12 downto 0),
|
addr => cpu_addr(10 downto 0),
|
rdata => rom_data_out,
|
rdata => rom_data_out,
|
wdata => cpu_data_out
|
wdata => cpu_data_out
|
);
|
);
|
|
|
my_ram : ram_32k port map (
|
my_ram : ram_32k port map (
|
Line 298... |
Line 478... |
data_out => pia_data_out,
|
data_out => pia_data_out,
|
irqa => pia_irq_a,
|
irqa => pia_irq_a,
|
irqb => pia_irq_b
|
irqb => pia_irq_b
|
);
|
);
|
|
|
my_uart : miniUART port map (
|
|
|
----------------------------------------
|
|
--
|
|
-- ACIA/UART Serial interface
|
|
--
|
|
----------------------------------------
|
|
my_ACIA : ACIA_6850 port map (
|
clk => cpu_clk,
|
clk => cpu_clk,
|
rst => cpu_reset,
|
rst => cpu_reset,
|
cs => uart_cs,
|
cs => uart_cs,
|
rw => cpu_rw,
|
rw => cpu_rw,
|
irq => uart_irq,
|
irq => uart_irq,
|
Addr => cpu_addr(0),
|
Addr => cpu_addr(0),
|
Datain => cpu_data_out,
|
Datain => cpu_data_out,
|
DataOut => uart_data_out,
|
DataOut => uart_data_out,
|
RxC => baudclk,
|
RxC => uart_clk,
|
TxC => baudclk,
|
TxC => uart_clk,
|
RxD => RS232_DCE_RXD,
|
RxD => rxbit,
|
TxD => RS232_DCE_TXD,
|
TxD => txbit,
|
DCD_n => dcd_n,
|
DCD_n => dcd_n,
|
CTS_n => cts_n,
|
CTS_n => cts_n,
|
RTS_n => rts_n
|
RTS_n => rts_n
|
);
|
);
|
|
|
|
----------------------------------------
|
|
--
|
|
-- ACIA Clock
|
|
--
|
|
----------------------------------------
|
|
my_ACIA_Clock : ACIA_Clock
|
|
generic map(
|
|
SYS_Clock_Frequency => SYS_Clock_Frequency,
|
|
ACIA_Clock_Frequency => ACIA_Clock_Frequency
|
|
)
|
|
port map(
|
|
clk => SysClk,
|
|
acia_clk => uart_clk
|
|
);
|
|
|
|
|
|
|
|
----------------------------------------
|
|
--
|
|
-- PS/2 Keyboard Interface
|
|
--
|
|
----------------------------------------
|
|
my_keyboard : keyboard
|
|
generic map (
|
|
KBD_Clock_Frequency => CPU_Clock_frequency
|
|
)
|
|
port map(
|
|
clk => cpu_clk,
|
|
rst => cpu_reset,
|
|
cs => keyboard_cs,
|
|
rw => cpu_rw,
|
|
addr => cpu_addr(0),
|
|
data_in => cpu_data_out(7 downto 0),
|
|
data_out => keyboard_data_out(7 downto 0),
|
|
irq => keyboard_irq,
|
|
kbd_clk => PS2_CLK,
|
|
kbd_data => PS2_DATA
|
|
);
|
|
|
|
----------------------------------------
|
|
--
|
|
-- Video Display Unit instantiation
|
|
--
|
|
----------------------------------------
|
|
my_vdu : vdu8
|
|
generic map(
|
|
VDU_CLOCK_FREQUENCY => CPU_Clock_Frequency, -- HZ
|
|
VGA_CLOCK_FREQUENCY => PIX_Clock_Frequency, -- HZ
|
|
VGA_HOR_CHARS => 80, -- CHARACTERS
|
|
VGA_VER_CHARS => 25, -- CHARACTERS
|
|
VGA_PIXELS_PER_CHAR => 8, -- PIXELS
|
|
VGA_LINES_PER_CHAR => 16, -- LINES
|
|
VGA_HOR_BACK_PORCH => 40, -- PIXELS
|
|
VGA_HOR_SYNC => 96, -- PIXELS
|
|
VGA_HOR_FRONT_PORCH => 24, -- PIXELS
|
|
VGA_VER_BACK_PORCH => 13, -- LINES
|
|
VGA_VER_SYNC => 1, -- LINES
|
|
VGA_VER_FRONT_PORCH => 36 -- LINES
|
|
)
|
|
port map(
|
|
|
|
-- Control Registers
|
|
vdu_clk => cpu_clk, -- 25 MHz System Clock in
|
|
vdu_rst => cpu_reset,
|
|
vdu_cs => vdu_cs,
|
|
vdu_rw => cpu_rw,
|
|
vdu_addr => cpu_addr(2 downto 0),
|
|
vdu_data_in => cpu_data_out,
|
|
vdu_data_out => vdu_data_out,
|
|
|
|
-- vga port connections
|
|
vga_clk => pix_clk, -- 25 MHz VDU pixel clock
|
|
vga_red_o => vga_red,
|
|
vga_green_o => vga_green,
|
|
vga_blue_o => vga_blue,
|
|
vga_hsync_o => vga_hsync,
|
|
vga_vsync_o => vga_vsync
|
|
);
|
|
|
|
|
|
----------------------------------------
|
|
--
|
|
-- Timer Module
|
|
--
|
|
----------------------------------------
|
|
my_timer : timer port map (
|
|
clk => cpu_clk,
|
|
rst => cpu_reset,
|
|
cs => timer_cs,
|
|
rw => cpu_rw,
|
|
addr => cpu_addr(0),
|
|
data_in => cpu_data_out,
|
|
data_out => timer_data_out,
|
|
irq => timer_irq,
|
|
timer_in => CountL(5)
|
|
-- timer_out => timer_out
|
|
);
|
|
|
|
----------------------------------------
|
|
--
|
|
-- Bus Trap Interrupt logic
|
|
--
|
|
----------------------------------------
|
|
my_trap : trap port map (
|
|
clk => cpu_clk,
|
|
rst => cpu_reset,
|
|
cs => trap_cs,
|
|
rw => cpu_rw,
|
|
vma => cpu_vma,
|
|
addr => cpu_addr,
|
|
data_in => cpu_data_out,
|
|
data_out => trap_data_out,
|
|
irq => trap_irq
|
|
);
|
|
|
clk_buffer : BUFG port map(
|
--
|
i => prescale(1),
|
-- 25 MHz CPU clock
|
|
--
|
|
cpu_clk_buffer : BUFG port map(
|
|
i => clock_div(0),
|
o => cpu_clk
|
o => cpu_clk
|
);
|
);
|
|
|
|
--
|
|
-- 25 MHz VGA Pixel clock
|
|
--
|
|
vga_clk_buffer : BUFG port map(
|
|
i => clock_div(0),
|
|
o => pix_clk
|
|
);
|
|
|
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
--
|
--
|
-- Process to decode memory map
|
-- Process to decode memory map
|
--
|
--
|
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
|
|
mem_decode: process( cpu_clk, BTN_SOUTH,
|
mem_decode: process( cpu_clk, Reset_n,
|
cpu_addr, cpu_rw, cpu_vma,
|
cpu_addr, cpu_rw, cpu_vma,
|
rom_data_out,
|
rom_data_out,
|
ram_data_out,
|
ram_data_out,
|
|
timer_data_out,
|
|
trap_data_out,
|
|
pia_data_out,
|
uart_data_out,
|
uart_data_out,
|
pia_data_out )
|
keyboard_data_out,
|
|
vdu_data_out )
|
|
variable decode_addr : std_logic_vector(3 downto 0);
|
begin
|
begin
|
case cpu_addr(15 downto 14) is
|
-- decode_addr := dat_addr(3 downto 0) & cpu_addr(11);
|
|
decode_addr := cpu_addr(15 downto 12);
|
|
|
|
case decode_addr is
|
--
|
--
|
-- Monitor ROM $C000 - $FFFF
|
-- SBUG/KBUG/SYS09BUG Monitor ROM $F800 - $FFFF
|
--
|
--
|
when "11" => -- $C000 - $FFFF
|
when "1111" => -- $F000 - $FFFF
|
cpu_data_in <= rom_data_out;
|
cpu_data_in <= rom_data_out;
|
rom_cs <= cpu_vma;
|
rom_cs <= cpu_vma; -- read ROM
|
ram_cs <= '0';
|
ram_cs <= '0';
|
uart_cs <= '0';
|
uart_cs <= '0';
|
|
timer_cs <= '0';
|
|
trap_cs <= '0';
|
pia_cs <= '0';
|
pia_cs <= '0';
|
|
keyboard_cs <= '0';
|
|
vdu_cs <= '0';
|
|
|
--
|
--
|
-- IO Devices $8000 - $BFFF
|
-- IO Devices $E000 - $EFFF
|
--
|
--
|
when "10" => -- $8000 - $BFFF
|
when "1110" => -- $E000 - $E7FF
|
rom_cs <= '0';
|
rom_cs <= '0';
|
ram_cs <= '0';
|
ram_cs <= '0';
|
case cpu_addr(3 downto 2) is
|
case cpu_addr(7 downto 4) is
|
--
|
--
|
-- PIA TIMER $8004
|
-- UART / ACIA $E000
|
--
|
--
|
when "01" => -- $8004
|
when "0000" => -- $E000
|
cpu_data_in <= pia_data_out;
|
cpu_data_in <= uart_data_out;
|
|
uart_cs <= cpu_vma;
|
|
timer_cs <= '0';
|
|
trap_cs <= '0';
|
|
pia_cs <= '0';
|
|
keyboard_cs <= '0';
|
|
vdu_cs <= '0';
|
|
|
|
--
|
|
-- WD1771 FDC sites at $E010-$E01F
|
|
--
|
|
when "0001" => -- $E010
|
|
cpu_data_in <= (others => '0');
|
uart_cs <= '0';
|
uart_cs <= '0';
|
pia_cs <= cpu_vma;
|
timer_cs <= '0';
|
|
trap_cs <= '0';
|
|
pia_cs <= '0';
|
|
keyboard_cs <= '0';
|
|
vdu_cs <= '0';
|
|
|
--
|
--
|
-- UART / ACIA $8008
|
-- Keyboard port $E020 - $E02F
|
--
|
--
|
when "10" => -- $8008
|
when "0010" => -- $E020
|
cpu_data_in <= uart_data_out;
|
cpu_data_in <= keyboard_data_out;
|
uart_cs <= cpu_vma;
|
uart_cs <= '0';
|
|
timer_cs <= '0';
|
|
trap_cs <= '0';
|
pia_cs <= '0';
|
pia_cs <= '0';
|
|
keyboard_cs <= cpu_vma;
|
|
vdu_cs <= '0';
|
|
|
when others =>
|
--
|
cpu_data_in <= "11111111";
|
-- VDU port $E030 - $E03F
|
|
--
|
|
when "0011" => -- $E030
|
|
cpu_data_in <= vdu_data_out;
|
|
uart_cs <= '0';
|
|
timer_cs <= '0';
|
|
trap_cs <= '0';
|
|
pia_cs <= '0';
|
|
keyboard_cs <= '0';
|
|
vdu_cs <= cpu_vma;
|
|
|
|
--
|
|
-- Compact Flash $E040 - $E04F
|
|
--
|
|
when "0100" => -- $E040
|
|
cpu_data_in <= (others => '0');
|
|
uart_cs <= '0';
|
|
timer_cs <= '0';
|
|
trap_cs <= '0';
|
|
pia_cs <= '0';
|
|
keyboard_cs <= '0';
|
|
vdu_cs <= '0';
|
|
|
|
--
|
|
-- Timer $E050 - $E05F
|
|
--
|
|
when "0101" => -- $E050
|
|
cpu_data_in <= timer_data_out;
|
|
uart_cs <= '0';
|
|
timer_cs <= cpu_vma;
|
|
trap_cs <= '0';
|
|
pia_cs <= '0';
|
|
keyboard_cs <= '0';
|
|
vdu_cs <= '0';
|
|
|
|
--
|
|
-- Bus Trap Logic $E060 - $E06F
|
|
--
|
|
when "0110" => -- $E060
|
|
cpu_data_in <= trap_data_out;
|
|
uart_cs <= '0';
|
|
timer_cs <= '0';
|
|
trap_cs <= cpu_vma;
|
|
pia_cs <= '0';
|
|
keyboard_cs <= '0';
|
|
vdu_cs <= '0';
|
|
|
|
--
|
|
-- I/O port $E070 - $E07F
|
|
--
|
|
when "0111" => -- $E070
|
|
cpu_data_in <= pia_data_out;
|
|
uart_cs <= '0';
|
|
timer_cs <= '0';
|
|
trap_cs <= '0';
|
|
pia_cs <= cpu_vma;
|
|
keyboard_cs <= '0';
|
|
vdu_cs <= '0';
|
|
|
|
when others => -- $E080 to $E7FF
|
|
cpu_data_in <= (others => '0');
|
uart_cs <= '0';
|
uart_cs <= '0';
|
|
timer_cs <= '0';
|
|
trap_cs <= '0';
|
pia_cs <= '0';
|
pia_cs <= '0';
|
|
keyboard_cs <= '0';
|
|
vdu_cs <= '0';
|
end case;
|
end case;
|
|
|
|
--
|
|
-- $8000 to $DFFF = null
|
|
--
|
|
when "1101" | "1100" | "1011" | "1010" |
|
|
"1001" | "1000" =>
|
|
cpu_data_in <= (others => '0');
|
|
rom_cs <= '0';
|
|
ram_cs <= '0';
|
|
uart_cs <= '0';
|
|
timer_cs <= '0';
|
|
trap_cs <= '0';
|
|
pia_cs <= '0';
|
|
keyboard_cs <= '0';
|
|
vdu_cs <= '0';
|
--
|
--
|
-- Everything else is RAM
|
-- Everything else is RAM
|
--
|
--
|
when others =>
|
when others =>
|
cpu_data_in <= ram_data_out;
|
cpu_data_in <= ram_data_out;
|
rom_cs <= '0';
|
rom_cs <= '0';
|
ram_cs <= cpu_vma;
|
ram_cs <= cpu_vma;
|
uart_cs <= '0';
|
uart_cs <= '0';
|
|
timer_cs <= '0';
|
|
trap_cs <= '0';
|
pia_cs <= '0';
|
pia_cs <= '0';
|
|
keyboard_cs <= '0';
|
|
vdu_cs <= '0';
|
end case;
|
end case;
|
end process;
|
end process;
|
|
|
--
|
--
|
-- Interrupts and other bus control signals
|
-- Interrupts and other bus control signals
|
--
|
--
|
interrupts : process( BTN_SOUTH, uart_irq,
|
interrupts : process( Reset_n,
|
pia_irq_a, pia_irq_b
|
pia_irq_a, pia_irq_b, uart_irq, trap_irq, timer_irq, keyboard_irq
|
)
|
)
|
begin
|
begin
|
cpu_reset <= BTN_SOUTH; -- CPU reset is active high
|
cpu_reset <= not Reset_n; -- CPU reset is active high
|
cpu_irq <= uart_irq;
|
cpu_irq <= uart_irq or keyboard_irq;
|
cpu_nmi <= pia_irq_a;
|
cpu_nmi <= pia_irq_a or trap_irq;
|
cpu_firq <= pia_irq_b;
|
cpu_firq <= pia_irq_b or timer_irq;
|
cpu_halt <= '0';
|
cpu_halt <= '0';
|
cpu_hold <= '0';
|
cpu_hold <= '0';
|
end process;
|
end process;
|
|
|
my_cpu_clock: process( CLK_50MHZ, prescale )
|
|
begin
|
|
if(CLK_50MHZ'event and CLK_50MHZ = '0') then
|
|
prescale <= prescale + "01";
|
|
end if;
|
|
end process;
|
|
|
|
--
|
--
|
-- Baud rate clock
|
|
-- 50 MHz / 81.38 = ~614.4 KHz (38400 * 16)
|
|
--
|
--
|
my_baud: process( CLK_50MHZ )
|
my_led_flasher: process( SysClk, Reset_n, CountL )
|
begin
|
begin
|
if(CLK_50MHZ'event and CLK_50MHZ = '0') then
|
if Reset_n = '0' then
|
if( BaudCount = 81 ) then
|
CountL <= "000000000000000000000000";
|
BaudCount <= "0000000";
|
elsif(SysClk'event and SysClk = '0') then
|
baudclk <= '0';
|
CountL <= CountL + 1;
|
else
|
|
BaudCount <= BaudCount + 1;
|
|
if BaudCount = 40 then
|
|
baudclk <= '1';
|
|
else
|
|
baudclk <= baudclk;
|
|
end if;
|
|
end if;
|
|
end if;
|
end if;
|
|
LED(7 downto 0) <= CountL(23 downto 16);
|
end process;
|
end process;
|
|
|
--
|
--
|
|
-- Clock divider
|
--
|
--
|
my_led_flasher: process( CLK_50MHZ, BTN_SOUTH, CountL )
|
my_clock_divider: process( SysClk )
|
begin
|
begin
|
if BTN_SOUTH = '1' then
|
if SysClk'event and SysClk='0' then
|
CountL <= "000000000000000000000000";
|
clock_div <= clock_div + "01";
|
elsif(CLK_50MHZ'event and CLK_50MHZ = '0') then
|
|
CountL <= CountL + 1;
|
|
end if;
|
end if;
|
LED(7 downto 0) <= CountL(23 downto 16);
|
|
end process;
|
end process;
|
|
|
DCD_n <= '0';
|
DCD_n <= '0';
|
CTS_n <= '0';
|
CTS_n <= '0';
|
|
Reset_n <= not BTN_SOUTH; -- CPU reset is active high
|
|
SysClk <= CLK_50MHZ;
|
|
rxbit <= RS232_DCE_RXD;
|
|
RS232_DCE_TXD <= txbit;
|
|
|
end my_computer; --===================== End of architecture =======================--
|
end my_computer; --===================== End of architecture =======================--
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|