Line 4... |
Line 4... |
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- File : TxCont.vhd
|
-- File : TxCont.vhd
|
-- Author : Jamil Khatib (khatib@ieee.org)
|
-- Author : Jamil Khatib (khatib@ieee.org)
|
-- Organization: OpenIPCore Project
|
-- Organization: OpenIPCore Project
|
-- Created :2001/01/15
|
-- Created :2001/01/15
|
-- Last update: 2001/01/26
|
-- Last update: 2001/10/20
|
-- Platform :
|
-- Platform :
|
-- Simulators : Modelsim 5.3XE/Windows98
|
-- Simulators : Modelsim 5.3XE/Windows98
|
-- Synthesizers:
|
-- Synthesizers:
|
-- Target :
|
-- Target :
|
-- Dependency : ieee.std_logic_1164
|
-- Dependency : ieee.std_logic_1164
|
Line 32... |
Line 32... |
-- Desccription : Created
|
-- Desccription : Created
|
-- ToOptimize :
|
-- ToOptimize :
|
-- Bugs :
|
-- Bugs :
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
|
|
library ieee;
|
LIBRARY ieee;
|
use ieee.std_logic_1164.all;
|
USE ieee.std_logic_1164.ALL;
|
entity TxCont_ent is
|
ENTITY TxCont_ent IS
|
|
|
port (
|
PORT (
|
TXclk : in std_logic; -- TX clock
|
TXclk : IN STD_LOGIC; -- TX clock
|
rst_n : in std_logic; -- System Reset
|
rst_n : IN STD_LOGIC; -- System Reset
|
TXEN : in std_logic; -- TX enable
|
TXEN : IN STD_LOGIC; -- TX enable
|
enable : out std_logic; -- Enable control
|
enable : OUT STD_LOGIC; -- Enable control
|
BackendEnable : out std_logic; -- Backend Enable
|
BackendEnable : OUT STD_LOGIC; -- Backend Enable
|
abortedTrans : in std_logic; -- No Valid data from the backend
|
abortedTrans : IN STD_LOGIC; -- No Valid data from the backend
|
inProgress : in std_logic; -- Data in progress
|
inProgress : IN STD_LOGIC; -- Data in progress
|
ValidFrame : in std_logic; -- Valid Frame
|
ValidFrame : IN STD_LOGIC; -- Valid Frame
|
Frame : out std_logic; -- Frame strobe
|
Frame : OUT STD_LOGIC; -- Frame strobe
|
AbortFrame : in std_logic; -- AbortFrame
|
AbortFrame : IN STD_LOGIC; -- AbortFrame
|
AbortTrans : out std_logic); -- Abort data transmission
|
AbortTrans : OUT STD_LOGIC); -- Abort data transmission
|
|
|
end TxCont_ent;
|
END TxCont_ent;
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
architecture TxCont_beh of TxCont_ent is
|
ARCHITECTURE TxCont_beh OF TxCont_ent IS
|
|
|
begin -- TxCont_beh
|
BEGIN -- TxCont_beh
|
|
|
-- purpose: Abort Machine
|
-- purpose: Abort Machine
|
-- type : sequential
|
-- type : sequential
|
-- inputs : Txclk, rst_n
|
-- inputs : Txclk, rst_n
|
-- outputs:
|
-- outputs:
|
abort_proc : process (Txclk, rst_n)
|
abort_proc : PROCESS (Txclk, rst_n)
|
|
|
variable counter : integer range 0 to 14; -- Counter
|
VARIABLE counter : INTEGER RANGE 0 TO 14; -- Counter
|
|
|
variable state : std_logic; -- Internal State
|
VARIABLE state : STD_LOGIC; -- Internal State
|
-- state ==> '0' No abort signal
|
-- state ==> '0' No abort signal
|
-- state ==> '1' Abort signal
|
-- state ==> '1' Abort signal
|
begin -- process abort_proc
|
BEGIN -- process abort_proc
|
if rst_n = '0' then -- asynchronous reset (active low)
|
IF rst_n = '0' THEN -- asynchronous reset (active low)
|
AbortTrans <= '0';
|
AbortTrans <= '0';
|
Counter := 0;
|
Counter := 0;
|
enable <= '1';
|
enable <= '1';
|
state := '0';
|
state := '0';
|
elsif Txclk'event and Txclk = '1' then -- rising clock edge
|
ELSIF Txclk'event AND Txclk = '1' THEN -- rising clock edge
|
if TXEN = '1' then
|
IF TXEN = '1' THEN
|
|
|
case state is
|
CASE state IS
|
|
|
when '0' =>
|
WHEN '0' =>
|
if abortedTrans = '1' or AbortFrame = '1' then
|
IF abortedTrans = '1' OR AbortFrame = '1' THEN
|
state := '1';
|
state := '1';
|
Counter := 0;
|
Counter := 0;
|
end if;
|
END IF;
|
AbortTrans <= '0';
|
AbortTrans <= '0';
|
|
|
when '1' =>
|
WHEN '1' =>
|
if counter = 8 then
|
IF counter = 8 THEN
|
counter := 0;
|
counter := 0;
|
if abortedTrans = '0' and AbortFrame = '0' then
|
IF abortedTrans = '0' AND AbortFrame = '0' THEN
|
|
|
state := '0';
|
state := '0';
|
AbortTrans <= '0';
|
AbortTrans <= '0';
|
else
|
ELSE
|
AbortTrans <= '1';
|
AbortTrans <= '1';
|
end if;
|
END IF;
|
|
|
else
|
ELSE
|
counter := counter +1;
|
counter := counter +1;
|
end if; -- counter
|
END IF; -- counter
|
|
|
when others => null;
|
WHEN OTHERS => NULL;
|
|
|
end case;
|
END CASE;
|
end if; -- TXEN
|
END IF; -- TXEN
|
enable <= TXEN;
|
enable <= TXEN;
|
|
|
end if; -- TXclk
|
END IF; -- TXclk
|
end process abort_proc;
|
END PROCESS abort_proc;
|
|
|
-- purpose: Flag Controller
|
-- purpose: Flag Controller
|
-- type : sequential
|
-- type : sequential
|
-- inputs : Txclk, rst_n
|
-- inputs : Txclk, rst_n
|
-- outputs:
|
-- outputs:
|
Flag_proc : process (Txclk, rst_n)
|
Flag_proc : PROCESS (Txclk, rst_n)
|
|
|
variable state : std_logic_vector(2 downto 0); -- Internal State machine
|
VARIABLE state : STD_LOGIC_VECTOR(2 DOWNTO 0); -- Internal State machine
|
variable counter : integer range 0 to 16; -- Internal counter
|
VARIABLE counter : INTEGER RANGE 0 TO 16; -- Internal counter
|
|
|
begin -- process Flag_proc
|
BEGIN -- process Flag_proc
|
if rst_n = '0' then -- asynchronous reset (active low)
|
IF rst_n = '0' THEN -- asynchronous reset (active low)
|
Frame <= '0';
|
Frame <= '0';
|
state := (others => '0');
|
state := (OTHERS => '0');
|
counter := 0;
|
counter := 0;
|
BackendEnable <= '1';
|
BackendEnable <= '0';
|
elsif Txclk'event and Txclk = '1' then -- rising clock edge
|
ELSIF Txclk'event AND Txclk = '1' THEN -- rising clock edge
|
if TXEN = '1' then
|
IF TXEN = '1' THEN
|
|
|
case state is
|
CASE state IS
|
when "000" => -- Check Valid Frame
|
WHEN "000" => -- Check Valid Frame
|
Frame <= '0';
|
Frame <= '0';
|
if ValidFrame = '1' then
|
IF ValidFrame = '1' THEN
|
state := "001";
|
state := "001";
|
counter := 0;
|
|
end if;
|
|
BackendEnable <= '1';
|
BackendEnable <= '1';
|
|
ELSE
|
when "001" => -- Wait 16 clks before set internal frame
|
BackendEnable <= '0';
|
counter := counter + 1;
|
END IF;
|
|
|
if counter = 16 then
|
|
counter := 0;
|
counter := 0;
|
|
|
if inProgress = '0' then
|
WHEN "001" =>
|
|
|
|
IF counter > 1 AND inProgress = '0' THEN
|
state := "010";
|
state := "010";
|
Frame <= '1';
|
Frame <= '1';
|
else
|
ELSE
|
state := "101";
|
|
Frame <= '0';
|
|
end if;
|
|
else
|
|
Frame <= '0';
|
Frame <= '0';
|
end if;
|
END IF;
|
BackendEnable <= '1';
|
|
|
|
when "101" => -- Wait for inProgress
|
IF inProgress = '0' THEN
|
|
counter := counter +1;
|
|
END IF;
|
|
|
if inProgress = '0' then
|
|
state := "010";
|
|
Frame <= '1';
|
|
else
|
|
Frame <= '0';
|
|
end if;
|
|
BackendEnable <= '1';
|
BackendEnable <= '1';
|
|
|
when "010" => -- Check ValidFrame
|
WHEN "010" => -- Check ValidFrame
|
|
|
Frame <= '1';
|
Frame <= '1';
|
|
|
if ValidFrame = '0' then
|
IF ValidFrame = '0' THEN
|
state := "011";
|
state := "011";
|
counter := 0;
|
|
BackendEnable <= '0';
|
BackendEnable <= '0';
|
else
|
ELSE
|
BackendEnable <= '1';
|
BackendEnable <= '1';
|
end if;
|
END IF;
|
|
|
when "011" => -- wait 16 clk before trying to unset
|
|
-- internal frame
|
|
counter := counter + 1;
|
|
if counter = 16 then
|
|
counter := 0;
|
counter := 0;
|
if inProgress = '0' then
|
|
state := "000";
|
|
Frame <= '0';
|
|
else
|
|
state := "100";
|
|
Frame <= '1';
|
|
end if;
|
|
else
|
|
Frame <= '1';
|
|
end if;
|
|
|
|
BackendEnable <= '0';
|
|
|
|
when "100" =>
|
WHEN "011" =>
|
|
IF counter > 2 AND inProgress = '0' THEN
|
if inProgress = '0' then
|
|
state := "000";
|
state := "000";
|
Frame <= '0';
|
Frame <= '0';
|
else
|
ELSE
|
Frame <= '1';
|
Frame <= '1';
|
end if;
|
END IF;
|
|
|
|
IF inProgress = '0' THEN
|
|
counter := counter +1;
|
|
END IF;
|
|
|
BackendEnable <= '0';
|
BackendEnable <= '0';
|
|
|
when others => null;
|
WHEN OTHERS => NULL;
|
end case;
|
END CASE;
|
end if; -- TXEN
|
END IF; -- TXEN
|
end if;
|
END IF;
|
end process Flag_proc;
|
END PROCESS Flag_proc;
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
end TxCont_beh;
|
END TxCont_beh;
|
|
|
No newline at end of file
|
No newline at end of file
|