AppleIISd/VHDL/AddressDecoder_Test.vhd

344 lines
11 KiB
VHDL
Raw Normal View History

2017-10-10 22:53:20 +00:00
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
2017-10-09 20:35:47 +00:00
--
2017-10-10 22:53:20 +00:00
-- Create Date: 23:42:22 10/10/2017
-- Design Name:
-- Module Name: C:/Git/AppleIISd/VHDL/AddressDecoder_Test.vhd
-- Project Name: AppleIISd
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: AddressDecoder
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
2017-10-09 20:35:47 +00:00
--
2017-10-10 22:53:20 +00:00
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
2017-10-09 20:35:47 +00:00
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
2017-10-10 22:53:20 +00:00
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY AddressDecoder_Test IS
END AddressDecoder_Test;
ARCHITECTURE behavior OF AddressDecoder_Test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT AddressDecoder
PORT(
2017-10-16 20:53:41 +00:00
A : IN std_logic_vector(11 downto 8);
2017-10-10 22:53:20 +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 22:53:20 +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;
2019-02-14 22:58:48 +00:00
DATA_EN : OUT std_logic;
PGM_EN : IN std_logic;
2017-10-10 22:53:20 +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
2017-10-10 22:53:20 +00:00
);
END COMPONENT;
2017-10-09 20:35:47 +00:00
2017-10-10 22:53:20 +00:00
--Inputs
2017-10-16 20:53:41 +00:00
signal A : std_logic_vector(11 downto 8) := "0101";
2017-10-10 22:53:20 +00:00
signal RNW : std_logic := '1';
signal NDEV_SEL : std_logic := '1';
signal NIO_SEL : std_logic := '1';
signal NIO_STB : std_logic := '1';
signal NRESET : std_logic := '1';
2017-10-13 21:04:38 +00:00
signal CLK : std_logic := '0';
2019-02-14 22:58:48 +00:00
signal PHI0 : std_logic := '1';
signal PGM_EN : std_logic := '1';
2017-10-09 20:35:47 +00:00
--Outputs
2017-10-10 22:53:20 +00:00
signal B : std_logic_vector(10 downto 8);
signal DATA_EN : std_logic;
signal NG : std_logic;
signal NOE : std_logic;
2019-02-10 11:47:46 +00:00
signal NWE : std_logic;
2017-10-13 21:04:38 +00:00
-- Clock period definitions
constant CLK_period : time := 142 ns;
2017-10-10 22:53:20 +00:00
2017-10-09 20:35:47 +00:00
BEGIN
2017-10-10 22:53:20 +00:00
-- Instantiate the Unit Under Test (UUT)
2017-10-10 22:53:20 +00:00
uut: AddressDecoder PORT MAP (
A => A,
B => B,
2017-10-13 21:04:38 +00:00
CLK => CLK,
PHI0 => PHI0,
2017-10-10 22:53:20 +00:00
RNW => RNW,
NDEV_SEL => NDEV_SEL,
NIO_SEL => NIO_SEL,
NIO_STB => NIO_STB,
NRESET => NRESET,
2019-02-14 22:58:48 +00:00
DATA_EN => DATA_EN,
PGM_EN => PGM_EN,
2017-10-10 22:53:20 +00:00
NG => NG,
2017-10-23 20:42:27 +00:00
NOE => NOE,
2019-02-14 19:37:35 +00:00
NWE => NWE
2017-10-10 22:53:20 +00:00
);
2017-10-13 21:04:38 +00:00
-- Clock process definitions
CLK_process :process
begin
CLK <= '0';
wait for CLK_period/2;
CLK <= '1';
wait for CLK_period/2;
2017-10-13 21:04:38 +00:00
end process;
PHI0_process :process(CLK)
variable counter : integer range 0 to 7;
begin
if rising_edge(CLK) or falling_edge(CLK) then
counter := counter + 1;
if counter = 7 then
PHI0 <= not PHI0;
counter := 0;
end if;
end if;
end process;
2017-10-10 22:53:20 +00:00
-- Stimulus process
stim_proc: process
begin
2017-10-13 21:04:38 +00:00
-- hold reset state.
wait for CLK_period * 10;
2017-10-10 22:53:20 +00:00
NRESET <= '0';
2017-10-13 21:04:38 +00:00
wait for CLK_period * 20;
2017-10-10 22:53:20 +00:00
NRESET <= '1';
2017-10-13 21:04:38 +00:00
wait for CLK_period * 10;
2017-10-09 20:35:47 +00:00
2017-10-16 20:53:41 +00:00
-- C0nX access
-- NG must be '0"
-- NOE must be '1'
-- NWE must be '1'
2017-10-23 20:42:27 +00:00
A <= "0000"; -- must become "000"
2017-10-13 21:04:38 +00:00
wait until rising_edge(PHI0);
2017-10-10 22:53:20 +00:00
NDEV_SEL <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (B="000") report "Address error" severity error;
assert (NG='0') report "NG error" severity error;
assert (NOE='1') report "NOE error" severity error;
assert (NWE='1') report "NWE error" severity error;
2017-10-10 22:53:20 +00:00
NDEV_SEL <= '1';
2019-02-14 22:26:44 +00:00
wait until rising_edge(PHI0);
2019-03-17 14:59:43 +00:00
assert (NG='1') report "NG error" severity error;
assert (NOE='1') report "NOE error" severity error;
assert (NWE='1') report "NWE error" severity error;
2019-02-14 22:26:44 +00:00
-- C0nX access, write
-- NG must be '0"
-- NOE must be '1'
-- NWE must be '1'
RNW <= '0';
A <= "0000"; -- must become "000"
wait until rising_edge(PHI0);
NDEV_SEL <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (B="000") report "Address error" severity error;
assert (NG='0') report "NG error" severity error;
assert (NOE='1') report "NOE error" severity error;
assert (NWE='1') report "NWE error" severity error;
2019-02-14 22:26:44 +00:00
NDEV_SEL <= '1';
2017-10-13 21:04:38 +00:00
wait until rising_edge(PHI0);
2017-10-16 20:53:41 +00:00
-- CnXX access, select
-- NG must be '0'
-- NOE must be '0'
2019-02-14 22:26:44 +00:00
-- NWE must be '1'
RNW <= '1';
A <= "0100"; -- must become "000"
wait until rising_edge(PHI0);
NIO_SEL <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (B="000") report "Address error" severity error;
assert (NG='0') report "NG error" severity error;
assert (NOE='0') report "NOE error" severity error;
assert (NWE='1') report "NWE error" severity error;
2019-02-14 22:26:44 +00:00
NIO_SEL <= '1';
wait until rising_edge(PHI0);
-- CnXX access, write, select
-- NG must be '0'
-- NOE must be '1'
-- NWE must be '0'
RNW <= '0';
2017-10-23 20:42:27 +00:00
A <= "0100"; -- must become "000"
2017-10-16 20:53:41 +00:00
wait until rising_edge(PHI0);
2017-10-10 22:53:20 +00:00
NIO_SEL <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (B="000") report "Address error" severity error;
assert (NG='0') report "NG error" severity error;
assert (NOE='1') report "NOE error" severity error;
assert (NWE='0') report "NWE error" severity error;
2017-10-10 22:53:20 +00:00
NIO_SEL <= '1';
2019-02-14 22:58:48 +00:00
wait until rising_edge(PHI0);
-- CnXX access, write, select, no PGM_EN
-- NG must be '0'
-- NOE must be '1'
-- NWE must be '1'
RNW <= '0';
PGM_EN <= '0';
A <= "0100"; -- must become "000"
wait until rising_edge(PHI0);
NIO_SEL <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (B="000") report "Address error" severity error;
assert (NG='0') report "NG error" severity error;
assert (NOE='1') report "NOE error" severity error;
assert (NWE='1') report "NWE error" severity error;
2019-02-14 22:58:48 +00:00
NIO_SEL <= '1';
2017-10-13 21:04:38 +00:00
wait until rising_edge(PHI0);
2017-10-16 20:53:41 +00:00
2017-10-10 22:53:20 +00:00
-- C8xx access, selected
-- NG must be '0'
-- NOE must be '0'
2019-02-14 22:26:44 +00:00
-- NWE must be '1'
2019-02-14 22:58:48 +00:00
RNW <= '1';
PGM_EN <= '1';
2017-10-23 20:42:27 +00:00
A <= "1000"; -- must become "001"
2017-10-16 20:53:41 +00:00
wait until rising_edge(PHI0);
2017-10-10 22:53:20 +00:00
NIO_STB <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (B="001") report "Address error" severity error;
assert (NG='0') report "NG error" severity error;
assert (NOE='0') report "NOE error" severity error;
assert (NWE='1') report "NWE error" severity error;
2017-10-10 22:53:20 +00:00
NIO_STB <= '1';
2017-10-13 21:04:38 +00:00
wait until rising_edge(PHI0);
-- C8xx write access, selected
-- NG must be '0'
-- NOE must be '1'
-- NWE must be '0'
2019-02-14 19:37:35 +00:00
RNW <= '0';
2019-02-10 11:47:46 +00:00
wait until rising_edge(PHI0);
NIO_STB <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (NG='0') report "NG error" severity error;
assert (NOE='1') report "NOE error" severity error;
assert (NWE='0') report "NWE error" severity error;
2019-02-10 11:47:46 +00:00
NIO_STB <= '1';
wait until rising_edge(PHI0);
2017-10-16 20:53:41 +00:00
-- C9xx access, selected
-- NG must be '0'
-- NOE must be '0'
-- NWE must be '1'
2019-02-10 11:47:46 +00:00
RNW <= '1';
2017-10-23 20:42:27 +00:00
A <= "1001"; -- must become "010"
2017-10-13 21:04:38 +00:00
wait until rising_edge(PHI0);
2017-10-16 20:53:41 +00:00
NIO_STB <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (B="010") report "Address error" severity error;
assert (NG='0') report "NG error" severity error;
assert (NOE='0') report "NOE error" severity error;
assert (NWE='1') report "NWE error" severity error;
2017-10-16 20:53:41 +00:00
NIO_STB <= '1';
wait until rising_edge(PHI0);
-- C9xx access write, selected
-- NG must be '0'
-- NOE must be '1'
-- NWE must be '0'
2019-02-10 11:47:46 +00:00
RNW <= '0';
wait until rising_edge(PHI0);
NIO_STB <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (NG='0') report "NG error" severity error;
assert (NOE='1') report "NOE error" severity error;
assert (NWE='0') report "NWE error" severity error;
2019-02-10 11:47:46 +00:00
NIO_STB <= '1';
wait until rising_edge(PHI0);
2017-10-16 20:53:41 +00:00
2017-10-10 22:53:20 +00:00
-- CPLD access
-- NG must be '0'
-- NOE must be '1'
-- NWE must be '1'
2019-02-10 11:47:46 +00:00
RNW <= '1';
2017-10-23 20:42:27 +00:00
A <= "0101"; -- must become "000"
2017-10-16 20:53:41 +00:00
wait until rising_edge(PHI0);
2017-10-10 22:53:20 +00:00
NDEV_SEL <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (B="000") report "Address error" severity error;
assert (NG='0') report "NG error" severity error;
assert (NOE='1') report "NOE error" severity error;
assert (NWE='1') report "NWE error" severity error;
2017-10-10 22:53:20 +00:00
NDEV_SEL <= '1';
2017-10-13 21:04:38 +00:00
wait until rising_edge(PHI0);
2017-10-16 20:53:41 +00:00
2017-10-10 22:53:20 +00:00
-- CFFF access
-- NG must be '1'
-- NOE must be '1'
-- NWE must be '1'
2017-10-16 20:53:41 +00:00
A <= "1111"; -- must become "111"
wait until rising_edge(PHI0);
2017-10-10 22:53:20 +00:00
NIO_STB <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (B="111") report "Address error" severity error;
assert (NG='1') report "NG error" severity error;
assert (NOE='1') report "NOE error" severity error;
assert (NWE='1') report "NWE error" severity error;
2017-10-10 22:53:20 +00:00
NIO_STB <= '1';
2017-10-13 21:04:38 +00:00
wait until rising_edge(PHI0);
2017-10-16 20:53:41 +00:00
2017-10-10 22:53:20 +00:00
-- C8xx access, unselected
-- NG must be '1'
-- NOE must be '1'
-- NWE must be '1'
2017-10-23 20:42:27 +00:00
A <= "1000"; -- must become "001"
2017-10-16 20:53:41 +00:00
wait until rising_edge(PHI0);
2017-10-10 22:53:20 +00:00
NIO_STB <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (B="001") report "Address error" severity error;
assert (NG='1') report "NG error" severity error;
assert (NOE='1') report "NOE error" severity error;
assert (NWE='1') report "NWE error" severity error;
2017-10-10 22:53:20 +00:00
NIO_STB <= '1';
2019-02-14 22:26:44 +00:00
wait until rising_edge(PHI0);
-- C8xx access write, unselected
-- NG must be '1'
-- NOE must be '1'
-- NWE must be '1'
RNW <= '0';
A <= "1000"; -- must become "001"
wait until rising_edge(PHI0);
NIO_STB <= '0';
2019-03-17 14:59:43 +00:00
wait until falling_edge(PHI0);
assert (B="001") report "Address error" severity error;
assert (NG='1') report "NG error" severity error;
assert (NOE='1') report "NOE error" severity error;
assert (NWE='1') report "NWE error" severity error;
2019-02-14 22:26:44 +00:00
NIO_STB <= '1';
2017-10-13 21:04:38 +00:00
wait until rising_edge(PHI0);
2017-10-09 20:35:47 +00:00
2017-10-10 22:53:20 +00:00
wait;
end process;
2017-10-09 20:35:47 +00:00
END;