From 83420367681b1cb958871b44771018577f93c734 Mon Sep 17 00:00:00 2001 From: hadeshyp Date: Mon, 30 Apr 2007 14:36:02 +0000 Subject: [PATCH] timing in trb_net_med_13bit_slow.vhd changed, Jan --- trb_net_med_13bit_slow.vhd | 87 ++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/trb_net_med_13bit_slow.vhd b/trb_net_med_13bit_slow.vhd index 943c956..f0c8b12 100755 --- a/trb_net_med_13bit_slow.vhd +++ b/trb_net_med_13bit_slow.vhd @@ -57,16 +57,15 @@ generic( 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; @@ -88,16 +87,17 @@ architecture trb_net_med_13bit_slow_arch of trb_net_med_13bit_slow is 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; @@ -135,6 +135,8 @@ gen_STAT_WORD: process(MED2INT_state,INT2MED_state,buf_INT_DATAREADY_OUT,RECV_ST 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 @@ -160,9 +162,11 @@ CTRL_reg: process (CLK,RESET) 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; @@ -256,7 +260,7 @@ transCLK_counter: process (this_TRCLK, last_TRCLK, CLK_counter, 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 @@ -281,6 +285,7 @@ begin 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 @@ -291,10 +296,13 @@ begin 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 @@ -360,15 +368,9 @@ begin 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"; @@ -386,6 +388,7 @@ INT2MED_fsm_reg: process(CLK,RESET) 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; @@ -394,6 +397,7 @@ INT2MED_fsm_reg: process(CLK,RESET) 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; @@ -402,6 +406,7 @@ INT2MED_fsm_reg: process(CLK,RESET) 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; @@ -427,15 +432,15 @@ MED2INT_fsm: process(MED_PARITY_IN,MED2INT_state,CLK,MED_DATA_IN,DAT_MED2INT, 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; @@ -488,27 +493,22 @@ MED2INT_fsm: process(MED_PARITY_IN,MED2INT_state,CLK,MED_DATA_IN,DAT_MED2INT, 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; @@ -523,18 +523,21 @@ MED2INT_fsm_reg: process(CLK,RESET) 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; -- 2.43.0