STAT: out STD_LOGIC_VECTOR (31 downto 0);
--STAT(0): Busy reading from media
--STAT(1): Busy writing to media
- --STAT(31 downto 24): Datain(63 downto 56
+ --STAT(31 downto 28): packets_in (mod 16)
+ --STAT(27 downto 24): packets_out (mod 16)
--STAT(11 downto 8): INT2MED state
--STAT(15 downto 12): MED2INT state
CTRL: in STD_LOGIC_VECTOR (31 downto 0)
--CTRL(24..31) -> lvds-data(63 downto 56) via lvds
--once for each packet
- --CTRL(16..18) -> debugbits updated every CLK
- --lvds(12 downto 10)(10bit-version only)
- --CTRL(0..5) -> lvds-data(69 downto 64) (10bit-version only)
+
);
end trb_net_med_13bit_slow;
signal my_error,next_my_error : std_logic_vector(2 downto 0);
signal fatal_error, media_not_connected : std_logic;
signal next_media_not_connected : std_logic;
- signal transmission_clk_Counter : std_logic_vector(1 downto 0);
- signal next_transmission_clk_Counter : std_logic_vector(1 downto 0);
+ signal transmission_clk_Counter : std_logic_vector(4 downto 0);
+ signal next_transmission_clk_Counter : std_logic_vector(4 downto 0);
signal TRANSMISSION_CLK, next_TRANSMISSION_CLK: std_logic;
signal buf_CTRL, next_STAT, buf_STAT : std_logic_vector(31 downto 0);
signal next_RECV_STAT, RECV_STAT : std_logic_vector(8 downto 0);
signal last_TRCLK, this_TRCLK: std_logic;
- signal CLK_counter,next_CLK_counter: std_logic_vector(4 downto 0);
-
+ signal CLK_counter,next_CLK_counter: std_logic_vector(7 downto 0);
+ signal packets_in_counter, next_packets_in_counter: std_logic_vector(3 downto 0);
+ signal packets_out_counter, next_packets_out_counter: std_logic_vector(3 downto 0);
begin
INT_DATAREADY_OUT <= buf_INT_DATAREADY_OUT;
end if;
next_STAT(11 downto 8) <= INT2MED_state;
next_STAT(15 downto 12) <= MED2INT_state;
+ next_STAT(31 downto 28) <= packets_in_counter;
+ next_STAT(27 downto 24) <= packets_out_counter;
if buf_INT_DATAREADY_OUT = '1' then
next_STAT(24 downto 16) <= RECV_STAT(8 downto 0);
else
begin
if RESET = '1' then
buf_CTRL <= (others => '0');
- elsif rising_edge(CLK) then
+ elsif rising_edge(CLK) then
buf_CTRL <= CTRL;
- else
+ buf_CTRL(31 downto 28) <= packets_in_counter;
+ buf_CTRL(27 downto 24) <= packets_out_counter;
+ else
buf_CTRL <= buf_CTRL;
end if;
end process;
next_media_not_connected <= '0';
if last_TRCLK = '0' and this_TRCLK = '1' then
next_CLK_counter <= (others => '0');
- elsif CLK_counter = 31 then
+ elsif CLK_counter = 255 then
next_media_not_connected <= '1';
next_CLK_counter <= CLK_counter;
else
next_buf_INT_DATA_IN <= buf_INT_DATA_IN;
next_buf_INT_READ_OUT <= '0';
next_MED_TRANSMISSION_CLK_OUT <= TRANSMISSION_CLK;
+ next_packets_out_counter <= packets_out_counter;
case INT2MED_state is
when "0000" =>
if INT_DATAREADY_IN = '1' and TRANSMISSION_CLK = '0' then
next_buf_MED_DATA_OUT(12 downto 0) <= INT_DATA_IN(12 downto 0);
next_MED_CARRIER_OUT <= '1';
next_MED_PARITY_OUT <= '1';
+ next_packets_out_counter <= packets_out_counter + 1;
else
- next_buf_MED_DATA_OUT(12 downto 0) <= (others => '0');
- next_MED_CARRIER_OUT <= '0';
- next_MED_PARITY_OUT <= '0';
+ if TRANSMISSION_CLK = '0' then
+ next_MED_CARRIER_OUT <= '0';
+ next_buf_MED_DATA_OUT(12 downto 0) <= (others => '0');
+ next_MED_PARITY_OUT <= '0';
+ end if;
end if;
when "0001" =>
if TRANSMISSION_CLK = '1' then
end if;
when "1101" =>
if TRANSMISSION_CLK = '1' then
- next_INT2MED_state <= "1110";
- else
- next_INT2MED_state <= "1101";
- end if;
- when "1110" =>
- if TRANSMISSION_CLK = '0' then
next_INT2MED_state <= "0000";
- else
- next_INT2MED_state <= "1110";
+ else
+ next_INT2MED_state <= "1101";
end if;
when others =>
next_INT2MED_state <= "0000";
buf_MED_CARRIER_OUT <= '0';
buf_MED_PARITY_OUT <= '0';
buf_MED_TRANSMISSION_CLK_OUT <= '0';
+ packets_out_counter <= (others => '0');
elsif rising_edge(CLK) then
INT2MED_state <= next_INT2MED_state;
buf_MED_TRANSMISSION_CLK_OUT <= next_MED_TRANSMISSION_CLK_OUT;
buf_MED_DATA_OUT(12 downto 0) <= next_buf_MED_DATA_OUT(12 downto 0);
buf_MED_CARRIER_OUT <= next_MED_CARRIER_OUT;
buf_MED_PARITY_OUT <= next_MED_PARITY_OUT;
+ packets_out_counter <= next_packets_out_counter;
else
buf_MED_TRANSMISSION_CLK_OUT <= buf_MED_TRANSMISSION_CLK_OUT;
buf_MED_DATA_OUT <= buf_MED_DATA_OUT;
INT2MED_state <= INT2MED_state;
buf_INT_READ_OUT <= buf_INT_READ_OUT;
buf_INT_DATA_IN <= buf_INT_DATA_IN;
+ packets_out_counter <= packets_out_counter;
end if;
end process;
media_not_connected,buf_INT_DATAREADY_OUT, buf_INT_DATA_OUT)
begin
next_DAT_MED2INT (64 downto 0) <= DAT_MED2INT (64 downto 0);
- next_INT_DATA_OUT <= (others => '0');
- next_INT_DATAREADY_OUT <= '0';
+ next_INT_DATA_OUT <= buf_INT_DATA_OUT;
+ next_INT_DATAREADY_OUT <= buf_INT_DATAREADY_OUT;
next_MED2INT_state <= "0000";
next_RECV_STAT <= RECV_STAT;
+ next_packets_in_counter <= packets_in_counter;
case MED2INT_state is
when "0000" =>
- next_INT_DATAREADY_OUT <= '0';
if MED_TRANSMISSION_CLK_IN = '1' and MED_CARRIER_IN = '1'
- and MED_PARITY_IN = '1' then
+ and MED_PARITY_IN = '1' then
next_MED2INT_state <= "1001";
next_DAT_MED2INT(12 downto 0) <= MED_DATA_IN(12 downto 0);
end if;
if MED_TRANSMISSION_CLK_IN = '1' and MED_CARRIER_IN = '1' then
next_MED2INT_state <= "0110";
next_DAT_MED2INT(64 downto 52) <= MED_DATA_IN(12 downto 0);
+ next_INT_DATA_OUT(51 downto 0) <= DAT_MED2INT(51 downto 0);
+ next_INT_DATA_OUT(55 downto 52) <= MED_DATA_IN(3 downto 0);
+ next_RECV_STAT <= MED_DATA_IN(12 downto 4);
+ next_INT_DATAREADY_OUT <= '1';
+ next_MED2INT_state <= "0000";
+ next_packets_in_counter <= packets_in_counter + 1;
else
next_MED2INT_state <= "0100";
end if;
- when "0110" =>
- next_INT_DATA_OUT <= DAT_MED2INT(55 downto 0);
- next_RECV_STAT <= DAT_MED2INT(64 downto 56);
- next_INT_DATAREADY_OUT <= '1';
- next_MED2INT_state <= "0111";
- when "0111" =>
- if buf_INT_DATAREADY_OUT = '1' and INT_READ_IN = '1' then
- next_MED2INT_state <= "0000";
- next_INT_DATAREADY_OUT <= '0';
- next_INT_DATA_OUT <= (others => '0');
- else
- next_MED2INT_state <= "0111";
- next_INT_DATAREADY_OUT <= '1';
- next_INT_DATA_OUT <= buf_INT_DATA_OUT;
- end if;
- when others =>
+ when others =>
next_MED2INT_state <= "0000";
end case;
+ if buf_INT_DATAREADY_OUT = '1' and INT_READ_IN = '1' then
+ next_INT_DATAREADY_OUT <= '0';
+ next_INT_DATA_OUT <= (others => '0');
+ end if;
if media_not_connected = '1' then
next_MED2INT_state <= "0000";
end if;
DAT_MED2INT <= (others => '0');
buf_INT_DATA_OUT <= (others => '0');
RECV_STAT <= (others => '0');
+ packets_in_counter <= (others => '0');
elsif rising_edge(CLK) then
DAT_MED2INT <= next_DAT_MED2INT;
MED2INT_state <= next_MED2INT_state;
buf_INT_DATA_OUT <= next_INT_DATA_OUT;
buf_INT_DATAREADY_OUT <= next_INT_DATAREADY_OUT;
RECV_STAT <= next_RECV_STAT;
+ packets_in_counter <= next_packets_in_counter;
else
buf_INT_DATA_OUT <= buf_INT_DATA_OUT;
MED2INT_state <= MED2INT_state;
buf_INT_DATAREADY_OUT <= buf_INT_DATAREADY_OUT;
DAT_MED2INT <= DAT_MED2INT;
RECV_STAT <= RECV_STAT;
+ packets_in_counter <= packets_in_counter;
end if;
end process;