Advertisement
HimikoWerckmeister

Untitled

Mar 31st, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.15 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.std_logic_1164.all;
  3. use IEEE.std_logic_arith.all;
  4.  
  5. entity CAMReg is
  6.     port ( data: in std_logic_vector(3 downto 0);
  7.             ld: in std_logic;
  8.             rd: in std_logic;
  9.             rdy: out std_logic;
  10.             mbit: out boolean);
  11. end CAMReg;
  12.  
  13. architecture behav of CAMReg is
  14.     type states is (STO, WT, RET);
  15.    
  16.     signal newstates;
  17. begin
  18.  
  19.     -- State transition process
  20.    
  21.     process is
  22.         variable currentstate: states := RET;
  23.     begin
  24.         if clk = '1'
  25.             case currentstate is
  26.                 when STO =>
  27.                     currentstate := WT;
  28.                 when WT =>
  29.                     if not((ld = '1') and (rd = '1')) then
  30.                         currentstate := WT;
  31.                     end if
  32.                    
  33.                     if ((ld = '1') and (rd = '1')) then
  34.                         currentstate := RET;
  35.                     end if;
  36.            
  37.                 when RET =>
  38.                     currentstate := WT
  39.             end case;
  40.         end if;
  41.         newstates <= currentstate;
  42.     wait on clk;
  43.     begin
  44.     end process;
  45.    
  46. -- Asserted outputs process
  47.     process is
  48.         variable REG: std_logic_vector(3 downto 0);
  49.         case newstates is
  50.             when STO =>
  51.                 REG := data;
  52.             when WT =>
  53.                 rdy <= '1';
  54.                 mbit <= '1';
  55.             when RET =>
  56.                 mbit <= (REG = data);
  57.         end case;
  58.     wait on newstates;
  59.     end process;
  60.        
  61. end behav;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement