Line 1... |
Line 1... |
--! Test serial_transmitter module
|
--! @file
|
|
--! @brief Test serial_transmitter module
|
|
|
|
--! Use standard library and import the packages (std_logic_1164,std_logic_unsigned,std_logic_arith)
|
LIBRARY ieee;
|
LIBRARY ieee;
|
USE ieee.std_logic_1164.ALL;
|
USE ieee.std_logic_1164.ALL;
|
|
|
--! Use CPU Definitions package
|
--! Use CPU Definitions package
|
use work.pkgDefinitions.all;
|
use work.pkgDefinitions.all;
|
|
|
ENTITY testSerial_transmitter IS
|
ENTITY testSerial_transmitter IS
|
END testSerial_transmitter;
|
END testSerial_transmitter;
|
|
|
|
--! @brief Test serial_transmitter module
|
|
--! @details Just send the date over the serial_out and analyse the results
|
ARCHITECTURE behavior OF testSerial_transmitter IS
|
ARCHITECTURE behavior OF testSerial_transmitter IS
|
|
|
-- Component Declaration for the Unit Under Test (UUT)
|
-- Component Declaration for the Unit Under Test (UUT)
|
|
|
COMPONENT serial_transmitter
|
COMPONENT serial_transmitter
|
Line 61... |
Line 66... |
rst <= '1';
|
rst <= '1';
|
data_byte <= "01010101";
|
data_byte <= "01010101";
|
wait for 50 ns;
|
wait for 50 ns;
|
rst <= '0';
|
rst <= '0';
|
|
|
|
-- Test serial data...
|
|
wait until rising_edge(baudClk); -- Start bit
|
|
wait for 1 ns;
|
|
assert serial_out = '0' report "Invalid value " severity failure;
|
|
|
|
for numBit in 0 to 7 loop
|
|
wait until rising_edge(baudClk);
|
|
wait for 1 ns;
|
|
-- The image attribute convert a typed value into a string
|
|
report "Testing bit:" & integer'image(numBit) & " value " & std_logic'image(serial_out);
|
|
assert serial_out = data_byte(numBit) report "Invalid value on bit:" severity failure;
|
|
end loop;
|
|
|
wait until data_sent = '1';
|
wait until data_sent = '1';
|
wait for baudClk_period*3;
|
wait for baudClk_period*3;
|
|
|
-- Prepare the data to be sent
|
-- Prepare the data to be sent
|
rst <= '1';
|
rst <= '1';
|
data_byte <= "11000100";
|
data_byte <= "11000100";
|
wait for 50 ns;
|
wait for 50 ns;
|
rst <= '0';
|
rst <= '0';
|
|
|
|
-- Test serial data...
|
|
wait until rising_edge(baudClk); -- Start bit
|
|
wait for 1 ns;
|
|
assert serial_out = '0' report "Invalid value " severity failure;
|
|
|
|
for numBit in 0 to (data_byte'LENGTH-1) loop
|
|
-- Wait for the clock rising edge
|
|
wait until rising_edge(baudClk);
|
|
wait for 1 ns;
|
|
report "Testing bit:" & integer'image(numBit) & " value " & std_logic'image(serial_out);
|
|
assert serial_out = data_byte(numBit) report "Invalid value on bit:" severity failure;
|
|
end loop;
|
|
|
|
|
wait until data_sent = '1';
|
wait until data_sent = '1';
|
wait for baudClk_period*3;
|
wait for baudClk_period*3;
|
|
|
-- Stop Simulation
|
-- Stop Simulation
|
assert false report "NONE. End of simulation." severity failure;
|
assert false report "NONE. End of simulation." severity failure;
|