Advertisement
Guest User

Untitled

a guest
May 21st, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.69 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.all;
  3. use IEEE.NUMERIC_STD.all;
  4.  
  5. entity RamCtrlUnit is
  6.    port(clk         : in  std_logic;
  7.         reset       : in  std_logic;
  8.         start       : in  std_logic;
  9.         busy        : out std_logic;
  10.         done        : out std_logic;
  11.           savedCount  : out std_logic_vector(1 downto 0));
  12. end RamCtrlUnit;
  13.  
  14.  
  15. architecture Behavioral of RamCtrlUnit is
  16.  
  17.    type TState is (ST_IDLE, ST_SAVE_1,
  18.                    ST_SAVE_2, ST_SAVE_3);
  19.                          
  20.    signal s_currentState, s_nextState : TState;
  21. begin
  22.     process(clk)
  23.     begin
  24.         if (rising_edge(clk)) then
  25.          if (reset = '1') then
  26.             s_currentState <= ST_IDLE;
  27.          else
  28.             s_currentState <= s_nextState;
  29.          end if;
  30.      end if;
  31.    end process;
  32.    
  33.     process(s_currentState, start)
  34.    begin
  35.       s_nextState <= s_currentState;
  36.  
  37.       case s_currentState is
  38.       when ST_IDLE =>
  39.          if (start = '1') then
  40.             s_nextState <= ST_SAVE_1;
  41.          end if;
  42.  
  43.       when ST_SAVE_1 =>
  44.          s_nextState <= ST_SAVE_2;
  45.  
  46.       when ST_SAVE_2 =>
  47.          s_nextState <= ST_SAVE_3;
  48.            
  49.         when ST_SAVE_3 =>
  50.          s_nextState <= ST_IDLE;
  51.       end case;
  52.        
  53.    end process;
  54.    
  55.     process(s_currentState)
  56.    begin
  57.       busy      <= '0';
  58.       done      <= '0';
  59.       savedCount <= "00";
  60.  
  61.       case s_currentState is
  62.       when ST_IDLE =>
  63.          done      <= '1';
  64.  
  65.       when ST_SAVE_1 =>
  66.          busy      <= '1';
  67.          savedCount  <= "01";
  68.  
  69.       when ST_SAVE_2 =>
  70.             busy      <= '1';
  71.          savedCount  <= "10";
  72.  
  73.       when ST_SAVE_3 =>
  74.             busy      <= '1';
  75.          savedCount  <= "11";
  76.       end case;
  77.    end process;
  78. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement