milanmetal

[VHDL] D Flip-flop w/ CE and Async CLEAR/PRESET

Apr 1st, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.51 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:          F T N
  3. -- Engineer:         Milan Nedic
  4. --
  5. -- Create Date:    01:14:55 04/02/2017
  6. -- Design Name:
  7. -- Module Name:    D_FLIPFLOP_CE_ASYNC_CLEAR_PRESET_BEH - Behavioral
  8.  
  9. ----------------------------------------------------------------------------------
  10. library IEEE;
  11. use IEEE.STD_LOGIC_1164.ALL;
  12.  
  13.  
  14. entity D_FLIPFLOP_CE_ASYNC_CLEAR_PRESET_BEH is
  15.     Port ( clk :                in  STD_LOGIC;
  16.            d :                  in  STD_LOGIC;
  17.            ce :                 in  STD_LOGIC;
  18.            clear :              in  STD_LOGIC;
  19.            preset :             in  STD_LOGIC;
  20.            q :                  out  STD_LOGIC
  21.             );
  22. end D_FLIPFLOP_CE_ASYNC_CLEAR_PRESET_BEH;
  23.  
  24. architecture Behavioral of D_FLIPFLOP_CE_ASYNC_CLEAR_PRESET_BEH is
  25. begin
  26.     -- Asynchronous PRESET and CLEAR with CLOCK ENABLE
  27.     -- Asynchronous inputs are placed in SENSITIVITY LIST
  28.     d_ff: process(clk, clear, preset) is
  29.     begin
  30.         -- First, lets check Asynchronous INPUTS
  31.         if(clear = '1') then                                -- CLEAR has PRIORITY higher than PRESET
  32.             q <= '0';                                       -- Sets OUTPUT to 0
  33.         elsif(preset = '1') then                            -- PRESET has second order PRIORITY
  34.             q <= '1';                                       -- Sets OUTPUT to 1
  35.         else
  36.             -- Check synchronous part...
  37.             if(clk'event and clk = '1')then                 -- on CLOCK rising edge
  38.                 if(ce = '1') then                           -- If CLOCK ENABLE is ACTIVE
  39.                     q <= d;                                 -- Assign INPUT value to the OUTPUT
  40.                 end if;
  41.             end if;
  42.         end if;
  43.     end process;
  44.  
  45. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment