Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as VHDL by Mal ( 14 years ago )
entity genFrame is
    Port ( Clk : in  STD_LOGIC;
           DI : in  STD_LOGIC_VECTOR (7 downto 0);
           Ready : in  STD_LOGIC;
     Reset : in  STD_LOGIC;
           DO : out  STD_LOGIC_VECTOR (7 downto 0) := x"00";
           DO_Rdy : out  STD_LOGIC := '1';
     Send : out STD_LOGIC := '0');
end genFrame;

architecture Behavioral of genFrame is

type state_type is( sIdle, sReset, sSign, sPreamble, sSFD, sEoF, sSend, sSent );
type state_type2 is( sSign, sPreamble, sSFD, sEoF );
signal state, nextState : state_type;
signal sPomocniczy : state_type2;
signal sign : STD_LOGIC_VECTOR (7 downto 0);
signal buff : STD_LOGIC_VECTOR (7 downto 0);

begin
 process ( Clk, Reset )
 begin
  if Reset = '1' then
   state <= sReset;
  elsif rising_edge( Clk ) then
   state <= nextState;
  end if;
 end process;

 process (state, Ready, Clk)
 variable licznik : integer;
 begin
  case state is
   when sReset =>
    buff <= x"00";
    licznik := 0;
    nextState <= sIdle;
   
   when sIdle =>
    if Ready = '0' then
     nextState <= sIdle;
    else
     sign <= DI;
     nextState <= sPreamble;     
    end if;
   
   when sPreamble =>
    buff <= x"55";
    licznik := 0;
    sPomocniczy <= sPreamble;
    nextState <= sSend;
   
   when sSFD =>
    buff <= x"D5";
    sPomocniczy <= sSFD;
    nextState <= sSend;

   when sSign =>
    buff <= sign;
    sPomocniczy <= sSign;
    nextState <= sSend;
   
   when sEoF =>
    buff <= x"AF";
    sPomocniczy <= sEoF;
    nextState <= sSend;
    
   when sSend =>
    DO <= buff;
    case sPomocniczy is
     when sPreamble =>
--      if rising_edge ( clk ) then 
       licznik := licznik + 1;
--      end if;
      if licznik < 12 then
       nextState <= sSend;
      else
       nextState <= sSFD;
      end if;
     when sSFD =>
      nextState <= sSign;
     when sSign =>
      nextState <= sEoF;
     when sEoF =>
      nextState <= sSent;
      
    end case;        
   
   when sSent =>
    buff <= x"00";
    DO <= buff;
    nextState <= sIdle;
  end case;
 end process;

 Send <= '1' when state = sSend or state = sSent else '0';
 DO_Rdy <='0' when state /= sSent else '1'; 
 
end Behavioral;

 

Revise this Paste

Your Name: Code Language: