Advertisement
cofyye

D FLIP-FLOP ASYNC

Apr 6th, 2023
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.32 KB | Source Code | 0 0
  1. -- design.vhd
  2.  
  3. library IEEE;
  4. use IEEE.std_logic_1164.all;
  5.  
  6. entity d_flipflop_async is
  7.     port(C, D : in std_logic;
  8.          Q, Qn : out std_logic);
  9. end entity d_flipflop_async;
  10.  
  11. architecture d_flipflop_async_arch of d_flipflop_async is
  12. begin
  13.     process(C, D)
  14.     begin
  15.         if(C = '0' and D = '0') then
  16.             Q <= Q;
  17.             Q <= Qn;
  18.         elsif(C = '0' and D = '1') then
  19.             Q <= Q;
  20.             Qn <= Qn;
  21.         elsif(C = '1' and D = '0') then
  22.             Q <= '0';
  23.             Qn <= '1';
  24.         elsif(C = '1' and D = '1') then
  25.             Q <= '1';
  26.             Qn <= '0';
  27.         end if;
  28.     end process;
  29. end architecture d_flipflop_async_arch;
  30.  
  31.  
  32. -- testbench.vhd
  33.  
  34. library IEEE;
  35. use IEEE.std_logic_1164.all;
  36.  
  37. entity d_flipflop_async_tb is
  38. end entity d_flipflop_async_tb;
  39.  
  40. architecture d_flipflop_async_tb_arch of d_flipflop_async_tb is
  41.     signal C1, D1, Q1, Qn1 : std_logic;
  42. begin
  43.     DUT1 : entity work.d_flipflop_async(d_flipflop_async_arch)
  44.            port map(C1, D1, Q1, Qn1);
  45.    
  46.     STIMULUS : process
  47.     begin
  48.         C1 <= '0'; D1 <= '0'; wait for 10ns;
  49.         C1 <= '0'; D1 <= '1'; wait for 10ns;
  50.         C1 <= '1'; D1 <= '0'; wait for 10ns;
  51.         C1 <= '1'; D1 <= '1'; wait for 10ns;
  52.         C1 <= 'X'; D1 <= 'X'; wait for 10ns;
  53.     end process;
  54. end architecture d_flipflop_async_tb_arch;
Tags: VHDL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement