signal next_D18_READ_OUT, buf_D18_READ_OUT : std_logic;
signal next_D55_DATAREADY_OUT, buf_D55_DATAREADY_OUT : std_logic;
+signal next_dataread55, dataread55 : std_logic;
+ --data from 55 read and waiting to be written
-
-signal next_buf_D55_DATA_IN, buf_D55_DATA_IN : std_logic_vector(47 downto 0);
+signal next_buf_D55_DATA_IN, buf_D55_DATA_IN : std_logic_vector(55 downto 0);
signal next_D55_DATA_OUT, buf_D55_DATA_OUT : std_logic_vector(55 downto 0);
-
+ --databuffer for both directions
begin
-----------------------------------------------------------
--Direction 18 to 55
-----------------------------------------------------------
D55to18_fsm : process(buf_D18_DATA_OUT, buf_D18_PACKET_NUM_OUT, buf_D18_DATAREADY_OUT,
D18_READ_IN, D55_DATA_IN, D55_DATAREADY_IN, D55to18_state,
- buf_D55_READ_OUT, buf_D55_DATA_IN)
+ buf_D55_READ_OUT, buf_D55_DATA_IN, dataread55)
variable dataisread : std_logic;
begin
next_D18_DATA_OUT <= buf_D18_DATA_OUT;
next_D55to18_state <= D55to18_state;
next_D55_READ_OUT <= '0';
next_buf_D55_DATA_IN <= buf_D55_DATA_IN;
-
+ next_dataread55 <= dataread55;
if(D18_READ_IN = '1' AND buf_D18_DATAREADY_OUT = '1') then
dataisread := '1';
else
case D55to18_state is
when IDLE =>
- next_D55_READ_OUT <= '1';
- if(D55_DATAREADY_IN = '1' AND buf_D55_READ_OUT = '1') then
- next_buf_D55_DATA_IN(47 downto 0) <= D55_DATA_IN(47 downto 0);
+ --data available?
+ if (D55_DATAREADY_IN = '1' AND buf_D55_READ_OUT = '1') then
+ next_buf_D55_DATA_IN(55 downto 0) <= D55_DATA_IN(55 downto 0);
+ next_D55_READ_OUT <= '0';
+ --data available and ready to write
+ if (dataisread = '1' OR buf_D18_DATAREADY_OUT = '0') then
+ next_D18_DATA_OUT(7 downto 0) <= D55_DATA_IN(55 downto 48);
+ next_D18_DATA_OUT(15 downto 8) <= (others => '0');
+ next_D18_PACKET_NUM_OUT <= "00";
+ next_D18_DATAREADY_OUT <= '1';
+ next_D55to18_state <= FIRST;
+ --data available but not ready to write
+ else
+ next_dataread55 <= '1';
+ end if;
+ --data available before, now ready to write
+ elsif dataisread = '1' and dataread55 = '1' then
+ next_dataread55 <= '0';
next_D18_DATA_OUT(7 downto 0) <= D55_DATA_IN(55 downto 48);
next_D18_DATA_OUT(15 downto 8) <= (others => '0');
next_D18_PACKET_NUM_OUT <= "00";
next_D18_DATAREADY_OUT <= '1';
next_D55to18_state <= FIRST;
+ --no data available
+ else
+ next_buf_D55_DATA_IN(55 downto 0) <= (others => '0');
+ next_D55_READ_OUT <= '1';
end if;
+
when FIRST =>
if(dataisread = '1') then
next_D18_DATA_OUT(15 downto 0) <= buf_D55_DATA_IN(47 downto 32);
next_D18_DATA_OUT(15 downto 0) <= buf_D55_DATA_IN(15 downto 0);
next_D18_DATAREADY_OUT <= '1';
next_D18_PACKET_NUM_OUT <= "11";
- next_D55to18_state <= LAST;
- end if;
- when LAST =>
- if(dataisread = '1') then
- next_D18_DATA_OUT(15 downto 0) <= (others => '0');
- next_D18_DATAREADY_OUT <= '0';
next_D55to18_state <= IDLE;
- next_D18_PACKET_NUM_OUT <= "00";
next_D55_READ_OUT <= '1';
end if;
+ when LAST =>
+-- if(dataisread = '1') then
+-- next_D18_DATA_OUT(15 downto 0) <= (others => '0');
+-- next_D18_DATAREADY_OUT <= '0';
+ next_D55to18_state <= IDLE;
+-- next_D18_PACKET_NUM_OUT <= "00";
+-- next_D55_READ_OUT <= '1';
+-- end if;
end case;
-
end process;
D55to18_fsm_reg : process(CLK)
buf_D18_DATAREADY_OUT <= '0';
buf_D18_PACKET_NUM_OUT <= "00";
D55to18_state <= IDLE;
+ dataread55 <= '0';
else
buf_D18_DATA_OUT <= next_D18_DATA_OUT;
buf_D18_DATAREADY_OUT <= next_D18_DATAREADY_OUT;
buf_D55_DATA_IN <= next_buf_D55_DATA_IN;
buf_D18_PACKET_NUM_OUT <= next_D18_PACKET_NUM_OUT;
D55to18_state <= next_D55to18_state;
+ dataread55 <= next_dataread55;
end if;
else
buf_D18_DATA_OUT <= buf_D18_DATA_OUT;
buf_D55_DATA_IN <= buf_D55_DATA_IN;
buf_D18_PACKET_NUM_OUT <= buf_D18_PACKET_NUM_OUT;
D55to18_state <= D55to18_state;
+ dataread55 <= dataread55;
end if;
end process;
signal CLK_TRANS : std_logic;
signal fifo_data_in, next_fifo_data_in : std_logic_vector(17 downto 0);
---signal next_next_fifo_data_in : std_logic_vector(7 downto 0);
signal fifo_data_out : std_logic_vector(17 downto 0);
signal fifo_full_out, fifo_empty_out : std_logic;
signal fifo_status_out : std_logic_vector(3 downto 0);
signal fifo_write_enable, next_fifo_write_enable : std_logic;
signal fifo_read_enable, last_fifo_read_enable : std_logic;
---signal fifo_data_buffer : std_logic_vector(15 downto 0);
-signal packet_in_state : std_logic;
-
signal buf_MED_PARITY_OUT : std_logic;
signal buf_MED_CARRIER_OUT : std_logic;
buf_MED_CARRIER_OUT <= buf_MED_CARRIER_OUT;
end if;
end process;
-
+
+buf_MED_DATA_OUT(11 downto 8) <= "0000";
-----------------------------------------------------------------------
-- Output generation