vlsibank

Log in or Sign up.
Main EDA Embedded Systems ASIC FPGA VHDL Verilog CMOS Semiconductors DSP Mixed Signal Architecture Miscellaneous

<-- Previous Next -- > TOPIC: D Flip-Flop VHDL Test Bench
Posted by: sasutto1     9/29/2008 1:07:57 PM     Category: VHDL
Questions posted: 1         Comments Posted: 0
I need to design a d flip flop test bench using VHDL code, can anyone help?

Posted by: kikani_niles     3/8/2010 10:26:47 PM
Comments Posted:1       

thanks for this


Posted by: $---Jay---$     9/30/2008 2:42:46 AM
Comments Posted:100       Questions Posted:1

----------------------------------------------------------------
-- Test Bench for D flip-flop
----------------------------------------------------------------

library ieee;
use ieee.std_logic_1164.all;

entity dff_TB is -- entity declaration
end dff_TB;

----------------------------------------------------------------

architecture TB of dff_TB is

   signal T_data_in: std_logic;
   signal T_clock: std_logic;
   signal T_data_out: std_logic;

   component dff
   port( data_in: in std_logic;
    clock: in std_logic;
data_out: out std_logic
   );
   end component;

begin

   U_DFF: dff port map (T_data_in, T_clock, T_data_out);

   -- concurrent process to offer clock signal
   process
   begin
T_clock <= '0';
wait for 5 ns;
T_clock <= '1';
wait for 5 ns;
   end process;

   process

variable err_cnt: integer := 0;

   begin

-- case 1
T_data_in <= '1';
wait for 12 ns;
assert (T_data_out='1') report "Error1!" severity error;
if (T_data_out/='1') then
   err_cnt := err_cnt + 1;
end if;

-- case 2
T_data_in <=  '0';
wait for 28 ns;
assert (T_data_out='0') report "Error2!" severity error;
if (T_data_out/='0') then
   err_cnt := err_cnt + 1;
end if;

-- case 3
T_data_in <= '1';  
wait for 2 ns;
assert (T_data_out='0') report "Error3!" severity error;
if (T_data_out/='0') then
   err_cnt := err_cnt + 1;
end if;

-- case 4
T_data_in <= '0';
wait for 10 ns;
assert (T_data_out='0') report "Error4!" severity error;
if (T_data_out/='0') then
   err_cnt := err_cnt + 1;
end if;

-- case 5
T_data_in <=  '1';
wait for 20 ns;
assert (T_data_out='1') report "Error5!" severity error;
if (T_data_out/='0') then
   err_cnt := err_cnt + 1;
end if;

-- summary of all the tests
if (err_cnt=0) then
   assert false
   report "Testbench of Adder completed successfully!"
   severity note;
else
   assert true
   report "Something wrong, try again"
   severity error;
end if;

wait;

   end process;

end TB;




You have to be logged in to be able to post a comment. To login click here. First time? Sign up. It just takes a few minutes to sign up.

Login to access the site

  Username:
  Password:
   Signup Forgot Password?    

Users with most replies

   User
 No. of Replies
100
86
77
76
70
66
61
57
54