]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
*** empty log message ***
authorhadeshyp <hadeshyp>
Fri, 14 Sep 2007 15:14:11 +0000 (15:14 +0000)
committerhadeshyp <hadeshyp>
Fri, 14 Sep 2007 15:14:11 +0000 (15:14 +0000)
trb_net16_term_ibuf.vhd

index 282504f0132d04ee792e497469829014cf294c80..deb0737f3496a95b8077ab775303a2e6c5098bf9 100644 (file)
@@ -30,7 +30,7 @@ entity trb_net16_term_ibuf is
     INT_HEADER_IN:     in  std_logic; -- Concentrator kindly asks to resend the last header
     INT_DATAREADY_OUT: out std_logic;
     INT_DATA_OUT:      out std_logic_vector (15 downto 0); -- Data word
-    INT_PACKET_NUM_IN: in  std_logic_vector(1 downto 0);
+    INT_PACKET_NUM_OUT:out std_logic_vector(1 downto 0);
     INT_READ_IN:       in  std_logic;
     INT_ERROR_OUT:     out std_logic_vector (2 downto 0);  -- Status bits
     -- Status and control port
@@ -69,7 +69,139 @@ architecture trb_net16_term_ibuf_arch of trb_net16_term_ibuf is
       );
   end component;
 
-
+  signal got_ack_internal, reg_ack_internal : std_logic; --should be raised for 1 cycle when ack
+  signal is_locked, got_locked,release_locked : std_logic;
+  signal got_eob_out, reg_eob_out: std_logic;
+  signal sbuf_free, comb_next_read: std_logic;
+  signal tmp_INT_DATAREADY_OUT: std_logic;
+  signal tmp_INT_DATA_OUT: std_logic_vector(15 downto 0);
+  signal tmp_INT_PACKET_NUM_OUT: std_logic_vector(1 downto 0);
+  type ERROR_STATE is (IDLE, GOT_OVERFLOW_ERROR, GOT_LOCKED_ERROR, GOT_UNDEFINED_ERROR);
+  signal current_error_state, next_error_state : ERROR_STATE;
+  signal next_rec_buffer_size_out, current_rec_buffer_size_out  : std_logic_vector(3 downto 0);
+                                      -- buffer size control
 begin
 
