Advertisement
cofyye

D FLIP-FLOP RESET ASYNC

Apr 6th, 2023
530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.90 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_async is
  7.     port(reset, clock, D : in std_logic;
  8.          Q, Qn : out std_logic);
  9. end entity d_flipflop_wReset_async;
  10.  
  11. architecture d_flipflop_wReset_async_arch of d_flipflop_wReset_async is
  12. begin
  13.     process
  14.     begin
  15.         if(reset = '1') then
  16.             Q <= '0';
  17.             Qn <= '0';
  18.         elsif(reset = '0' and clock = '0') then
  19.             Q <= Q;
  20.             Qn <= Qn;
  21.         elsif(reset = '0' and clock = '1' and D = '0') then
  22.             Q <= D;
  23.             Qn <= not D;
  24.         elsif(reset = '0' and clock = '1' and D = '1') then
  25.             Q <= D;
  26.             Qn <= not D;
  27.         end if;
  28.     end process;
  29. end architecture d_flipflop_wReset_async_arch;
  30.  
  31. -- testbench.vhd
  32.  
  33. library IEEE;
  34. use IEEE.std_logic_1164.all;
  35.  
  36. entity d_flipflop_wReset_async_tb is
  37. end entity d_flipflop_wReset_async_tb;
  38.  
  39. architecture d_flipflop_wReset_async_tb_arch of d_flipflop_wReset_async_tb is
  40.     signal reset1, clock1, D1, Q1, Qn1 : std_logic;
  41. begin
  42.     DUT1 : entity work.d_flipflop_wReset_async(d_flipflop_wReset_async_arch)
  43.            port map(reset1, clock1, D1, Q1, Qn1);
  44.    
  45.     STIMULUS : process
  46.     begin
  47.         reset1 <= '0'; clock1 <= '0'; D1 <= '0'; wait for 10ns;
  48.         reset1 <= '1'; clock1 <= '0'; D1 <= '0'; wait for 10ns;
  49.         reset1 <= '0'; clock1 <= '0'; D1 <= '1'; wait for 10ns;
  50.         reset1 <= '1'; clock1 <= '0'; D1 <= '1'; wait for 10ns;
  51.         reset1 <= '0'; clock1 <= '1'; D1 <= '0'; wait for 10ns;
  52.         reset1 <= '1'; clock1 <= '1'; D1 <= '0'; wait for 10ns;
  53.         reset1 <= '0'; clock1 <= '1'; D1 <= '1'; wait for 10ns;
  54.         reset1 <= '1'; clock1 <= '1'; D1 <= '1'; wait for 10ns;
  55.         reset1 <= '0'; clock1 <= 'X'; D1 <= 'X'; wait for 10ns;
  56.         reset1 <= '1'; clock1 <= 'X'; D1 <= 'X'; wait for 10ns;
  57.     end process STIMULUS;
  58. end architecture d_flipflop_wReset_async_tb_arch;
Tags: VHDL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement