--! Test baud_generator module
|
--! Test baud_generator 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 testBaud_generator IS
|
ENTITY testBaud_generator IS
|
END testBaud_generator;
|
END testBaud_generator;
|
|
|
ARCHITECTURE behavior OF testBaud_generator IS
|
ARCHITECTURE behavior OF testBaud_generator IS
|
|
|
|
|
|
|
COMPONENT baud_generator
|
COMPONENT baud_generator
|
PORT(
|
PORT(
|
rst : IN std_logic;
|
rst : IN std_logic;
|
clk : IN std_logic;
|
clk : IN std_logic;
|
cycle_wait : in STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0);
|
cycle_wait : in STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0);
|
|
baud_oversample : out std_logic;
|
baud : OUT std_logic
|
baud : OUT std_logic
|
);
|
);
|
END COMPONENT;
|
END COMPONENT;
|
|
|
|
|
--Inputs
|
--Inputs
|
signal rst : std_logic := '0';
|
signal rst : std_logic := '0';
|
signal clk : std_logic := '0';
|
signal clk : std_logic := '0';
|
signal cycle_wait : std_logic_vector((nBitsLarge-1) downto 0) := (others => '0');
|
signal cycle_wait : std_logic_vector((nBitsLarge-1) downto 0) := (others => '0');
|
|
|
--Outputs
|
--Outputs
|
signal baud : std_logic;
|
signal baud : std_logic;
|
|
signal baud_oversample : std_logic;
|
|
|
-- Clock period definitions (1.8432MHz)
|
-- Clock period definitions (1.8432MHz)
|
constant clk_period : time := 0.543 us; -- 0.543us (1.8432Mhz) 2ns (50Mhz)
|
constant clk_period : time := 0.543 us; -- 0.543us (1.8432Mhz) 2ns (50Mhz)
|
|
|
BEGIN
|
BEGIN
|
|
|
-- Instantiate the Unit Under Test (UUT)
|
-- Instantiate the Unit Under Test (UUT)
|
uut: baud_generator PORT MAP (
|
uut: baud_generator PORT MAP (
|
rst => rst,
|
rst => rst,
|
clk => clk,
|
clk => clk,
|
cycle_wait => cycle_wait,
|
cycle_wait => cycle_wait,
|
|
baud_oversample => baud_oversample,
|
baud => baud
|
baud => baud
|
);
|
);
|
|
|
-- Clock process definitions
|
-- Clock process definitions
|
clk_process :process
|
clk_process :process
|
begin
|
begin
|
clk <= '0';
|
clk <= '0';
|
wait for clk_period/2;
|
wait for clk_period/2;
|
clk <= '1';
|
clk <= '1';
|
wait for clk_period/2;
|
wait for clk_period/2;
|
end process;
|
end process;
|
|
|
|
|
-- Stimulus process
|
-- Stimulus process
|
stim_proc: process
|
stim_proc: process
|
begin
|
begin
|
-- Test the baud generator waiting for 16 clock cycles for 1.8432MHz clock
|
-- Test the baud generator waiting for 16 clock cycles for 1.8432MHz clock
|
rst <= '1';
|
rst <= '1';
|
cycle_wait <= conv_std_logic_vector(16, (nBitsLarge));
|
cycle_wait <= conv_std_logic_vector(16, (nBitsLarge));
|
wait for 2 ns;
|
wait for 2 ns;
|
rst <= '0';
|
rst <= '0';
|
|
|
wait for clk_period*300;
|
wait for clk_period*300;
|
|
|
-- Stop Simulation
|
-- Stop Simulation
|
assert false report "NONE. End of simulation." severity failure;
|
assert false report "NONE. End of simulation." severity failure;
|
|
|
wait;
|
wait;
|
end process;
|
end process;
|
|
|
END;
|
END;
|
|
|