--! Test uart_wishbone_slave (Main test module)
|
--! Test uart_wishbone_slave (Main test module)
|
LIBRARY ieee;
|
LIBRARY ieee;
|
USE ieee.std_logic_1164.ALL;
|
USE ieee.std_logic_1164.ALL;
|
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_arith.all;
|
use ieee.std_logic_arith.all;
|
|
|
--! Use Global Definitions package
|
--! Use Global Definitions package
|
use work.pkgDefinitions.all;
|
use work.pkgDefinitions.all;
|
|
|
ENTITY testUart_wishbone_slave IS
|
ENTITY testUart_wishbone_slave IS
|
END testUart_wishbone_slave;
|
END testUart_wishbone_slave;
|
|
|
ARCHITECTURE behavior OF testUart_wishbone_slave IS
|
ARCHITECTURE behavior OF testUart_wishbone_slave IS
|
|
|
-- Component Declaration for the Unit Under Test (UUT)
|
-- Component Declaration for the Unit Under Test (UUT)
|
|
|
COMPONENT uart_wishbone_slave
|
COMPONENT uart_wishbone_slave
|
PORT(
|
PORT(
|
RST_I : IN std_logic;
|
RST_I : IN std_logic;
|
CLK_I : IN std_logic;
|
CLK_I : IN std_logic;
|
ADR_I0 : IN std_logic_vector(1 downto 0);
|
ADR_I0 : IN std_logic_vector(1 downto 0);
|
DAT_I0 : IN std_logic_vector(31 downto 0);
|
DAT_I0 : IN std_logic_vector(31 downto 0);
|
DAT_O0 : OUT std_logic_vector(31 downto 0);
|
DAT_O0 : OUT std_logic_vector(31 downto 0);
|
WE_I : IN std_logic;
|
WE_I : IN std_logic;
|
STB_I : IN std_logic;
|
STB_I : IN std_logic;
|
ACK_O : OUT std_logic;
|
ACK_O : OUT std_logic;
|
serial_in : IN std_logic;
|
serial_in : IN std_logic;
|
|
data_Avaible : out std_logic; -- Indicate that the receiver module got something
|
serial_out : OUT std_logic
|
serial_out : OUT std_logic
|
);
|
);
|
END COMPONENT;
|
END COMPONENT;
|
|
|
|
|
--Inputs
|
--Inputs
|
signal RST_I : std_logic := '0';
|
signal RST_I : std_logic := '0';
|
signal CLK_I : std_logic := '0';
|
signal CLK_I : std_logic := '0';
|
signal ADR_I0 : std_logic_vector(1 downto 0) := (others => '0');
|
signal ADR_I0 : std_logic_vector(1 downto 0) := (others => '0');
|
signal DAT_I0 : std_logic_vector(31 downto 0) := (others => '0');
|
signal DAT_I0 : std_logic_vector(31 downto 0) := (others => '0');
|
signal WE_I : std_logic := '0';
|
signal WE_I : std_logic := '0';
|
signal STB_I : std_logic := '0';
|
signal STB_I : std_logic := '0';
|
signal serial_in : std_logic := '0';
|
signal serial_in : std_logic := '0';
|
|
|
--Outputs
|
--Outputs
|
signal DAT_O0 : std_logic_vector(31 downto 0);
|
signal DAT_O0 : std_logic_vector(31 downto 0);
|
signal ACK_O : std_logic;
|
signal ACK_O : std_logic;
|
signal serial_out : std_logic;
|
signal serial_out : std_logic;
|
|
signal data_Avaible : std_logic;
|
|
|
-- Clock period definitions (1.8432MHz)
|
-- Clock period definitions (1.8432MHz)
|
constant CLK_I_period : time := 20 ns; -- 0.543us (1.8432Mhz) 2ns (50Mhz)
|
constant CLK_I_period : time := 20 ns; -- 0.543us (1.8432Mhz) 2ns (50Mhz)
|
|
|
BEGIN
|
BEGIN
|
|
|
-- Instantiate the Unit Under Test (UUT)
|
-- Instantiate the Unit Under Test (UUT)
|
uut: uart_wishbone_slave PORT MAP (
|
uut: uart_wishbone_slave PORT MAP (
|
RST_I => RST_I,
|
RST_I => RST_I,
|
CLK_I => CLK_I,
|
CLK_I => CLK_I,
|
ADR_I0 => ADR_I0,
|
ADR_I0 => ADR_I0,
|
DAT_I0 => DAT_I0,
|
DAT_I0 => DAT_I0,
|
DAT_O0 => DAT_O0,
|
DAT_O0 => DAT_O0,
|
WE_I => WE_I,
|
WE_I => WE_I,
|
STB_I => STB_I,
|
STB_I => STB_I,
|
ACK_O => ACK_O,
|
ACK_O => ACK_O,
|
serial_in => serial_in,
|
serial_in => serial_in,
|
|
data_Avaible => data_Avaible,
|
serial_out => serial_out
|
serial_out => serial_out
|
);
|
);
|
|
|
-- Clock process definitions
|
-- Clock process definitions
|
CLK_I_process :process
|
CLK_I_process :process
|
begin
|
begin
|
CLK_I <= '0';
|
CLK_I <= '0';
|
wait for CLK_I_period/2;
|
wait for CLK_I_period/2;
|
CLK_I <= '1';
|
CLK_I <= '1';
|
wait for CLK_I_period/2;
|
wait for CLK_I_period/2;
|
end process;
|
end process;
|
|
|
|
|
-- Stimulus process
|
-- Stimulus process
|
stim_proc: process
|
stim_proc: process
|
begin
|
begin
|
-- Reset the slave
|
-- Reset the slave
|
RST_I <= '1';
|
RST_I <= '1';
|
serial_in <= '1';
|
serial_in <= '1';
|
wait for CLK_I_period;
|
wait for CLK_I_period;
|
RST_I <= '0';
|
RST_I <= '0';
|
wait for CLK_I_period;
|
wait for CLK_I_period;
|
|
|
-- Configure the clock...
|
-- Configure the clock...
|
ADR_I0 <= "00";
|
ADR_I0 <= "00";
|
WE_I <= '1';
|
WE_I <= '1';
|
STB_I <= '1';
|
STB_I <= '1';
|
DAT_I0 <= conv_std_logic_vector(50000000, (nBitsLarge));
|
DAT_I0 <= conv_std_logic_vector(50000000, (nBitsLarge));
|
wait until ACK_O = '1';
|
wait until ACK_O = '1';
|
WE_I <= '0';
|
WE_I <= '0';
|
STB_I <= '0';
|
STB_I <= '0';
|
ADR_I0 <= (others => 'U');
|
ADR_I0 <= (others => 'U');
|
wait for CLK_I_period;
|
wait for CLK_I_period;
|
|
|
-- Configure the Baud...
|
-- Configure the Baud...
|
ADR_I0 <= "01";
|
ADR_I0 <= "01";
|
WE_I <= '1';
|
WE_I <= '1';
|
STB_I <= '1';
|
STB_I <= '1';
|
DAT_I0 <= conv_std_logic_vector(115200, (nBitsLarge));
|
DAT_I0 <= conv_std_logic_vector(115200, (nBitsLarge));
|
wait until ACK_O = '1';
|
wait until ACK_O = '1';
|
WE_I <= '0';
|
WE_I <= '0';
|
STB_I <= '0';
|
STB_I <= '0';
|
ADR_I0 <= (others => 'U');
|
ADR_I0 <= (others => 'U');
|
wait for CLK_I_period;
|
wait for CLK_I_period;
|
|
|
-- Ask to send some data...(0xC4)
|
-- Ask to send some data...(0xC4)
|
ADR_I0 <= "10";
|
ADR_I0 <= "10";
|
WE_I <= '1';
|
WE_I <= '1';
|
STB_I <= '1';
|
STB_I <= '1';
|
DAT_I0 <= x"000000C4";
|
DAT_I0 <= x"000000C4";
|
wait until ACK_O = '1';
|
wait until ACK_O = '1';
|
WE_I <= '0';
|
WE_I <= '0';
|
STB_I <= '0';
|
STB_I <= '0';
|
ADR_I0 <= (others => 'U');
|
ADR_I0 <= (others => 'U');
|
wait for CLK_I_period*500;
|
wait for CLK_I_period*500;
|
|
|
-- Receive data from serial
|
-- Receive data from serial
|
ADR_I0 <= "11";
|
ADR_I0 <= "11";
|
WE_I <= '0';
|
WE_I <= '0';
|
STB_I <= '1';
|
STB_I <= '1';
|
wait for CLK_I_period*100; -- Error !!!!! (Should not need this!!)
|
wait for CLK_I_period*100; -- Error !!!!! (Should not need this!!)
|
|
|
-- Receive data... (Should work by retainning the last received value...)
|
-- Receive data... (Should work by retainning the last received value...)
|
-- Receive 0x55 value (01010101)
|
-- Receive 0x55 value (01010101)
|
serial_in <= '0'; -- Start bit
|
serial_in <= '0'; -- Start bit
|
wait for 8.68 us;
|
wait for 8.68 us;
|
|
|
serial_in <= '1';
|
serial_in <= '1';
|
wait for 8.68 us;
|
wait for 8.68 us;
|
serial_in <= '0';
|
serial_in <= '0';
|
wait for 8.68 us;
|
wait for 8.68 us;
|
serial_in <= '1';
|
serial_in <= '1';
|
wait for 8.68 us;
|
wait for 8.68 us;
|
serial_in <= '0';
|
serial_in <= '0';
|
wait for 8.68 us;
|
wait for 8.68 us;
|
serial_in <= '1';
|
serial_in <= '1';
|
wait for 8.68 us;
|
wait for 8.68 us;
|
serial_in <= '0';
|
serial_in <= '0';
|
wait for 8.68 us;
|
wait for 8.68 us;
|
serial_in <= '1';
|
serial_in <= '1';
|
wait for 8.68 us;
|
wait for 8.68 us;
|
serial_in <= '0';
|
serial_in <= '0';
|
wait for 8.68 us;
|
wait for 8.68 us;
|
|
|
-- Stop bit here
|
-- Stop bit here
|
serial_in <= '1';
|
serial_in <= '1';
|
|
|
wait until ACK_O = '1';
|
wait until ACK_O = '1';
|
wait for CLK_I_period*100;
|
wait for CLK_I_period*100;
|
STB_I <= '0';
|
STB_I <= '0';
|
wait for CLK_I_period*100;
|
wait for CLK_I_period*100;
|
|
|
-- Read byte sent...
|
-- Read byte sent...
|
ADR_I0 <= "10";
|
ADR_I0 <= "10";
|
WE_I <= '0';
|
WE_I <= '0';
|
STB_I <= '1';
|
STB_I <= '1';
|
wait until ACK_O = '1';
|
wait until ACK_O = '1';
|
wait for CLK_I_period*100;
|
wait for CLK_I_period*100;
|
|
|
-- Stop Simulation
|
-- Stop Simulation
|
assert false report "NONE. End of simulation." severity failure;
|
assert false report "NONE. End of simulation." severity failure;
|
end process;
|
end process;
|
|
|
END;
|
END;
|
|
|