Advertisement
cofyye

SR FLIP-FLOP ASYNC

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