Advertisement
cofyye

D FLIP-FLOP RESET SYNC

Apr 6th, 2023 (edited)
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.95 KB | Source Code | 0 0
  1. -- design.vhd
  2.  
  3. library IEEE;
  4. use IEEE.std_logic_1164.all;
  5.  
  6. entity d_flipflop_wReset_sync is
  7.     port(reset, clock, D : in std_logic;
  8.          Q, Qn : out std_logic);
  9. end entity d_flipflop_wReset_sync;
  10.  
  11. architecture d_flipflop_wReset_sync_arch of d_flipflop_wReset_sync is
  12. begin
  13.     process(clock)
  14.     begin
  15.         if(clock'event and clock = '1') then
  16.             if(reset = '1') then
  17.                 Q <= '0';
  18.                 Qn <= '0';
  19.             elsif(reset = '0' and D = '0') then
  20.                 Q <= D;
  21.                 Qn <= not D;
  22.             elsif(reset = '0' and D = '1') then
  23.                 Q <= D;
  24.                 Qn <= not D;
  25.             end if;
  26.         end if;
  27.     end process;
  28. end architecture d_flipflop_wReset_sync_arch;
  29.  
  30.  
  31. -- testbench.vhd
  32.  
  33. library IEEE;
  34. use IEEE.std_logic_1164.all;
  35.  
  36. entity d_flipflop_wReset_sync_tb is
  37. end entity d_flipflop_wReset_sync_tb;
  38.  
  39. architecture d_flipflop_wReset_sync_tb_arch of d_flipflop_wReset_sync_tb is
  40.     signal reset1, clock1, D1, Q1, Qn1 : std_logic;
  41. begin
  42.     DUT1 : entity work.d_flipflop_wReset_sync(d_flipflop_wReset_sync_arch)
  43.            port map(reset1, clock1, D1, Q1, Qn1);
  44.    
  45.     CLOCK : process
  46.     begin
  47.         clock1 <= '0'; wait for 10ns;
  48.         clock1 <= '1'; wait for 10ns;
  49.     end process CLOCK;
  50.    
  51.     STIMULUS : process
  52.     begin
  53.         reset1 <= '0'; D1 <= '0'; wait for 10ns;
  54.         reset1 <= '1'; D1 <= '0'; wait for 10ns;
  55.         reset1 <= '0'; D1 <= '0'; wait for 10ns;
  56.         reset1 <= '1'; D1 <= '0'; wait for 10ns;
  57.         reset1 <= '0'; D1 <= '1'; wait for 10ns;
  58.         reset1 <= '1'; D1 <= '1'; wait for 10ns;
  59.         reset1 <= '0'; D1 <= '1'; wait for 10ns;
  60.         reset1 <= '1'; D1 <= '1'; wait for 10ns;
  61.         reset1 <= '0'; D1 <= 'X'; wait for 10ns;
  62.         reset1 <= '1'; D1 <= 'X'; wait for 10ns;
  63.         reset1 <= '0'; D1 <= 'X'; wait for 10ns;
  64.         reset1 <= '0'; D1 <= 'X'; wait for 10ns;
  65.     end process STIMULUS;
  66. end architecture d_flipflop_wReset_sync_tb_arch;
Tags: VHDL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement