Line 127... |
Line 127... |
use unisim.vcomponents.all;
|
use unisim.vcomponents.all;
|
|
|
entity system09 is
|
entity system09 is
|
port(
|
port(
|
CLKA : in Std_Logic; -- 100MHz Clock input
|
CLKA : in Std_Logic; -- 100MHz Clock input
|
--SW2_N : in Std_logic; -- Master Reset input (active low)
|
RESET_N : in Std_logic; -- Master Reset input (active low)
|
--SW3_N : in Std_logic; -- Non Maskable Interrupt input (active low)
|
NMI_N : in Std_logic; -- Non Maskable Interrupt input (active low)
|
|
|
-- RS232 Port
|
-- RS232 Port
|
RS232_RXD : in Std_Logic;
|
--RS232_CTS : in std_logic;
|
RS232_TXD : out Std_Logic;
|
--RS232_RTS : out std_logic;
|
|
RS232_RXD : in Std_Logic; -- RS-232 data in
|
-- Status 7 segment LED
|
RS232_TXD : out Std_Logic -- RS-232 data out
|
sw : in std_logic_vector(7 downto 0);
|
|
btn : in std_logic_vector(4 downto 0);
|
|
S : out std_logic_vector(7 downto 0)
|
|
|
|
|
|
-- CPU Debug Interface signals
|
-- CPU Debug Interface signals
|
-- cpu_reset_o : out Std_Logic;
|
-- cpu_reset_o : out Std_Logic;
|
-- cpu_clk_o : out Std_Logic;
|
-- cpu_clk_o : out Std_Logic;
|
-- cpu_rw_o : out std_logic;
|
-- cpu_rw_o : out std_logic;
|
Line 165... |
Line 161... |
architecture rtl of system09 is
|
architecture rtl of system09 is
|
|
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
-- constants
|
-- constants
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
|
constant SYS_CLK_FREQ : natural := 100_000_000; -- FPGA System Clock (in Hz)
|
constant MEM_CLK_FREQ : natural := 100_000; -- operating frequency of Memory in KHz
|
constant CPU_CLK_FREQ : natural := 25_000_000; -- CPU Clock (Hz)
|
constant SYS_CLK_DIV : real := 2.0; -- divisor for FREQ (can only be 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 8.0 or 16.0)
|
|
|
|
constant SYS_CLK_FREQ : natural := ((MEM_CLK_FREQ*2)/integer(SYS_CLK_DIV*2.0))*1000; -- FPGA System Clock (in Hz)
|
|
constant CPU_CLK_FREQ : natural := 1; --25_000_000; -- CPU Clock (Hz)
|
|
constant CPU_CLK_DIV : natural := (SYS_CLK_FREQ/CPU_CLK_FREQ);
|
constant CPU_CLK_DIV : natural := (SYS_CLK_FREQ/CPU_CLK_FREQ);
|
constant BAUD_RATE : integer := 57600; -- Baud Rate
|
constant BAUD_RATE : integer := 57600; -- Baud Rate
|
constant ACIA_CLK_FREQ : integer := BAUD_RATE * 16;
|
constant ACIA_CLK_FREQ : integer := BAUD_RATE * 16;
|
|
|
constant TRESET : natural := 300; -- min initialization interval (us)
|
|
constant RST_CYCLES : natural := 1+(TRESET*(MEM_CLK_FREQ/1_000)); -- SDRAM power-on initialization interval
|
|
|
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
-- Signals
|
-- Signals
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
signal pbtn : std_logic_vector(4 downto 0);
|
|
signal SW3_N : std_logic;
|
|
signal SW2_N : std_logic;
|
|
-- 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);
|
|
|
-- Flex Memory & Monitor Stack
|
-- Flex Memory & Monitor Stack
|
Line 244... |
Line 231... |
signal clk_i : std_logic; -- internal master clock signal
|
signal clk_i : std_logic; -- internal master clock signal
|
|
|
signal rs232_cts : Std_Logic;
|
signal rs232_cts : Std_Logic;
|
signal rs232_rts : Std_Logic;
|
signal rs232_rts : Std_Logic;
|
|
|
signal CountL : std_logic_vector(23 downto 0);
|
|
signal clk_count : natural range 0 to CPU_CLK_DIV;
|
signal clk_count : natural range 0 to CPU_CLK_DIV;
|
signal Clk25 : std_logic;
|
signal Clk25 : std_logic;
|
|
|
|
|
component btn_debounce
|
|
Port ( BTN_I : in STD_LOGIC_VECTOR (4 downto 0);
|
|
CLK : in STD_LOGIC;
|
|
BTN_O : out STD_LOGIC_VECTOR (4 downto 0));
|
|
end component;
|
|
|
|
|
|
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
--
|
--
|
-- CPU09 CPU core
|
-- CPU09 CPU core
|
--
|
--
|
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
Line 457... |
Line 435... |
data_in : in std_logic_vector(7 downto 0);
|
data_in : in std_logic_vector(7 downto 0);
|
data_out : out std_logic_vector(7 downto 0)
|
data_out : out std_logic_vector(7 downto 0)
|
);
|
);
|
end component;
|
end component;
|
|
|
|
----------------------------------------
|
--
|
--
|
-- Clock buffer
|
-- Clock buffer
|
--
|
--
|
|
----------------------------------------
|
|
|
component BUFG
|
component BUFG
|
Port (
|
Port (
|
i: in std_logic;
|
i: in std_logic;
|
o: out std_logic
|
o: out std_logic
|
);
|
);
|
end component;
|
end component;
|
|
|
begin
|
begin
|
|
|
|
|
|
|
|
|
|
|
clk_i <= CLKA;
|
clk_i <= CLKA;
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
-- Instantiation of internal components
|
-- Instantiation of internal components
|
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
|
|
Line 758... |
Line 733... |
end process;
|
end process;
|
|
|
--
|
--
|
-- Interrupts and other bus control signals
|
-- Interrupts and other bus control signals
|
--
|
--
|
interrupts : process( SW3_N,
|
interrupts : process( NMI_N,
|
acia_irq,
|
acia_irq,
|
trap_irq,
|
trap_irq,
|
timer_irq
|
timer_irq
|
)
|
)
|
begin
|
begin
|
cpu_irq <= acia_irq;
|
cpu_irq <= acia_irq;
|
cpu_nmi <= trap_irq or not( SW3_N );
|
cpu_nmi <= trap_irq or not( NMI_N );
|
cpu_firq <= timer_irq;
|
cpu_firq <= timer_irq;
|
cpu_halt <= '0';
|
cpu_halt <= '0';
|
cpu_hold <= '0'; -- pb_hold or ram_hold;
|
cpu_hold <= '0'; -- pb_hold or ram_hold;
|
end process;
|
end process;
|
|
|
--
|
--
|
-- Flash 7 segment LEDS
|
-- Generate CPU & Pixel Clock from Memory Clock
|
--
|
--
|
my_led_flasher: process( clk_i, rst_i, CountL )
|
my_prescaler : process( clk_i, clk_count )
|
begin
|
begin
|
if rst_i = '1' then
|
if rising_edge( clk_i ) then
|
CountL <= "000000000000000000000000";
|
if clk_count = 0 then
|
elsif rising_edge(clk_i) then
|
clk_count <= CPU_CLK_DIV-1;
|
CountL <= CountL + 1;
|
else
|
|
clk_count <= clk_count - 1;
|
|
end if;
|
|
if clk_count = 0 then
|
|
clk25 <= '0';
|
|
elsif clk_count = (CPU_CLK_DIV/2) then
|
|
clk25 <= '1';
|
|
end if;
|
end if;
|
end if;
|
--S(7 downto 0) <= CountL(23 downto 16);
|
|
end process;
|
end process;
|
|
|
--
|
--
|
-- Generate CPU & Pixel Clock from Memory Clock
|
|
--
|
|
-- my_prescaler : process( clk_i, clk_count )
|
|
-- begin
|
|
-- if rising_edge( clk_i ) then
|
|
-- if clk_count = 0 then
|
|
-- clk_count <= CPU_CLK_DIV-1;
|
|
-- else
|
|
-- clk_count <= clk_count - 1;
|
|
-- end if;
|
|
-- if clk_count = 0 then
|
|
-- clk25 <= '0';
|
|
-- elsif clk_count = (CPU_CLK_DIV/2) then
|
|
-- clk25 <= '1';
|
|
-- end if;
|
|
-- end if;
|
|
-- end process;
|
|
|
|
|
|
my_singlestep: btn_debounce
|
|
port map ( BTN_I => btn, CLK => CLKA, BTN_O => pbtn);
|
|
SW2_N <= pbtn(0);
|
|
SW3_N <= pbtn(1);
|
|
clk25 <= pbtn(2);
|
|
|
|
--
|
|
-- Reset button and reset timer
|
-- Reset button and reset timer
|
--
|
--
|
my_switch_assignments : process( rst_i, SW2_N)
|
my_switch_assignments : process( rst_i, RESET_N)
|
begin
|
begin
|
rst_i <= SW2_N;
|
rst_i <= RESET_N;
|
cpu_reset <= rst_i;
|
cpu_reset <= rst_i;
|
end process;
|
end process;
|
|
|
--
|
--
|
-- RS232 signals:
|
-- RS232 signals:
|
Line 831... |
Line 786... |
dcd_n <= '0';
|
dcd_n <= '0';
|
RS232_TXD <= txd;
|
RS232_TXD <= txd;
|
RS232_RTS <= rts_n;
|
RS232_RTS <= rts_n;
|
end process;
|
end process;
|
|
|
status_leds : process( rst_i, cpu_reset,cpu_addr, cpu_rw, sw)
|
|
begin
|
|
S(7) <= '0';
|
|
S(6) <= cpu_rw;
|
|
S(5) <= cpu_vma;
|
|
S(4) <= '0';
|
|
case sw is
|
|
when "00000000" =>
|
|
S(3 downto 0) <= cpu_addr(3 downto 0);
|
|
when "00000001" =>
|
|
S(3 downto 0) <= cpu_addr(7 downto 4);
|
|
when "00000010" =>
|
|
S(3 downto 0) <= cpu_addr(11 downto 8);
|
|
when "00000011" =>
|
|
S(3 downto 0) <= cpu_addr(15 downto 12);
|
|
when "00000100" =>
|
|
S(3 downto 0) <= cpu_data_in(3 downto 0);
|
|
when "00000101" =>
|
|
S(3 downto 0) <= cpu_data_in(7 downto 4);
|
|
when others => S(3 downto 0) <= (others => '0');
|
|
end case;
|
|
end process;
|
|
|
|
-- debug_proc : process( cpu_reset, cpu_clk, cpu_rw, cpu_vma,
|
-- debug_proc : process( cpu_reset, cpu_clk, cpu_rw, cpu_vma,
|
-- cpu_halt, cpu_hold,
|
-- cpu_halt, cpu_hold,
|
-- cpu_firq, cpu_irq, cpu_nmi,
|
-- cpu_firq, cpu_irq, cpu_nmi,
|
-- cpu_addr, cpu_data_out, cpu_data_in )
|
-- cpu_addr, cpu_data_out, cpu_data_in )
|
-- begin
|
-- begin
|