Line 52... |
Line 52... |
port (
|
port (
|
i_nReset : in std_logic;
|
i_nReset : in std_logic;
|
i_IFCLK : in std_logic; -- GPIF CLK (GPIF is Master and provides the clock)
|
i_IFCLK : in std_logic; -- GPIF CLK (GPIF is Master and provides the clock)
|
i_WRU : in std_logic; -- write from GPIF
|
i_WRU : in std_logic; -- write from GPIF
|
i_RDYU : in std_logic; -- GPIF is ready
|
i_RDYU : in std_logic; -- GPIF is ready
|
|
i_EOM : in std_logic; -- all data for X2U transfer is in FIFO
|
i_U2X_FULL : in std_logic;
|
i_U2X_FULL : in std_logic;
|
i_U2X_AM_FULL : in std_logic; -- signals for IN FIFO
|
i_U2X_AM_FULL : in std_logic; -- signals for IN FIFO
|
|
i_X2U_FULL_IFCLK : in std_logic;
|
i_X2U_AM_EMPTY : in std_logic;
|
i_X2U_AM_EMPTY : in std_logic;
|
i_X2U_EMPTY : in std_logic; -- signals for OUT FIFO
|
i_X2U_EMPTY : in std_logic; -- signals for OUT FIFO
|
o_bus_trans_dir : out std_logic;
|
o_bus_trans_dir : out std_logic;
|
o_U2X_WR_EN : out std_logic; -- signals for IN FIFO
|
o_U2X_WR_EN : out std_logic; -- signals for IN FIFO
|
o_X2U_RD_EN : out std_logic; -- signals for OUT FIFO
|
o_X2U_RD_EN : out std_logic; -- signals for OUT FIFO
|
Line 88... |
Line 90... |
signal s_bus_trans_dir : t_busAccess;
|
signal s_bus_trans_dir : t_busAccess;
|
|
|
|
|
type t_fsmState is (rst, idle, -- controll states
|
type t_fsmState is (rst, idle, -- controll states
|
inRQ, inACK, inWait, inTrans, inThrot,
|
inRQ, inACK, inWait, inTrans, inThrot,
|
inThrotBreak,inThrotBreak2, inThrotEnd, endInTrans, -- in com states
|
inThrotBreak,inThrotBreak2, inThrotEnd,
|
outRQ, outTrans, outWait, endOutTrans); -- out com states
|
endInTrans, -- in com states
|
|
outRQ, outTrans, outACK, outUSBwait, outFIFOwait,
|
|
endOutTrans); -- out com states
|
|
|
|
|
|
|
signal pr_state, nx_state : t_fsmState;
|
signal pr_state, nx_state : t_fsmState;
|
-- XST specific synthesize attributes
|
-- XST specific synthesize attributes
|
attribute safe_recovery_state of pr_state : signal is "idle";
|
attribute safe_recovery_state of pr_state : signal is "idle";
|
attribute safe_implementation of pr_state : signal is "yes";
|
attribute safe_implementation of pr_state : signal is "yes";
|
|
|
|
|
|
|
|
|
-- interconection signals
|
-- interconection signals
|
signal s_FIFOrst, s_RDYX, s_WRX, s_ABORT : std_logic;
|
signal s_FIFOrst, s_RDYX, s_WRX, s_ABORT : std_logic;
|
|
|
-- USB to Xilinx (U2X)
|
-- USB to Xilinx (U2X)
|
signal s_U2X_WR_EN : std_logic;
|
signal s_U2X_WR_EN : std_logic;
|
Line 140... |
Line 145... |
end if;
|
end if;
|
end process action;
|
end process action;
|
|
|
|
|
-- comb logic
|
-- comb logic
|
transaction : process(pr_state, i_WRU, i_RDYU, i_U2X_FULL,
|
transaction : process(pr_state, i_WRU, i_RDYU, i_U2X_FULL, i_U2X_AM_FULL,
|
i_U2X_AM_FULL, i_X2U_EMPTY)
|
i_X2U_EMPTY, i_X2U_FULL_IFCLK, i_EOM)
|
begin -- process transaction
|
begin -- process transaction
|
|
|
-- default signal values to avoid latches:
|
-- default signal values to avoid latches:
|
s_FIFOrst <= '0';
|
s_FIFOrst <= '0';
|
s_bus_trans_dir <= readFromGPIF;
|
s_bus_trans_dir <= readFromGPIF;
|
Line 169... |
Line 174... |
s_U2X_WR_EN <= '0';
|
s_U2X_WR_EN <= '0';
|
s_X2U_RD_EN <= '0';
|
s_X2U_RD_EN <= '0';
|
s_ABORT <= '1';
|
s_ABORT <= '1';
|
o_RX <= '0';
|
o_RX <= '0';
|
o_TX <= '0';
|
o_TX <= '0';
|
|
|
s_bus_trans_dir <= readFromGPIF;
|
s_bus_trans_dir <= readFromGPIF;
|
|
|
-- state decisions
|
-- state decisions
|
if i_WRU = '1' and i_RDYU = '1' then
|
if i_WRU = '1' and i_RDYU = '1' then
|
nx_state <= rst;
|
nx_state <= rst;
|
Line 193... |
Line 197... |
-- state decisions
|
-- state decisions
|
if i_WRU = '1' and i_RDYU = '1' then
|
if i_WRU = '1' and i_RDYU = '1' then
|
nx_state <= rst;
|
nx_state <= rst;
|
elsif i_WRU = '1' and i_RDYU = '0' then
|
elsif i_WRU = '1' and i_RDYU = '0' then
|
nx_state <= inRQ;
|
nx_state <= inRQ;
|
elsif i_WRU = '0' and i_X2U_EMPTY = '0' then
|
elsif i_WRU = '0' and
|
|
(i_X2U_FULL_IFCLK = '1' or i_EOM = '1') and i_X2U_EMPTY = '0' then
|
nx_state <= outRQ;
|
nx_state <= outRQ;
|
else
|
else
|
nx_state <= idle;
|
nx_state <= idle;
|
end if;
|
end if;
|
|
|
|
-----------------------------------------------------------------------
|
-- in trans
|
-- in trans
|
when inRQ =>
|
when inRQ =>
|
-- output signal values:
|
-- output signal values:
|
s_WRX <= '0';
|
s_WRX <= '0';
|
s_RDYX <= '0';
|
s_RDYX <= '0';
|
Line 255... |
Line 261... |
-- state decisions
|
-- state decisions
|
if i_WRU = '1' and i_RDYU = '1' then
|
if i_WRU = '1' and i_RDYU = '1' then
|
nx_state <= rst;
|
nx_state <= rst;
|
elsif i_WRU = '0' then
|
elsif i_WRU = '0' then
|
nx_state <= endInTrans;
|
nx_state <= endInTrans;
|
elsif i_U2X_FULL = '1' then
|
elsif i_U2X_AM_FULL = '1' then
|
nx_state <= inThrot;
|
nx_state <= inThrot;
|
else
|
else
|
nx_state <= inTrans;
|
nx_state <= inTrans;
|
end if;
|
end if;
|
|
|
Line 271... |
Line 277... |
o_RX <= '1';
|
o_RX <= '1';
|
|
|
-- state decisions
|
-- state decisions
|
if i_WRU = '1' and i_RDYU = '1' then
|
if i_WRU = '1' and i_RDYU = '1' then
|
nx_state <= rst;
|
nx_state <= rst;
|
elsif i_U2X_FULL = '0' then
|
elsif i_U2X_AM_FULL = '0' then
|
nx_state <= inThrotBreak;
|
nx_state <= inThrotBreak;
|
--nx_state <= inACK;
|
--nx_state <= inThrotEnd;
|
elsif i_WRU = '0' then
|
elsif i_WRU = '0' then
|
nx_state <= endInTrans;
|
nx_state <= endInTrans;
|
else
|
else
|
nx_state <= inThrot;
|
nx_state <= inThrot;
|
end if;
|
end if;
|
Line 327... |
Line 333... |
o_RX <= '0';
|
o_RX <= '0';
|
|
|
-- state decisions
|
-- state decisions
|
nx_state <= idle;
|
nx_state <= idle;
|
|
|
|
-----------------------------------------------------------------------
|
-- out trans
|
-- out trans
|
when outRQ =>
|
when outRQ =>
|
-- output signal values:
|
-- output signal values:
|
s_WRX <= '1';
|
s_WRX <= '1';
|
s_RDYX <= '0';
|
s_RDYX <= '0';
|
|
s_X2U_RD_EN <= '0';
|
|
|
-- state decisions
|
-- state decisions
|
if i_WRU = '1' and i_RDYU = '1' then
|
if i_WRU = '1' and i_RDYU = '1' then
|
nx_state <= rst;
|
nx_state <= rst;
|
elsif i_WRU = '1' and i_RDYU = '0' then
|
elsif i_WRU = '1' and i_RDYU = '0' then
|
nx_state <= inRQ;
|
nx_state <= inRQ;
|
elsif i_WRU = '0' and i_RDYU = '0' then -- vervollständigt, wenn ez-usb noch beschäfigt mit altem transfer
|
|
--s_X2U_RD_EN <= '1';
|
|
nx_state <= outTrans;
|
|
-- s_bus_trans_dir <= writeToGPIF;
|
|
else
|
else
|
nx_state <= outRQ;
|
nx_state <= outACK;
|
end if;
|
end if;
|
|
|
|
when outACK =>
|
|
-- output signal values:
|
|
s_WRX <= '1';
|
|
s_RDYX <= '0';
|
|
s_X2U_RD_EN <= '1';
|
|
o_TX <= '1';
|
|
|
|
-- state decisions
|
|
if i_WRU = '1' and i_RDYU = '1' then
|
|
nx_state <= rst;
|
|
elsif i_WRU = '0' and i_RDYU = '1' then
|
|
nx_state <= outTrans;
|
|
else
|
|
nx_state <= outUSBwait;
|
|
end if;
|
|
|
when outTrans =>
|
when outTrans =>
|
-- output signal values:
|
-- output signal values:
|
s_WRX <= '1';
|
s_WRX <= '1';
|
s_RDYX <= '0';
|
s_RDYX <= '0';
|
s_X2U_RD_EN <= '1';
|
s_X2U_RD_EN <= '1';
|
s_bus_trans_dir <= writeToGPIF;
|
|
o_TX <= '1';
|
o_TX <= '1';
|
|
s_bus_trans_dir <= writeToGPIF;
|
|
|
-- state decisions
|
-- state decisions
|
if i_WRU = '1' and i_RDYU = '1' then
|
if i_WRU = '1' and i_RDYU = '1' then
|
nx_state <= rst;
|
nx_state <= rst;
|
elsif i_X2U_EMPTY = '1' then
|
elsif i_X2U_EMPTY = '1' and i_EOM = '1' then
|
nx_state <= endOutTrans;
|
nx_state <= endOutTrans;
|
|
elsif i_X2U_EMPTY = '1' and i_EOM = '0' then
|
|
nx_state <= outFIFOwait;
|
elsif i_WRU = '0' and i_RDYU = '1' then
|
elsif i_WRU = '0' and i_RDYU = '1' then
|
nx_state <= outTrans;
|
nx_state <= outTrans;
|
else
|
else
|
--s_X2U_RD_EN <= '0'; -- to realise a wait case
|
nx_state <= outUSBwait;
|
nx_state <= outWait;
|
|
end if;
|
end if;
|
|
|
when outWait =>
|
when outUSBwait =>
|
-- output signal values:
|
-- output signal values:
|
s_WRX <= '1';
|
s_WRX <= '1';
|
s_RDYX <= '0';
|
s_RDYX <= '0';
|
s_X2U_RD_EN <= '0';
|
s_X2U_RD_EN <= '0';
|
o_TX <= '1';
|
o_TX <= '1';
|
Line 382... |
Line 401... |
if i_WRU = '1' and i_RDYU = '1' then
|
if i_WRU = '1' and i_RDYU = '1' then
|
nx_state <= rst;
|
nx_state <= rst;
|
elsif i_WRU = '0' and i_RDYU = '1' then
|
elsif i_WRU = '0' and i_RDYU = '1' then
|
nx_state <= outTrans;
|
nx_state <= outTrans;
|
else
|
else
|
nx_state <= outWait;
|
nx_state <= outUSBwait;
|
|
end if;
|
|
|
|
when outFIFOwait =>
|
|
-- output signal values:
|
|
s_WRX <= '1';
|
|
s_RDYX <= '1';
|
|
s_X2U_RD_EN <= '0';
|
|
o_TX <= '1';
|
|
s_bus_trans_dir <= writeToGPIF;
|
|
|
|
-- state decisions
|
|
if i_WRU = '1' and i_RDYU = '1' then
|
|
nx_state <= rst;
|
|
elsif i_X2U_EMPTY = '1' and i_EOM = '1' then
|
|
nx_state <= endOutTrans;
|
|
elsif i_X2U_EMPTY = '0' and i_EOM = '0' then
|
|
nx_state <= outTrans;
|
|
else
|
|
nx_state <= outFIFOwait;
|
end if;
|
end if;
|
|
|
when endOutTrans =>
|
when endOutTrans =>
|
-- output signal values:
|
-- output signal values:
|
s_RDYX <= '0';
|
s_RDYX <= '0';
|
s_WRX <= '1'; -- nötig um letzte 16bit an ez-usb zu schreiben
|
s_WRX <= '0';
|
s_X2U_RD_EN <= '1'; -- nötig da empyte flag schon beim ersten fifo zugriff auftaucht, zweite 16bit müssen noch gelesen werden
|
s_X2U_RD_EN <= '0';
|
s_bus_trans_dir <= writeToGPIF;
|
s_bus_trans_dir <= writeToGPIF;
|
|
|
-- state decisions
|
-- state decisions
|
|
if i_RDYU = '0' then
|
nx_state <= idle;
|
nx_state <= idle;
|
|
else
|
|
nx_state <= endOutTrans;
|
|
end if;
|
|
|
-- error case
|
-- error case
|
when others =>
|
when others =>
|
nx_state <= idle;
|
nx_state <= idle;
|
end case;
|
end case;
|