Advertisement
HimikoWerckmeister

Untitled

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