------------------------------------------------------------
-- Copyright: 2010 Integrated Sytems Laboratory, ETH Zurich
--            http://www.iis.ee.ethz.ch/~sha3
------------------------------------------------------------
library ieee;
use ieee.numeric_std.all;
use ieee.std_logic_1164.all;

entity JFSM is

  port (
    ClkxCI      : in  std_logic;
    RstxRBI     : in  std_logic;
    EnxEI       : in  std_logic;
    CntxDO      : out unsigned(7 downto 0);
    R36xSO      : out std_logic;
    SavexSO     : out std_logic;
    NewMsgxSO   : out std_logic;
    OutputEnxSO : out std_logic);

end JFSM;

architecture rtl of JFSM is

  type   state is (idle, round, check, output);
  signal StatexDP, StatexDN   : state;
  signal TENcntxDP, TENcntxDN : unsigned(7 downto 0);
  
begin  -- rtl

  p_fsm : process (EnxEI, StatexDP, TENcntxDP)
  begin  -- process p_fsm

    StatexDN    <= StatexDP;
    TENcntxDN   <= (others => '0');
    CntxDO      <= TENcntxDP;
    R36xSO      <= '0';
    SavexSO     <= '0';
    NewMsgxSO   <= '0';
    OutputEnxSO <= '0';

    case StatexDP is
      -------------------------------------------------------------------------
      when idle =>

        if EnxEI = '1' then
          NewMsgxSO <= '1';
          TENcntxDN <= to_unsigned(1, 8);
          StatexDN  <= round;
        end if;

        -------------------------------------------------------------------------
      when round =>
        
        if TENcntxDP = 35 then
          R36xSO   <= '1';
          StatexDN <= check;
        else
          if TENcntxDP < 35 then
            TENcntxDN <= TENcntxDP+1;
            StatexDN  <= round;
          else
            StatexDN <= idle;
          end if;
        end if;

        -------------------------------------------------------------------------
      when check =>
        
        if EnxEI = '1' then
          TENcntxDN <= to_unsigned(1, 8);
          StatexDN  <= round;
        else
          SavexSO  <= '1';
          StatexDN <= output;
        end if;
        -------------------------------------------------------------------------
      when output =>
        OutputEnxSO <= '1';
        StatexDN    <= idle;

        -------------------------------------------------------------------------
      when others => StatexDN <= idle;
                     
    end case;
    
  end process p_fsm;

  p_mem : process (ClkxCI, RstxRBI)
  begin  -- process p_mem
    if RstxRBI = '0' then               -- asynchronous reset (active low)
      StatexDP  <= idle;
      TENcntxDP <= (others => '0');
      
    elsif ClkxCI'event and ClkxCI = '1' then  -- rising clock edge
      StatexDP  <= StatexDN;
      TENcntxDP <= TENcntxDN;
      
    end if;
  end process p_mem;

end rtl;

Generated on Fri Sep 24 10:39:12 CEST 2010
Home