+this process has to be converted to 16 Bit
+------------------------------------------
+
+
+-- -- this process controls the writing of the media into the fifo
+--     FILTER_DATAREADY_IN : process(MED_DATA_IN, MED_DATAREADY_IN, MED_ERROR_IN,
+--                                   is_locked, current_rec_buffer_size_out,
+--                                   current_error_state, release_locked,
+--                                   sbuf_free)
+--     begin  -- process
+--       got_ack_internal <=   '0';
+--       next_rec_buffer_size_out <= current_rec_buffer_size_out;
+--       next_error_state <= current_error_state;
+--       tmp_INT_DATA_OUT <= (others => '1');
+--       tmp_INT_DATAREADY_OUT <= '0';
+--       got_eob_out <= '0';
+--       got_locked  <= is_locked;
+--       
+--       if MED_DATAREADY_IN = '1' then    -- data word offered
+--         if MED_DATA_IN(TYPE_POSITION) = TYPE_ACK then
+--           got_ack_internal <=   '1';    
+--           if MED_DATA_IN(F1_POSITION) = F1_CHECK_ACK then
+--             next_rec_buffer_size_out <= MED_DATA_IN(BUFFER_SIZE_POSITION);
+--           end if;
+--         elsif MED_DATA_IN(TYPE_POSITION) = TYPE_TRM then
+--           got_eob_out <= '1';           --exactly when buffer is killed
+--           tmp_INT_DATA_OUT <= MED_DATA_IN;
+--           tmp_INT_DATAREADY_OUT <= '1';
+--           if release_locked = '0' then
+--             got_locked  <= '1';
+--           end if;
+--         elsif MED_DATA_IN(TYPE_POSITION) = TYPE_EOB then
+--           got_eob_out <= '1';
+--           tmp_INT_DATAREADY_OUT <= '0';
+--           -- this should happen only one CLK cycle
+--         elsif sbuf_free = '0' then
+--           next_error_state <= GOT_OVERFLOW_ERROR;
+--         elsif is_locked = '1' then
+--           next_error_state <= GOT_LOCKED_ERROR;
+--         end if;                         -- end TYPE
+--       end if;                           -- end MED_DATAREADY_IN             
+--     end process;
+-- 
+--     MED_READ_OUT <= '1';                -- I always can read
+--     
+-- reg_buffer: process(CLK)
+--     begin
+--     if rising_edge(CLK) then
+--       if RESET = '1' then
+--         current_rec_buffer_size_out <= (others => '0');
+--         reg_ack_internal    <= '0';
+--         current_error_state <= IDLE;
+--       elsif CLK_EN = '1' then
+--         current_rec_buffer_size_out <= next_rec_buffer_size_out;
+--         reg_ack_internal    <= got_ack_internal;
+--         current_error_state <= next_error_state;
+--       else
+--         current_rec_buffer_size_out <= current_rec_buffer_size_out;
+--         reg_ack_internal    <= reg_ack_internal;
+--         current_error_state <= current_error_state;
+--       end if;
+--     end if;
+--   end process;
+-- 
+-- 
+-- 
+  SBUF: trb_net16_sbuf
+    generic map (
+      DATA_WIDTH => 16,
+      NUM_WIDTH  => 2,
+      VERSION => 0
+      )
+    port map (
+      CLK                => CLK,
+      RESET              => RESET,
+      CLK_EN             => CLK_EN,
+      COMB_DATAREADY_IN  => tmp_INT_DATAREADY_OUT,
+      COMB_next_READ_OUT => comb_next_read,
+      COMB_READ_IN       => '1',
+      COMB_DATA_IN       => tmp_INT_DATA_OUT,
+      COMB_PACKET_NUM_IN => tmp_INT_PACKET_NUM_OUT,
+      SYN_DATAREADY_OUT  => INT_DATAREADY_OUT,
+      SYN_DATA_OUT       => INT_DATA_OUT,
+      SYN_PACKET_NUM_OUT => INT_PACKET_NUM_OUT,
+      SYN_READ_IN        => INT_READ_IN
+      );
+  sbuf_free <= comb_next_read or INT_READ_IN;  --sbuf killed
+  release_locked <= CTRL_LOCKED(0);
+  STAT_LOCKED(0) <= is_locked;
+  STAT_LOCKED(15 downto 1) <= (others => '0');
+
+  reg_locked: process(CLK)
+    begin
+      if rising_edge(CLK) then
+        if RESET = '1' then
+          is_locked <= '0';
+          reg_eob_out <= '0';
+        elsif CLK_EN = '1' then
+          if release_locked = '1' then
+            is_locked <= '0';
+          else
+            is_locked <= got_locked;
+          end if;
+          reg_eob_out <= got_eob_out;
+        else
+          is_locked <= is_locked;
+          reg_eob_out <= reg_eob_out;
+        end if;
+      end if;
+    end process;
+    
+-- make STAT_BUFFER
+  STAT_BUFFER(3 downto 0) <= "0111";    --always "biggest fifo"
+  STAT_BUFFER(7 downto 4) <= current_rec_buffer_size_out;
+  STAT_BUFFER(8) <= reg_eob_out;
+  STAT_BUFFER(9) <= reg_ack_internal;
+  STAT_BUFFER(11 downto 10) <= "00" when current_error_state = IDLE,
+                               "01" when current_error_state = GOT_OVERFLOW_ERROR,
+                               "10" when current_error_state = GOT_LOCKED_ERROR
+                               else "11";
+  STAT_BUFFER(31 downto 12) <= (others => '0');
+
 end architecture;
\ No newline at end of file