AppleIISd/VHDL/AppleIISd.vhd

222 lines
5.9 KiB
VHDL
Raw Normal View History

2017-08-27 10:21:26 +00:00
----------------------------------------------------------------------------------
2017-10-10 20:55:21 +00:00
-- Company:
-- Engineer:
2017-08-27 10:21:26 +00:00
--
2017-10-10 20:55:21 +00:00
-- Create Date: 20:44:25 10/09/2017
-- Design Name:
-- Module Name: IO - Behavioral
-- Project Name:
-- Target Devices:
2017-08-27 10:21:26 +00:00
-- Tool versions:
2017-10-10 20:55:21 +00:00
-- Description:
2017-08-27 10:21:26 +00:00
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
2017-10-10 20:55:21 +00:00
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
2017-08-27 10:21:26 +00:00
entity AppleIISd is
2017-09-03 12:51:09 +00:00
Port (
2017-10-16 20:53:41 +00:00
ADD_HIGH : in std_logic_vector(11 downto 8);
2017-10-10 20:55:21 +00:00
ADD_LOW : in std_logic_vector(1 downto 0);
B : out std_logic_vector(10 downto 8);
CARD : in std_logic;
DATA : inout std_logic_vector (7 downto 0);
CLK : in std_logic;
LED : out std_logic;
NDEV_SEL : in std_logic;
NG : out std_logic;
NIO_SEL : in std_logic;
NIO_STB : in std_logic;
NOE : out std_logic;
2019-02-10 11:47:46 +00:00
NWE : out std_logic;
2017-10-10 20:55:21 +00:00
PHI0 : in std_logic;
NRESET : in std_logic;
RNW : in std_logic;
MISO : in std_logic;
MOSI : out std_logic;
NSEL : out std_logic;
SCLK : out std_logic;
WP : in std_logic
-- synthesis translate_off
;
data_dbg : out std_logic_vector (7 downto 0);
2017-10-15 18:58:33 +00:00
add_dbg : out std_logic_vector (1 downto 0);
data_en_dbg : out std_logic
2017-10-10 20:55:21 +00:00
-- synthesis translate_on
2017-09-10 12:07:23 +00:00
);
2017-08-27 10:21:26 +00:00
end AppleIISd;
architecture Behavioral of AppleIISd is
2017-10-10 20:55:21 +00:00
signal data_in : std_logic_vector (7 downto 0);
signal data_out : std_logic_vector (7 downto 0);
signal addr_low_int : std_logic_vector (1 downto 0);
2019-04-08 19:17:44 +00:00
signal s_spi_data_in : std_logic_vector(7 downto 0);
signal s_spi_data_out : std_logic_vector(7 downto 0);
signal s_bsy : std_logic;
signal s_tc : std_logic;
signal s_ece : std_logic;
signal s_frx : std_logic;
2017-09-03 12:51:09 +00:00
2017-10-10 20:55:21 +00:00
signal data_en : std_logic;
2019-02-14 22:58:48 +00:00
signal pgm_en : std_logic;
2019-04-08 19:17:44 +00:00
component Registers is
Port (
ADDR : in STD_LOGIC_VECTOR (1 downto 0);
BUS_DATA_IN : in STD_LOGIC_VECTOR (7 downto 0);
BUS_DATA_OUT : out STD_LOGIC_VECTOR (7 downto 0);
SPI_DATA_IN : in STD_LOGIC_VECTOR (7 downto 0);
SPI_DATA_OUT : out STD_LOGIC_VECTOR (7 downto 0);
PGMEN : out STD_LOGIC;
ECE : out STD_LOGIC;
FRX : out STD_LOGIC;
SLAVESEL : out STD_LOGIC;
LED : out STD_LOGIC;
BSY : in STD_LOGIC;
TC : in STD_LOGIC;
WP : in STD_LOGIC;
CARD : in STD_LOGIC;
NRESET : in STD_LOGIC;
NDEV_SEL : in STD_LOGIC;
IS_READ : in STD_LOGIC
);
end component;
2017-10-10 20:55:21 +00:00
component SpiController is
Port (
2019-04-08 19:17:44 +00:00
BUS_DATA : in STD_LOGIC_VECTOR (7 downto 0);
SPI_DATA : out STD_LOGIC_VECTOR (7 downto 0);
IS_READ : in STD_LOGIC;
NRESET : in STD_LOGIC;
ADDR : in STD_LOGIC_VECTOR (1 downto 0);
CLK_SLOW : in STD_LOGIC;
NDEV_SEL : in STD_LOGIC;
CLK_FAST : in STD_LOGIC;
MISO: in std_logic;
MOSI : out STD_LOGIC;
SCLK : out STD_LOGIC;
BSY : out STD_LOGIC;
TC : out STD_LOGIC;
FRX : in std_logic;
ECE : in std_logic
2017-10-10 20:55:21 +00:00
);
end component;
2017-08-27 10:21:26 +00:00
2019-02-10 11:47:46 +00:00
component AddressDecoder
2017-10-10 20:55:21 +00:00
Port (
2017-10-16 20:53:41 +00:00
A : in std_logic_vector (11 downto 8);
2017-10-10 20:55:21 +00:00
B : out std_logic_vector (10 downto 8);
2017-10-13 21:04:38 +00:00
CLK : in std_logic;
PHI0 : in std_logic;
2017-10-10 20:55:21 +00:00
RNW : in std_logic;
NDEV_SEL : in std_logic;
NIO_SEL : in std_logic;
NIO_STB : in std_logic;
NRESET : in std_logic;
DATA_EN : out std_logic;
2019-02-14 22:58:48 +00:00
PGM_EN : in std_logic;
2017-10-10 20:55:21 +00:00
NG : out std_logic;
2017-10-23 20:42:27 +00:00
NOE : out std_logic;
2019-02-14 19:37:35 +00:00
NWE : out std_logic
2019-02-10 11:47:46 +00:00
);
end component;
2017-08-27 10:21:26 +00:00
2017-10-10 20:55:21 +00:00
begin
2019-04-08 19:17:44 +00:00
regs: Registers port map(
ADDR => addr_low_int,
BUS_DATA_IN => data_in,
BUS_DATA_OUT => data_out,
SPI_DATA_IN => s_spi_data_in,
SPI_DATA_OUT => s_spi_data_out,
PGMEN => pgm_en,
ECE => s_ece,
FRX => s_frx,
SLAVESEL => NSEL,
LED => LED,
BSY => s_bsy,
TC => s_tc,
WP => WP,
CARD => CARD,
NRESET => NRESET,
NDEV_SEL => NDEV_SEL,
IS_READ => RNW
);
2017-10-10 20:55:21 +00:00
spi: SpiController port map(
2019-04-08 19:17:44 +00:00
BUS_DATA => s_spi_data_out,
SPI_DATA => s_spi_data_in,
IS_READ => RNW,
NRESET => NRESET,
ADDR => addr_low_int,
CLK_SLOW => PHI0,
CLK_FAST => CLK,
NDEV_SEL => NDEV_SEL,
MISO => MISO,
MOSI => MOSI,
SCLK => SCLK,
BSY => s_bsy,
TC => s_tc,
FRX => s_frx,
ECE => s_ece
2017-10-10 20:55:21 +00:00
);
addDec: AddressDecoder port map(
A => ADD_HIGH,
B => B,
2017-10-13 21:04:38 +00:00
CLK => CLK,
PHI0 => PHI0,
2017-10-10 20:55:21 +00:00
RNW => RNW,
2017-10-13 21:04:38 +00:00
NDEV_SEL => NDEV_SEL,
2017-10-10 20:55:21 +00:00
NIO_SEL => NIO_SEL,
NIO_STB => NIO_STB,
NRESET => NRESET,
DATA_EN => data_en,
2019-02-14 22:58:48 +00:00
PGM_EN => pgm_en,
2017-10-10 20:55:21 +00:00
NOE => NOE,
2019-02-10 11:47:46 +00:00
NWE => NWE,
2017-10-10 20:55:21 +00:00
NG => NG
);
DATA <= data_out when (data_en = '1') else (others => 'Z'); -- data bus tristate
2017-09-03 12:51:09 +00:00
2017-10-10 20:55:21 +00:00
-- synthesis translate_off
2017-10-10 21:37:21 +00:00
data_dbg <= data_in;
add_dbg <= addr_low_int;
2017-10-15 18:58:33 +00:00
data_en_dbg <= data_en;
2017-10-10 20:55:21 +00:00
-- synthesis translate_on
2017-09-03 12:51:09 +00:00
2017-10-10 20:55:21 +00:00
data_latch: process(CLK)
2017-09-03 12:51:09 +00:00
begin
2017-10-10 21:37:21 +00:00
if falling_edge(CLK) then
2017-10-13 21:04:38 +00:00
addr_low_int <= ADD_LOW;
2017-10-10 20:55:21 +00:00
if (NDEV_SEL = '0') then
data_in <= DATA;
end if;
2017-09-03 12:51:09 +00:00
end if;
end process;
2017-10-10 20:55:21 +00:00
2017-08-27 10:21:26 +00:00
end Behavioral;