| 1 |
13 |
leonardoar |
--! @file
|
| 2 |
|
|
--! @brief Testbench for TriStateBuffer
|
| 3 |
|
|
|
| 4 |
|
|
--! Use standard library and import the packages (std_logic_1164,std_logic_unsigned,std_logic_arith)
|
| 5 |
|
|
LIBRARY ieee;
|
| 6 |
|
|
use ieee.std_logic_1164.all;
|
| 7 |
|
|
use ieee.std_logic_unsigned.all;
|
| 8 |
|
|
use ieee.std_logic_arith.all;
|
| 9 |
|
|
|
| 10 |
|
|
--! Use CPU Definitions package
|
| 11 |
|
|
use work.pkgOpenCPU32.all;
|
| 12 |
|
|
|
| 13 |
|
|
ENTITY testTriStateBuffer IS
|
| 14 |
|
|
END testTriStateBuffer;
|
| 15 |
|
|
|
| 16 |
|
|
--! @brief TriStateBuffer Testbench file
|
| 17 |
|
|
--! @details Test TriStateBuffer by enabling/disabling the sel signal
|
| 18 |
|
|
ARCHITECTURE behavior OF testTriStateBuffer IS
|
| 19 |
|
|
|
| 20 |
|
|
-- Component Declaration for the Unit Under Test (UUT)
|
| 21 |
|
|
|
| 22 |
|
|
COMPONENT TriStateBuffer
|
| 23 |
|
|
generic (n : integer := nBits - 1); --! Generic value (Used to easily change the size of the Alu on the package)
|
| 24 |
|
|
PORT(
|
| 25 |
|
|
A : IN std_logic_vector(n downto 0); --! Buffer Input
|
| 26 |
|
|
sel : IN typeEnDis; --! Enable or Disable the output
|
| 27 |
|
|
S : OUT std_logic_vector(n downto 0) --! Enable or Disable the output
|
| 28 |
|
|
);
|
| 29 |
|
|
END COMPONENT;
|
| 30 |
|
|
|
| 31 |
|
|
|
| 32 |
|
|
--Inputs
|
| 33 |
14 |
leonardoar |
signal A : std_logic_vector((nBits - 1) downto 0) := (others => '0'); --! Wire to connect Test signal to component
|
| 34 |
|
|
signal sel : typeEnDis := disable; --! Wire to connect Test signal to component
|
| 35 |
13 |
leonardoar |
|
| 36 |
|
|
--Outputs
|
| 37 |
14 |
leonardoar |
signal S : std_logic_vector((nBits - 1) downto 0); --! Wire to connect Test signal to component
|
| 38 |
13 |
leonardoar |
|
| 39 |
|
|
BEGIN
|
| 40 |
|
|
--!Instantiate the Unit Under Test (Multiplexer2_1) (Doxygen bug if it's not commented!)
|
| 41 |
|
|
uut: TriStateBuffer PORT MAP (
|
| 42 |
|
|
A => A,
|
| 43 |
|
|
sel => sel,
|
| 44 |
|
|
S => S
|
| 45 |
|
|
);
|
| 46 |
|
|
|
| 47 |
|
|
--! Process that will change sel signal and verify the Mux outputs
|
| 48 |
|
|
stim_proc: process
|
| 49 |
14 |
leonardoar |
variable allZ : std_logic_vector((nBits - 1) downto 0) := (others => 'Z');
|
| 50 |
13 |
leonardoar |
begin
|
| 51 |
|
|
-- Sel disable ---------------------------------------------------------------------------
|
| 52 |
|
|
wait for 1 ps;
|
| 53 |
|
|
REPORT "Test tristate on disable mode" SEVERITY NOTE;
|
| 54 |
|
|
sel <= disable;
|
| 55 |
|
|
A <= conv_std_logic_vector(10, nBits);
|
| 56 |
|
|
wait for 1 ns; -- Wait to stabilize the response
|
| 57 |
14 |
leonardoar |
assert S = allZ report "Output should be high impedance..." severity FAILURE;
|
| 58 |
13 |
leonardoar |
|
| 59 |
|
|
-- Sel disable ---------------------------------------------------------------------------
|
| 60 |
|
|
wait for 1 ps;
|
| 61 |
|
|
REPORT "Test tristate on enable mode" SEVERITY NOTE;
|
| 62 |
|
|
sel <= enable;
|
| 63 |
|
|
A <= conv_std_logic_vector(10, nBits);
|
| 64 |
|
|
wait for 1 ns; -- Wait to stabilize the response
|
| 65 |
|
|
assert S = (conv_std_logic_vector(10, nBits)) report "Output should be high impedance..." severity FAILURE;
|
| 66 |
|
|
|
| 67 |
18 |
leonardoar |
-- Finish simulation
|
| 68 |
|
|
assert false report "NONE. End of simulation." severity failure;
|
| 69 |
13 |
leonardoar |
end process;
|
| 70 |
|
|
|
| 71 |
|
|
END;
|