]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
*** empty log message ***
authorhadeshyp <hadeshyp>
Sun, 16 Mar 2008 22:40:07 +0000 (22:40 +0000)
committerhadeshyp <hadeshyp>
Sun, 16 Mar 2008 22:40:07 +0000 (22:40 +0000)
testbench/trb_net16_dummy_apl.vhd
trb_net16_ibuf.vhd
trb_net16_iobuf.vhd
trb_net16_obuf.vhd
trb_net16_obuf_nodata.vhd

index a216298b62aebe0043726c329951e71cbc04f233..1ce0a85dfe040d9853523012d5b26522060e935c 100644 (file)
@@ -8,6 +8,7 @@ USE IEEE.std_logic_1164.ALL;
 USE IEEE.std_logic_ARITH.ALL;
 USE IEEE.std_logic_UNSIGNED.ALL;
 
+library work;
 use work.trb_net_std.all;
 
 
index 9abaff1cd49be7c34c6f3ffb7ed9b37fa9b51097..e9c3da3fa9c32aa724181b470cab9a29fce5feca 100644 (file)
@@ -11,11 +11,11 @@ use work.trb_net_std.all;
 
 entity trb_net16_ibuf is
   generic (
-    DEPTH            : integer range 0 to 7 := c_FIFO_SMALL;
+    DEPTH            : integer range 0 to 7 := c_FIFO_BRAM;
     USE_VENDOR_CORES : integer range 0 to 1 := c_YES;
     USE_ACKNOWLEDGE  : integer range 0 to 1 := std_USE_ACKNOWLEDGE;
     SBUF_VERSION     : integer range 0 to 1 := std_SBUF_VERSION;
-    SECURE_MODE      : integer range 0 to 1 := c_NO
+    SECURE_MODE      : integer range 0 to 1 := c_YES
                  --use sbuf in med_to_api direction?
     );
   port(
@@ -24,22 +24,23 @@ entity trb_net16_ibuf is
     RESET  : in std_logic;     
     CLK_EN : in std_logic;
     --  Media direction port
-    MED_DATAREADY_IN:  in  std_logic; -- Data word is offered by the Media (the IOBUF MUST read)
-    MED_DATA_IN:       in  std_logic_vector (c_DATA_WIDTH-1 downto 0); -- Data word
-    MED_PACKET_NUM_IN :in  std_logic_vector(c_NUM_WIDTH-1 downto 0);
-    MED_READ_OUT:      out std_logic; -- buffer reads a word from media
-    MED_ERROR_IN:      in  std_logic_vector (2 downto 0);  -- Status bits
+    MED_DATAREADY_IN        : in  std_logic;
+    MED_DATA_IN             : in  std_logic_vector (c_DATA_WIDTH-1 downto 0);
+    MED_PACKET_NUM_IN       : in  std_logic_vector(c_NUM_WIDTH-1 downto 0);
+    MED_READ_OUT            : out std_logic;
+    MED_ERROR_IN            : in  std_logic_vector (2 downto 0);
     -- Internal direction port
-    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 (c_DATA_WIDTH-1 downto 0); -- Data word
-    INT_PACKET_NUM_OUT:out  std_logic_vector(c_NUM_WIDTH-1 downto 0);
-    INT_READ_IN:       in  std_logic;
-    INT_ERROR_OUT:     out std_logic_vector (2 downto 0);  -- Status bits
+    INT_INIT_DATA_OUT       : out std_logic_vector (c_DATA_WIDTH-1 downto 0);
+    INT_INIT_PACKET_NUM_OUT : out std_logic_vector(c_NUM_WIDTH-1 downto 0);
+    INT_INIT_DATAREADY_OUT  : out std_logic;
+    INT_INIT_READ_IN        : in  std_logic;
+    INT_REPLY_DATA_OUT      : out std_logic_vector (c_DATA_WIDTH-1 downto 0);
+    INT_REPLY_PACKET_NUM_OUT: out std_logic_vector(c_NUM_WIDTH-1 downto 0);
+    INT_REPLY_DATAREADY_OUT : out std_logic;
+    INT_REPLY_READ_IN       : in  std_logic;
+    INT_ERROR_OUT           : out std_logic_vector (2 downto 0);
     -- Status and control port
-    STAT_LOCKED:       out std_logic_vector (15 downto 0);
-    CTRL_LOCKED:       in  std_logic_vector (15 downto 0);
-    STAT_BUFFER:       out std_logic_vector (31 downto 0)
+    STAT_BUFFER             : out std_logic_vector (31 downto 0)
     );
 end entity;
 
@@ -54,13 +55,13 @@ architecture trb_net16_ibuf_arch of trb_net16_ibuf is
       CLK    : in std_logic;
       RESET  : in std_logic;
       CLK_EN : in std_logic;
-      DATA_IN         : in  std_logic_vector(c_DATA_WIDTH - 1 downto 0);  -- Input data
-      PACKET_NUM_IN   : in  std_logic_vector(c_NUM_WIDTH - 1 downto 0);  -- Input data
+      DATA_IN         : in  std_logic_vector(c_DATA_WIDTH - 1 downto 0);
+      PACKET_NUM_IN   : in  std_logic_vector(c_NUM_WIDTH - 1 downto 0); 
       WRITE_ENABLE_IN : in  std_logic;
-      DATA_OUT        : out std_logic_vector(c_DATA_WIDTH - 1 downto 0);  -- Output data
-      PACKET_NUM_OUT  : out std_logic_vector(c_NUM_WIDTH - 1 downto 0);  -- Input data
+      DATA_OUT        : out std_logic_vector(c_DATA_WIDTH - 1 downto 0);
+      PACKET_NUM_OUT  : out std_logic_vector(c_NUM_WIDTH - 1 downto 0); 
       READ_ENABLE_IN  : in  std_logic;
-      FULL_OUT        : out std_logic;         -- Full Flag
+      FULL_OUT        : out std_logic;
       EMPTY_OUT       : out std_logic;
       DEPTH_OUT       : out std_logic_vector(7 downto 0)
       );
@@ -99,31 +100,32 @@ architecture trb_net16_ibuf_arch of trb_net16_ibuf is
   signal fifo_full, fifo_empty : std_logic;
   signal fifo_depth            : std_logic_vector(7 downto 0);
 
-  signal current_packet_type   : std_logic_vector(2 downto 0);
-  signal saved_packet_type     : std_logic_vector(2 downto 0);
-  signal current_fifo_packet_type   : std_logic_vector(2 downto 0);
-  signal saved_fifo_packet_type     : std_logic_vector(2 downto 0);
+  signal current_packet_type   : std_logic_vector(3 downto 0);
+  signal saved_packet_type     : std_logic_vector(3 downto 0);
+  signal current_fifo_packet_type   : std_logic_vector(3 downto 0);
+  signal saved_fifo_packet_type     : std_logic_vector(3 downto 0);
   
 
   signal next_read_out, reg_read_out : std_logic;
-  signal got_ack_internal, reg_ack_internal : std_logic;    --should be raised for 1 cycle when ack
-                                          --arrived
-  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 got_ack_init_internal, reg_ack_init_internal : std_logic; 
+  signal got_ack_reply_internal, reg_ack_reply_internal : std_logic; 
+  signal got_eob_init_out, reg_eob_init_out: std_logic;
+  signal got_eob_reply_out, reg_eob_reply_out: std_logic;
+  signal sbuf_init_free, comb_next_init_read: std_logic;
+  signal sbuf_reply_free, comb_next_reply_read: std_logic;
+  signal tmp_INT_INIT_DATAREADY_OUT: std_logic;
+  signal tmp_INT_REPLY_DATAREADY_OUT: std_logic;
   signal tmp_INT_DATA_OUT: std_logic_vector(c_DATA_WIDTH-1 downto 0);
   signal tmp_INT_PACKET_NUM_OUT: std_logic_vector(c_NUM_WIDTH-1 downto 0);
-  signal current_last_header, next_last_header : std_logic_vector(47 downto 0);
-                           --last_header does not contain the TYPE_HDR, only packets 1 to 3 are stored.
   signal current_last_header_F1, current_last_header_F2, current_last_header_F3 : std_logic_vector(15 downto 0);
   signal next_last_header_F1, next_last_header_F2, next_last_header_F3 : std_logic_vector(15 downto 0);
   signal reading_header : std_logic;
   
-  type ERROR_STATE is (IDLE, GOT_OVERFLOW_ERROR, GOT_LOCKED_ERROR, GOT_UNDEFINED_ERROR);
+  type ERROR_STATE is (IDLE, GOT_OVERFLOW_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);
-  signal buf_INT_DATAREADY_OUT : std_logic;
+  signal buf_INT_INIT_DATAREADY_OUT : std_logic;
+  signal buf_INT_REPLY_DATAREADY_OUT : std_logic;
 
   signal last_fifo_read : std_logic;
   signal throw_away : std_logic;
@@ -155,15 +157,15 @@ begin
   fifo_packet_num_in  <= MED_PACKET_NUM_IN;
 
 ------------------------
---save the current packet type
+--save the current packet type (including init/reply channel)
 ------------------------
   process(CLK)
     begin
       if rising_edge(CLK) then
         if RESET = '1' then
-          saved_packet_type <= TYPE_ILLEGAL;
+          saved_packet_type <= '1' & TYPE_ILLEGAL;
         elsif MED_PACKET_NUM_IN = "00" then
-          saved_packet_type <= MED_DATA_IN(2 downto 0);
+          saved_packet_type <= MED_DATA_IN(3 downto 0);
         end if;
       end if;
     end process;
@@ -172,39 +174,41 @@ begin
     begin
       if rising_edge(CLK) then
         if RESET = '1' or fifo_packet_num_out = "11" then
-          saved_fifo_packet_type <= TYPE_ILLEGAL;
+          saved_fifo_packet_type <= '1' & TYPE_ILLEGAL;
         elsif fifo_packet_num_out = "00" then
-          saved_fifo_packet_type <= fifo_data_out(2 downto 0);
+          saved_fifo_packet_type <= fifo_data_out(3 downto 0);
         end if;
       end if;
     end process;
   --create comb. real packet type
-  current_packet_type <= MED_DATA_IN(2 downto 0) when (MED_PACKET_NUM_IN = "00") 
+  current_packet_type <= MED_DATA_IN(3 downto 0) when (MED_PACKET_NUM_IN = "00") 
                          else saved_packet_type;
-  current_fifo_packet_type <= fifo_data_out(2 downto 0) when (fifo_packet_num_out = "00")
+  current_fifo_packet_type <= fifo_data_out(3 downto 0) when (fifo_packet_num_out = "00")
                               else saved_fifo_packet_type;
 
 ------------------------
 --control incoming data
 ------------------------
-  FILTER_DATAREADY_IN : process(MED_DATA_IN, MED_DATAREADY_IN, MED_ERROR_IN, MED_PACKET_NUM_IN,
-                                  fifo_full, is_locked, current_rec_buffer_size_out,
-                                  current_error_state, reg_read_out, current_packet_type)
+  FILTER_DATA_IN : process(MED_DATA_IN, MED_DATAREADY_IN, MED_ERROR_IN, MED_PACKET_NUM_IN,
+                           fifo_full, current_rec_buffer_size_out,
+                           current_error_state, reg_read_out, current_packet_type)
     begin  -- process
-      got_ack_internal <=   '0';
+      got_ack_init_internal <=   '0';
+      got_ack_reply_internal <=   '0';
       next_read_out <= not fifo_full;
       fifo_write <=  '0';
       next_rec_buffer_size_out <= current_rec_buffer_size_out;
       next_error_state <= current_error_state;
       if MED_DATAREADY_IN = '1' and reg_read_out= '1' then
-        if current_packet_type = TYPE_ACK and USE_ACKNOWLEDGE = 1 then
+        if current_packet_type(2 downto 0) = TYPE_ACK and USE_ACKNOWLEDGE = 1 then
           if MED_PACKET_NUM_IN = "00" and current_error_state /= GOT_OVERFLOW_ERROR then
-            got_ack_internal <=   '1';
+            got_ack_init_internal <= not current_packet_type(3);
+            got_ack_reply_internal <=    current_packet_type(3);
           end if;
           if MED_PACKET_NUM_IN = "10" then
             next_rec_buffer_size_out <= MED_DATA_IN(3 downto 0);
           end if;
-        elsif not (current_packet_type = TYPE_ILLEGAL) then
+        elsif not (current_packet_type(2 downto 0) = TYPE_ILLEGAL) then
           fifo_write <=  '1';
           if fifo_full = '1' then
             next_error_state <= GOT_OVERFLOW_ERROR;
@@ -220,12 +224,14 @@ begin
     if rising_edge(CLK) then
       if RESET = '1' then
         current_rec_buffer_size_out <= (others => '0');
-        reg_ack_internal    <= '0';
+        reg_ack_init_internal    <= '0';
+        reg_ack_reply_internal   <= '0';
         reg_read_out        <= '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;
+        reg_ack_init_internal    <= got_ack_init_internal;
+        reg_ack_reply_internal   <= got_ack_reply_internal;
         reg_read_out        <= next_read_out;
         current_error_state <= next_error_state;
       end if;
@@ -236,7 +242,7 @@ begin
 --generate output logic
 ------------------------
   gensecure : if SECURE_MODE = 1 generate
-    SBUF: trb_net16_sbuf
+    SBUF_INIT: trb_net16_sbuf
       generic map (
         Version => SBUF_VERSION
         )
@@ -244,60 +250,85 @@ begin
         CLK   => CLK,
         RESET  => RESET,
         CLK_EN => CLK_EN,
-        COMB_DATAREADY_IN => tmp_INT_DATAREADY_OUT,
-        COMB_next_READ_OUT => comb_next_read,
+        COMB_DATAREADY_IN => tmp_INT_INIT_DATAREADY_OUT,
+        COMB_next_READ_OUT => comb_next_init_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
+        SYN_DATAREADY_OUT => INT_INIT_DATAREADY_OUT,
+        SYN_DATA_OUT => INT_INIT_DATA_OUT,
+        SYN_PACKET_NUM_OUT => INT_INIT_PACKET_NUM_OUT,
+        SYN_READ_IN => INT_INIT_READ_IN
         );
-
+    SBUF_REPLY: trb_net16_sbuf
+      generic map (
+        Version => SBUF_VERSION
+        )
+      port map (
+        CLK   => CLK,
+        RESET  => RESET,
+        CLK_EN => CLK_EN,
+        COMB_DATAREADY_IN => tmp_INT_REPLY_DATAREADY_OUT,
+        COMB_next_READ_OUT => comb_next_reply_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_REPLY_DATAREADY_OUT,
+        SYN_DATA_OUT => INT_REPLY_DATA_OUT,
+        SYN_PACKET_NUM_OUT => INT_REPLY_PACKET_NUM_OUT,
+        SYN_READ_IN => INT_REPLY_READ_IN
+        );
+        
     process(CLK)
       begin
         if rising_edge(CLK) then
-          sbuf_free <= comb_next_read;
+          sbuf_init_free <= comb_next_init_read;
+          sbuf_reply_free <= comb_next_reply_read;
         end if;
       end process;
   end generate;
   gen_notsecure : if SECURE_MODE = 0 generate
-   INT_DATA_OUT <= tmp_INT_DATA_OUT;
-   INT_DATAREADY_OUT <= tmp_INT_DATAREADY_OUT;
-   INT_PACKET_NUM_OUT <= tmp_INT_PACKET_NUM_OUT;
-   sbuf_free <= '1';
+   INT_INIT_DATA_OUT <= tmp_INT_DATA_OUT;
+   INT_INIT_PACKET_NUM_OUT <= tmp_INT_PACKET_NUM_OUT;
+   INT_INIT_DATAREADY_OUT <= tmp_INT_INIT_DATAREADY_OUT;
+   sbuf_INIT_free <= '1';
+   INT_REPLY_DATA_OUT <= tmp_INT_DATA_OUT;
+   INT_REPLY_PACKET_NUM_OUT <= tmp_INT_PACKET_NUM_OUT;
+   INT_REPLY_DATAREADY_OUT <= tmp_INT_REPLY_DATAREADY_OUT;
+   sbuf_REPLY_free <= '1';
   end generate;
 
 
-  process(fifo_data_out, fifo_packet_num_out, is_locked, sbuf_free, fifo_empty, last_fifo_read, current_fifo_packet_type,
-          release_locked, fifo_read_before, INT_READ_IN)
+  process(fifo_data_out, fifo_packet_num_out, sbuf_init_free, 
+          fifo_empty, sbuf_reply_free, last_fifo_read, current_fifo_packet_type,
+          fifo_read_before, INT_INIT_READ_IN, INT_REPLY_READ_IN)
     begin
       tmp_INT_DATA_OUT <= fifo_data_out;
       tmp_INT_PACKET_NUM_OUT <= fifo_packet_num_out;
-      got_eob_out <= '0';
-      got_locked  <= is_locked;
+      tmp_INT_INIT_DATAREADY_OUT <= '0';
+      tmp_INT_REPLY_DATAREADY_OUT <= '0';
+      got_eob_init_out <= '0';
+      got_eob_reply_out <= '0';
       throw_away <= '0';
 
-      fifo_read <= not fifo_empty and not (fifo_read_before and not INT_READ_IN and not throw_away);
+      fifo_read <= not fifo_empty and not (fifo_read_before and not 
+                      ((INT_INIT_READ_IN and not current_fifo_packet_type(3)) 
+                      or (INT_REPLY_READ_IN and current_fifo_packet_type(3)) or throw_away));
 
-      if (fifo_read_before = '1' and (current_fifo_packet_type /= TYPE_EOB) and sbuf_free = '1') then
-        tmp_INT_DATAREADY_OUT <= '1';
-      else
-        tmp_INT_DATAREADY_OUT <= '0';
+      if (fifo_read_before = '1' and (current_fifo_packet_type(2 downto 0) /= TYPE_EOB)) then
+        tmp_INT_INIT_DATAREADY_OUT <=  sbuf_init_free and not current_fifo_packet_type(3);
+        tmp_INT_REPLY_DATAREADY_OUT <=  sbuf_reply_free and current_fifo_packet_type(3);
       end if;
 
       if last_fifo_read = '1' then
-        if current_fifo_packet_type = TYPE_EOB then
+        if current_fifo_packet_type(2 downto 0) = TYPE_EOB then
           throw_away <= '1';
         end if;
         if USE_ACKNOWLEDGE = 1 then
-          if (current_fifo_packet_type = TYPE_EOB or current_fifo_packet_type = TYPE_TRM)
-                                    and fifo_packet_num_out = "11" then
-            got_eob_out <= '1';
-          end if;
-          if current_fifo_packet_type = TYPE_TRM then
-            got_locked <= is_locked or not release_locked;
+          if (   current_fifo_packet_type(2 downto 0) = TYPE_EOB 
+              or current_fifo_packet_type(2 downto 0) = TYPE_TRM) and fifo_packet_num_out = "11" then
+            got_eob_init_out <= not current_fifo_packet_type(3);
+            got_eob_reply_out <= current_fifo_packet_type(3);
           end if;
         end if;
       end if;
@@ -322,7 +353,8 @@ begin
         else
           if fifo_read = '1' then
             fifo_read_before <= '1';
-          elsif INT_READ_IN = '1' or throw_away = '1' then
+          elsif (   (INT_INIT_READ_IN and not current_fifo_packet_type(3)) 
+                 or (INT_REPLY_READ_IN and current_fifo_packet_type(3)) or throw_away) = '1' then
             fifo_read_before <= '0';
           end if;
         end if;
@@ -330,82 +362,78 @@ begin
     end process;
 
 
-  release_locked <= CTRL_LOCKED(0);
-  STAT_LOCKED(0) <= is_locked;
-  STAT_LOCKED(15 downto 1) <= (others => '0');
-
   gen_ack1 : if USE_ACKNOWLEDGE = 1 generate
     reg_locked: process(CLK)
       begin
         if rising_edge(CLK) then
           if RESET = '1' then
-            is_locked <= '0';
-            reg_eob_out <= '0';
+            reg_eob_init_out <= '0';
+            reg_eob_reply_out <= '0';
           elsif CLK_EN = '1' then
-            is_locked <= got_locked and not release_locked;
-            reg_eob_out <= got_eob_out;
+            reg_eob_init_out <= got_eob_init_out;
+            reg_eob_reply_out <= got_eob_reply_out;
           end if;
         end if;
       end process;
   end generate;
 
 --saving last HDR
-  reading_header <= '1' when (current_fifo_packet_type = TYPE_HDR and fifo_empty = '0') else '0';
-   reg_hdr_f1: process(CLK)
-     begin
-      if rising_edge(CLK) then
-        if RESET = '1' then
-          current_last_header_F1 <= (others => '0');
-        elsif reading_header = '1' and fifo_packet_num_out = "01" then
-          current_last_header_F1 <= fifo_data_out;
-        end if;
-      end if;
-     end process;
-   reg_hdr_f2: process(CLK)
-     begin
-      if rising_edge(CLK) then
-        if RESET = '1' then
-          current_last_header_F2 <= (others => '0');
-        elsif reading_header = '1' and fifo_packet_num_out = "10" then
-          current_last_header_F2 <= fifo_data_out;
-        end if;
-      end if;
-     end process;
-   reg_hdr_f3: process(CLK)
-     begin
-      if rising_edge(CLK) then
-        if RESET = '1' then
-          current_last_header_F3 <= (others => '0');
-        elsif reading_header = '1' and fifo_packet_num_out = "11" then
-          current_last_header_F3 <= fifo_data_out;
-        end if;
-      end if;
-     end process;
+  -- reading_header <= '1' when (current_fifo_packet_type = TYPE_HDR and fifo_empty = '0') else '0';
+   -- reg_hdr_f1: process(CLK)
+     -- begin
+      -- if rising_edge(CLK) then
+        -- if RESET = '1' then
+          -- current_last_header_F1 <= (others => '0');
+        -- elsif reading_header = '1' and fifo_packet_num_out = "01" then
+          -- current_last_header_F1 <= fifo_data_out;
+        -- end if;
+      -- end if;
+     -- end process;
+   -- reg_hdr_f2: process(CLK)
+     -- begin
+      -- if rising_edge(CLK) then
+        -- if RESET = '1' then
+          -- current_last_header_F2 <= (others => '0');
+        -- elsif reading_header = '1' and fifo_packet_num_out = "10" then
+          -- current_last_header_F2 <= fifo_data_out;
+        -- end if;
+      -- end if;
+     -- end process;
+   -- reg_hdr_f3: process(CLK)
+     -- begin
+      -- if rising_edge(CLK) then
+        -- if RESET = '1' then
+          -- current_last_header_F3 <= (others => '0');
+        -- elsif reading_header = '1' and fifo_packet_num_out = "11" then
+          -- current_last_header_F3 <= fifo_data_out;
+        -- end if;
+      -- end if;
+     -- end process;
 
   
 -- make STAT_BUFFER
   STAT_BUFFER(3 downto 0) <= (fifo_depth(3 downto 0));
+  STAT_BUFFER(7 downto 4) <= current_rec_buffer_size_out;
 
   gen_ack2 : if USE_ACKNOWLEDGE = 1 generate
-    STAT_BUFFER(7 downto 4) <= current_rec_buffer_size_out;
-    STAT_BUFFER(8) <= reg_eob_out;
-    STAT_BUFFER(9) <= reg_ack_internal;
+    STAT_BUFFER(8) <= reg_eob_init_out;
+    STAT_BUFFER(9) <= reg_ack_init_internal;
+    STAT_BUFFER(10) <= reg_eob_reply_out;
+    STAT_BUFFER(11) <= reg_ack_reply_internal;
   end generate;
   gen_ack3 : if USE_ACKNOWLEDGE = 0 generate
-    STAT_BUFFER(9 downto 4) <= (others => '0');
+    STAT_BUFFER(11 downto 8) <= (others => '0');
   end generate;
 
   process(current_error_state)
     begin
       case current_error_state is
-        when IDLE               => STAT_BUFFER(11 downto 10) <= "00";
-        when GOT_OVERFLOW_ERROR => STAT_BUFFER(11 downto 10) <= "01";
-        when GOT_LOCKED_ERROR   => STAT_BUFFER(11 downto 10) <= "10";
-        when others             => STAT_BUFFER(11 downto 10) <= "11";
+        when IDLE               => STAT_BUFFER(13 downto 12) <= "00";
+        when GOT_OVERFLOW_ERROR => STAT_BUFFER(13 downto 12) <= "01";
+        when others             => STAT_BUFFER(13 downto 12) <= "11";
       end case;
     end process;
-
-  STAT_BUFFER(31 downto 12) <= (others => '0');
+  STAT_BUFFER(31 downto 14) <= (others => '0');
 
 
   INT_ERROR_OUT <= MED_ERROR_IN;
index bf713781782920fe14e06c0d2afb88f2845be829..d5df14a6c8d1f23f8c9a6aac6f36739a779ed7c8 100644 (file)
@@ -9,12 +9,12 @@ use work.trb_net_std.all;
 
 entity trb_net16_iobuf is
   generic (
-    INIT_DEPTH            : integer range 0 to 6 := 6;--std_FIFO_DEPTH;
-    REPLY_DEPTH           : integer range 0 to 6 := 6;--std_FIFO_DEPTH;
-    IBUF_SECURE_MODE      : integer range 0 to 1 := c_YES;--std_IBUF_SECURE_MODE;
+    IBUF_DEPTH            : integer range 0 to 6 := c_FIFO_BRAM;--std_FIFO_DEPTH;
+    IBUF_SECURE_MODE      : integer range 0 to 1 := c_NO;--std_IBUF_SECURE_MODE;
     SBUF_VERSION          : integer range 0 to 1 := std_SBUF_VERSION;
     OBUF_DATA_COUNT_WIDTH : integer range 2 to 7 := std_DATA_COUNT_WIDTH;
     USE_ACKNOWLEDGE       : integer range 0 to 1 := std_USE_ACKNOWLEDGE;
+    USE_VENDOR_CORES      : integer range 0 to 1 := c_YES;
     USE_REPLY_CHANNEL     : integer range 0 to 1 := c_YES;  -- not used yet
     INIT_CAN_SEND_DATA    : integer range 0 to 1 := c_YES;
     REPLY_CAN_SEND_DATA   : integer range 0 to 1 := c_YES
@@ -73,13 +73,9 @@ entity trb_net16_iobuf is
 
     -- Status and control port
     STAT_GEN:               out std_logic_vector (31 downto 0);
-    STAT_LOCKED:            out std_logic_vector (31 downto 0);
-    STAT_INIT_BUFFER:       out std_logic_vector (31 downto 0);
-    STAT_REPLY_BUFFER:      out std_logic_vector (31 downto 0);
+    STAT_IBUF_BUFFER:       out std_logic_vector (31 downto 0);
     CTRL_GEN:               in  std_logic_vector (31 downto 0);
-    CTRL_LOCKED:            in  std_logic_vector (31 downto 0);
-    STAT_CTRL_INIT_BUFFER:  in  std_logic_vector (31 downto 0);
-    STAT_CTRL_REPLY_BUFFER: in  std_logic_vector (31 downto 0)
+    STAT_CTRL_IBUF_BUFFER:  in  std_logic_vector (31 downto 0)
     );
 end entity;
 
@@ -107,8 +103,6 @@ architecture trb_net16_iobuf_arch of trb_net16_iobuf is
       INT_PACKET_NUM_IN: in  std_logic_vector (c_NUM_WIDTH-1  downto 0);
       INT_READ_OUT:      out std_logic;
       -- Status and control port
-      STAT_LOCKED:       out std_logic_vector (15 downto 0);
-      CTRL_LOCKED:       in  std_logic_vector (15 downto 0);
       STAT_BUFFER:       out std_logic_vector (31 downto 0);
       CTRL_BUFFER:       in  std_logic_vector (31 downto 0)
       );
@@ -126,8 +120,6 @@ architecture trb_net16_iobuf_arch of trb_net16_iobuf is
       MED_PACKET_NUM_OUT:out std_logic_vector (c_NUM_WIDTH-1  downto 0);
       MED_READ_IN:       in  std_logic;
       --STAT
-      STAT_LOCKED:       out std_logic_vector (15 downto 0);
-      CTRL_LOCKED:       in  std_logic_vector (15 downto 0);
       STAT_BUFFER:       out std_logic_vector (31 downto 0);
       CTRL_BUFFER:       in  std_logic_vector (31 downto 0)
       );
@@ -135,94 +127,85 @@ architecture trb_net16_iobuf_arch of trb_net16_iobuf is
 
   component trb_net16_ibuf is
     generic (
-      DEPTH            : integer range 0 to 7 := std_FIFO_DEPTH;
+      DEPTH            : integer range 0 to 7 := c_FIFO_BRAM;
+      USE_VENDOR_CORES : integer range 0 to 1 := c_YES;
       USE_ACKNOWLEDGE  : integer range 0 to 1 := std_USE_ACKNOWLEDGE;
       SBUF_VERSION     : integer range 0 to 1 := std_SBUF_VERSION;
-      SECURE_MODE      : integer range 0 to 1 := std_IBUF_SECURE_MODE;
-      USE_VENDOR_CORES : integer range 0 to 1 := c_YES
+      SECURE_MODE      : integer range 0 to 1 := c_YES
+                   --use sbuf in med_to_api direction?
       );
     port(
       --  Misc
-      CLK    : in std_logic;      
-      RESET  : in std_logic;    
+      CLK    : in std_logic;           
+      RESET  : in std_logic;   
       CLK_EN : in std_logic;
       --  Media direction port
-      MED_DATAREADY_IN:  in  std_logic; -- Data word is offered by the Media (the IOBUF MUST read)
-      MED_DATA_IN:       in  std_logic_vector (c_DATA_WIDTH-1 downto 0);
-      MED_PACKET_NUM_IN :in  std_logic_vector (c_NUM_WIDTH-1  downto 0);
-      MED_READ_OUT:      out std_logic;
-      MED_ERROR_IN:      in  std_logic_vector (2 downto 0);
+      MED_DATAREADY_IN        : in  std_logic;
+      MED_DATA_IN             : in  std_logic_vector (c_DATA_WIDTH-1 downto 0);
+      MED_PACKET_NUM_IN       : in  std_logic_vector(c_NUM_WIDTH-1 downto 0);
+      MED_READ_OUT            : out std_logic;
+      MED_ERROR_IN            : in  std_logic_vector (2 downto 0);
       -- Internal direction port
-      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 (c_DATA_WIDTH-1 downto 0);
-      INT_PACKET_NUM_OUT:out std_logic_vector (c_NUM_WIDTH-1  downto 0);
-      INT_READ_IN:       in  std_logic;
-      INT_ERROR_OUT:     out std_logic_vector (2 downto 0);
+      INT_INIT_DATA_OUT       : out std_logic_vector (c_DATA_WIDTH-1 downto 0);
+      INT_INIT_PACKET_NUM_OUT : out std_logic_vector(c_NUM_WIDTH-1 downto 0);
+      INT_INIT_DATAREADY_OUT  : out std_logic;
+      INT_INIT_READ_IN        : in  std_logic;
+      INT_REPLY_DATA_OUT      : out std_logic_vector (c_DATA_WIDTH-1 downto 0);
+      INT_REPLY_PACKET_NUM_OUT: out std_logic_vector(c_NUM_WIDTH-1 downto 0);
+      INT_REPLY_DATAREADY_OUT : out std_logic;
+      INT_REPLY_READ_IN       : in  std_logic;
+      INT_ERROR_OUT           : out std_logic_vector (2 downto 0);
       -- Status and control port
-      STAT_LOCKED:       out std_logic_vector (15 downto 0);
-      CTRL_LOCKED:       in  std_logic_vector (15 downto 0);
-      STAT_BUFFER:       out std_logic_vector (31 downto 0)
+      STAT_BUFFER             : out std_logic_vector (31 downto 0)
       );
   end component;
 
-  component trb_net16_term_ibuf is
-    generic(
-      SECURE_MODE   : integer range 0 to 1 := std_TERM_SECURE_MODE;
-      SBUF_VERSION  : integer range 0 to 1 := std_SBUF_VERSION
-      );
-    port(
-      --  Misc
-      CLK    : in std_logic;
-      RESET  : in std_logic;
-      CLK_EN : in std_logic;
-      --  Media direction port
-      MED_DATAREADY_IN:  in  std_logic; -- Data word is offered by the Media (the IOBUF MUST read)
-      MED_DATA_IN:       in  std_logic_vector (c_DATA_WIDTH-1 downto 0);
-      MED_PACKET_NUM_IN: in  std_logic_vector (c_NUM_WIDTH-1  downto 0);
-      MED_READ_OUT:      out std_logic;
-      MED_ERROR_IN:      in  std_logic_vector (2 downto 0);
-      -- Internal direction port
-      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 (c_DATA_WIDTH-1 downto 0);
-      INT_PACKET_NUM_OUT:out std_logic_vector (c_NUM_WIDTH-1  downto 0);
-      INT_READ_IN:       in  std_logic;
-      INT_ERROR_OUT:     out std_logic_vector (2 downto 0);
-      -- Status and control port
-      STAT_LOCKED:       out std_logic_vector (15 downto 0);
-      CTRL_LOCKED:       in  std_logic_vector (15 downto 0);
-      STAT_BUFFER:       out std_logic_vector (31 downto 0)
-      );
-  end component;
+  -- component trb_net16_term_ibuf is
+    -- generic(
+      -- SECURE_MODE   : integer range 0 to 1 := std_TERM_SECURE_MODE;
+      -- SBUF_VERSION  : integer range 0 to 1 := std_SBUF_VERSION
+      -- );
+    -- port(
+      -- -- Misc
+      -- CLK    : in std_logic;
+      -- RESET  : in std_logic;
+      -- CLK_EN : in std_logic;
+      -- -- Media direction port
+      -- MED_DATAREADY_IN:  in  std_logic;
+      -- MED_DATA_IN:       in  std_logic_vector (c_DATA_WIDTH-1 downto 0);
+      -- MED_PACKET_NUM_IN: in  std_logic_vector (c_NUM_WIDTH-1  downto 0);
+      -- MED_READ_OUT:      out std_logic;
+      -- MED_ERROR_IN:      in  std_logic_vector (2 downto 0);
+      -- --Internal direction port
+      -- INT_DATAREADY_OUT: out std_logic;
+      -- INT_DATA_OUT:      out std_logic_vector (c_DATA_WIDTH-1 downto 0);
+      -- INT_PACKET_NUM_OUT:out std_logic_vector (c_NUM_WIDTH-1  downto 0);
+      -- INT_READ_IN:       in  std_logic;
+      -- INT_ERROR_OUT:     out std_logic_vector (2 downto 0);
+      -- --Status and control port
+      -- STAT_LOCKED:       out std_logic_vector (15 downto 0);
+      -- CTRL_LOCKED:       in  std_logic_vector (15 downto 0);
+      -- STAT_BUFFER:       out std_logic_vector (31 downto 0)
+      -- );
+  -- end component;
   
   -- internal signals for the INITIBUF
-  signal  INITIBUF_error:    STD_LOGIC_VECTOR (2 downto 0);  -- error watch needed!
-  signal  INITIBUF_stat_locked, INITIBUF_ctrl_locked: STD_LOGIC_VECTOR (15 downto 0);
-  signal  INITIBUF_stat_buffer  :  STD_LOGIC_VECTOR (31 downto 0);
-
-  -- internal signals for the REPLYIBUF
-  signal  REPLYIBUF_error:    STD_LOGIC_VECTOR (2 downto 0); -- error watch needed!
-  signal  REPLYIBUF_stat_locked, REPLYIBUF_ctrl_locked: STD_LOGIC_VECTOR (15 downto 0);
-  signal  REPLYIBUF_stat_buffer  :  STD_LOGIC_VECTOR (31 downto 0);
-
-  -- internal signals for the INITOBUF
-  signal  INITOBUF_stat_locked, INITOBUF_ctrl_locked: STD_LOGIC_VECTOR (15 downto 0);
+  signal  IBUF_error:    STD_LOGIC_VECTOR (2 downto 0);  -- error watch needed!
+  signal  IBUF_stat_buffer  :  STD_LOGIC_VECTOR (31 downto 0);
   signal  INITOBUF_stat_buffer, INITOBUF_ctrl_buffer:  STD_LOGIC_VECTOR (31 downto 0);
-
-  -- internal signals for the REPLYOBUF
-  signal  REPLYOBUF_stat_locked, REPLYOBUF_ctrl_locked: STD_LOGIC_VECTOR (15 downto 0);
   signal  REPLYOBUF_stat_buffer, REPLYOBUF_ctrl_buffer:  STD_LOGIC_VECTOR (31 downto 0);
-
--- locking control
-  signal  INIT_IS_LOCKED,  REPLY_IS_LOCKED: STD_LOGIC;
-  signal  next_INIT_IS_LOCKED,  next_REPLY_IS_LOCKED: STD_LOGIC;
+  signal ibuf_dataready_in, ibuf_read_out   : std_logic;
 
 begin
-  GEN_INIT_IBUF: if INIT_DEPTH>0 generate
-    INITIBUF : trb_net16_ibuf
+  GEN_IBUF: if IBUF_DEPTH>0 generate
+    ibuf_dataready_in <= MED_INIT_DATAREADY_IN or MED_REPLY_DATAREADY_IN;
+    MED_INIT_READ_OUT <= ibuf_read_out;
+    MED_REPLY_READ_OUT <= ibuf_read_out;
+    
+    IBUF : trb_net16_ibuf
       generic map (
-        DEPTH            => INIT_DEPTH,
+        DEPTH            => IBUF_DEPTH,
+        USE_VENDOR_CORES => USE_VENDOR_CORES,
         USE_ACKNOWLEDGE  => USE_ACKNOWLEDGE,
         SBUF_VERSION     => SBUF_VERSION,
         SECURE_MODE      => IBUF_SECURE_MODE
@@ -231,105 +214,52 @@ begin
         CLK       => CLK,
         RESET     => RESET,
         CLK_EN    => CLK_EN,
-        MED_DATAREADY_IN => MED_INIT_DATAREADY_IN,
+        MED_DATAREADY_IN => ibuf_dataready_in,
         MED_DATA_IN => MED_INIT_DATA_IN,
         MED_PACKET_NUM_IN => MED_INIT_PACKET_NUM_IN,
-        MED_READ_OUT => MED_INIT_READ_OUT,
+        MED_READ_OUT => ibuf_read_out,
         MED_ERROR_IN => MED_INIT_ERROR_IN,
-        INT_HEADER_IN => '0',
-        INT_DATAREADY_OUT => INT_INIT_DATAREADY_OUT,
-        INT_DATA_OUT => INT_INIT_DATA_OUT,
-        INT_PACKET_NUM_OUT => INT_INIT_PACKET_NUM_OUT,
-        INT_READ_IN => INT_INIT_READ_IN,
-        INT_ERROR_OUT => INITIBUF_error,
-        STAT_LOCKED(15 downto 0) => INITIBUF_stat_locked,
-        CTRL_LOCKED(15 downto 0) => INITIBUF_ctrl_locked,
-        STAT_BUFFER(31 downto 0) => INITIBUF_stat_buffer
+        INT_INIT_DATAREADY_OUT => INT_INIT_DATAREADY_OUT,
+        INT_INIT_DATA_OUT => INT_INIT_DATA_OUT,
+        INT_INIT_PACKET_NUM_OUT => INT_INIT_PACKET_NUM_OUT,
+        INT_INIT_READ_IN => INT_INIT_READ_IN,
+        INT_REPLY_DATAREADY_OUT => INT_REPLY_DATAREADY_OUT,
+        INT_REPLY_DATA_OUT => INT_REPLY_DATA_OUT,
+        INT_REPLY_PACKET_NUM_OUT => INT_REPLY_PACKET_NUM_OUT,
+        INT_REPLY_READ_IN => INT_REPLY_READ_IN,
+        INT_ERROR_OUT => IBUF_error,
+        STAT_BUFFER(31 downto 0) => IBUF_stat_buffer
         );
   end generate;
 
-  GEN_REPLY_IBUF : if REPLY_DEPTH > 0 generate
-    REPLYIBUF : trb_net16_ibuf
-      generic map (
-        DEPTH            => REPLY_DEPTH,
-        USE_ACKNOWLEDGE  => USE_ACKNOWLEDGE,
-        SBUF_VERSION     => SBUF_VERSION,
-        SECURE_MODE      => IBUF_SECURE_MODE
-        )
-      port map (
-        CLK       => CLK,
-        RESET     => RESET,
-        CLK_EN    => CLK_EN,
-        MED_DATAREADY_IN => MED_REPLY_DATAREADY_IN,
-        MED_DATA_IN => MED_REPLY_DATA_IN,
-        MED_PACKET_NUM_IN => MED_REPLY_PACKET_NUM_IN,
-        MED_READ_OUT => MED_REPLY_READ_OUT,
-        MED_ERROR_IN => MED_REPLY_ERROR_IN,
-        INT_HEADER_IN => INT_REPLY_HEADER_IN,
-        INT_DATAREADY_OUT => INT_REPLY_DATAREADY_OUT,
-        INT_DATA_OUT => INT_REPLY_DATA_OUT,
-        INT_PACKET_NUM_OUT => INT_REPLY_PACKET_NUM_OUT,
-        INT_READ_IN => INT_REPLY_READ_IN,
-        INT_ERROR_OUT => REPLYIBUF_error,
-        STAT_LOCKED(15 downto 0) => REPLYIBUF_stat_locked,
-        CTRL_LOCKED(15 downto 0) => REPLYIBUF_ctrl_locked,
-        STAT_BUFFER(31 downto 0) => REPLYIBUF_stat_buffer
-        );
-  end generate;
+  -- GEN_TERM_IBUF: if INIT_DEPTH=0 generate
+    -- INITIBUF : trb_net16_term_ibuf
+      -- generic map(
+        -- SBUF_VERSION => SBUF_VERSION,
+        -- SECURE_MODE  => IBUF_SECURE_MODE
+        -- )
+      -- port map (
+        -- CLK       => CLK,
+        -- RESET     => RESET,
+        -- CLK_EN    => CLK_EN,
+        -- MED_DATAREADY_IN => MED_INIT_DATAREADY_IN,
+        -- MED_DATA_IN => MED_INIT_DATA_IN,
+        -- MED_PACKET_NUM_IN => MED_INIT_PACKET_NUM_IN,
+        -- MED_READ_OUT => MED_INIT_READ_OUT,
+        -- MED_ERROR_IN => MED_INIT_ERROR_IN,
+        -- INT_HEADER_IN => '0',
+        -- INT_DATAREADY_OUT => INT_INIT_DATAREADY_OUT,
+        -- INT_DATA_OUT => INT_INIT_DATA_OUT,
+        -- INT_PACKET_NUM_OUT => INT_INIT_PACKET_NUM_OUT,
+        -- INT_READ_IN => INT_INIT_READ_IN,
+        -- INT_ERROR_OUT => INITIBUF_error,
+        -- STAT_LOCKED(15 downto 0) => INITIBUF_stat_locked,
+        -- CTRL_LOCKED(15 downto 0) => INITIBUF_ctrl_locked,
+        -- STAT_BUFFER(31 downto 0) => INITIBUF_stat_buffer
+        -- );
+  -- end generate;
 
-  GEN_TERM_INIT_IBUF: if INIT_DEPTH=0 generate
-    INITIBUF : trb_net16_term_ibuf
-      generic map(
-        SBUF_VERSION => SBUF_VERSION,
-        SECURE_MODE  => IBUF_SECURE_MODE
-        )
-      port map (
-        CLK       => CLK,
-        RESET     => RESET,
-        CLK_EN    => CLK_EN,
-        MED_DATAREADY_IN => MED_INIT_DATAREADY_IN,
-        MED_DATA_IN => MED_INIT_DATA_IN,
-        MED_PACKET_NUM_IN => MED_INIT_PACKET_NUM_IN,
-        MED_READ_OUT => MED_INIT_READ_OUT,
-        MED_ERROR_IN => MED_INIT_ERROR_IN,
-        INT_HEADER_IN => '0',
-        INT_DATAREADY_OUT => INT_INIT_DATAREADY_OUT,
-        INT_DATA_OUT => INT_INIT_DATA_OUT,
-        INT_PACKET_NUM_OUT => INT_INIT_PACKET_NUM_OUT,
-        INT_READ_IN => INT_INIT_READ_IN,
-        INT_ERROR_OUT => INITIBUF_error,
-        STAT_LOCKED(15 downto 0) => INITIBUF_stat_locked,
-        CTRL_LOCKED(15 downto 0) => INITIBUF_ctrl_locked,
-        STAT_BUFFER(31 downto 0) => INITIBUF_stat_buffer
-        );
-  end generate;
 
-  GEN_TERM_REPLY_IBUF: if REPLY_DEPTH=0 generate
-    REPLYIBUF : trb_net16_term_ibuf
-      generic map(
-        SBUF_VERSION => SBUF_VERSION,
-        SECURE_MODE  => IBUF_SECURE_MODE
-        )
-      port map (
-        CLK       => CLK,
-        RESET     => RESET,
-        CLK_EN    => CLK_EN,
-        MED_DATAREADY_IN => MED_REPLY_DATAREADY_IN,
-        MED_DATA_IN => MED_REPLY_DATA_IN,
-        MED_PACKET_NUM_IN => MED_REPLY_PACKET_NUM_IN,
-        MED_READ_OUT => MED_REPLY_READ_OUT,
-        MED_ERROR_IN => MED_REPLY_ERROR_IN,
-        INT_HEADER_IN => INT_REPLY_HEADER_IN,
-        INT_DATAREADY_OUT => INT_REPLY_DATAREADY_OUT,
-        INT_DATA_OUT => INT_REPLY_DATA_OUT,
-        INT_PACKET_NUM_OUT => INT_REPLY_PACKET_NUM_OUT,
-        INT_READ_IN => INT_REPLY_READ_IN,
-        INT_ERROR_OUT => REPLYIBUF_error,
-        STAT_LOCKED(15 downto 0) => REPLYIBUF_stat_locked,
-        CTRL_LOCKED(15 downto 0) => REPLYIBUF_ctrl_locked,
-        STAT_BUFFER(31 downto 0) => REPLYIBUF_stat_buffer
-        );
-  end generate;
 
   genINITOBUF1 : if INIT_CAN_SEND_DATA = 1 generate
     INITOBUF : trb_net16_obuf
@@ -350,8 +280,6 @@ begin
         INT_DATA_IN => INT_INIT_DATA_IN,
         INT_PACKET_NUM_IN => INT_INIT_PACKET_NUM_IN,
         INT_READ_OUT => INT_INIT_READ_OUT,
-        STAT_LOCKED(15 downto 0) => INITOBUF_stat_locked,
-        CTRL_LOCKED(15 downto 0) => INITOBUF_ctrl_locked,
         STAT_BUFFER(31 downto 0) => INITOBUF_stat_buffer,
         CTRL_BUFFER(31 downto 0) => INITOBUF_ctrl_buffer
         );
@@ -367,8 +295,6 @@ begin
           MED_DATA_OUT => MED_INIT_DATA_OUT,
           MED_PACKET_NUM_OUT => MED_INIT_PACKET_NUM_OUT,
           MED_READ_IN => MED_INIT_READ_IN,
-          STAT_LOCKED(15 downto 0) => INITOBUF_stat_locked,
-          CTRL_LOCKED(15 downto 0) => INITOBUF_ctrl_locked,
           STAT_BUFFER(31 downto 0) => INITOBUF_stat_buffer,
           CTRL_BUFFER(31 downto 0) => INITOBUF_ctrl_buffer
           );
@@ -401,8 +327,6 @@ begin
         INT_DATA_IN => INT_REPLY_DATA_IN,
         INT_PACKET_NUM_IN => INT_REPLY_PACKET_NUM_IN,
         INT_READ_OUT => INT_REPLY_READ_OUT,
-        STAT_LOCKED(15 downto 0) => REPLYOBUF_stat_locked,
-        CTRL_LOCKED(15 downto 0) => REPLYOBUF_ctrl_locked,
         STAT_BUFFER(31 downto 0) => REPLYOBUF_stat_buffer,
         CTRL_BUFFER(31 downto 0) => REPLYOBUF_ctrl_buffer
         );
@@ -418,8 +342,6 @@ begin
           MED_DATA_OUT => MED_REPLY_DATA_OUT,
           MED_PACKET_NUM_OUT => MED_REPLY_PACKET_NUM_OUT,
           MED_READ_IN => MED_REPLY_READ_IN,
-          STAT_LOCKED(15 downto 0) => REPLYOBUF_stat_locked,
-          CTRL_LOCKED(15 downto 0) => REPLYOBUF_ctrl_locked,
           STAT_BUFFER(31 downto 0) => REPLYOBUF_stat_buffer,
           CTRL_BUFFER(31 downto 0) => REPLYOBUF_ctrl_buffer
           );
@@ -434,105 +356,24 @@ begin
 
 
 -- build the registers according to the wiki page
-  STAT_INIT_BUFFER(8 downto 0) <= INITIBUF_stat_buffer(8 downto 0);
-  STAT_INIT_BUFFER(11 downto 9) <= INITOBUF_stat_buffer(17 downto 15);
-  STAT_INIT_BUFFER(13 downto 12) <= (others => '0');
-  STAT_INIT_BUFFER(15 downto 14) <= INITOBUF_stat_buffer(1 downto 0);
-  STAT_INIT_BUFFER(31 downto 16) <= INITOBUF_stat_buffer(31 downto 16);
-  STAT_REPLY_BUFFER(11 downto 0) <= REPLYIBUF_stat_buffer(11 downto 0);
-  STAT_REPLY_BUFFER(13 downto 12) <= (others => '0');
-  STAT_REPLY_BUFFER(15 downto 14) <= REPLYOBUF_stat_buffer(1 downto 0);
-  STAT_REPLY_BUFFER(31 downto 16) <= REPLYOBUF_stat_buffer(31 downto 16);
+  -- STAT_BUFFER(15 downto 0) 
+  -- STAT_INIT_BUFFER(8 downto 0) <= INITIBUF_stat_buffer(8 downto 0);
+  -- STAT_INIT_BUFFER(11 downto 9) <= INITOBUF_stat_buffer(17 downto 15);
+  -- STAT_INIT_BUFFER(13 downto 12) <= (others => '0');
+  -- STAT_INIT_BUFFER(15 downto 14) <= INITOBUF_stat_buffer(1 downto 0);
+  -- STAT_INIT_BUFFER(31 downto 16) <= INITOBUF_stat_buffer(31 downto 16);
+  -- STAT_REPLY_BUFFER(11 downto 0) <= REPLYIBUF_stat_buffer(11 downto 0);
+  -- STAT_REPLY_BUFFER(13 downto 12) <= (others => '0');
+  -- STAT_REPLY_BUFFER(15 downto 14) <= REPLYOBUF_stat_buffer(1 downto 0);
+  -- STAT_REPLY_BUFFER(31 downto 16) <= REPLYOBUF_stat_buffer(31 downto 16);
 
 -- build the CTRL register of the OBUFs
-  INITOBUF_ctrl_buffer(9 downto 0) <= INITIBUF_stat_buffer(9 downto 0);
+  INITOBUF_ctrl_buffer(9 downto 0) <= IBUF_stat_buffer(9 downto 0);
   INITOBUF_ctrl_buffer(31 downto 10) <= (others => '0');
-  REPLYOBUF_ctrl_buffer(9 downto 0) <= REPLYIBUF_stat_buffer(9 downto 0);
+  REPLYOBUF_ctrl_buffer(7 downto 0) <= IBUF_stat_buffer(7 downto 0);
+  REPLYOBUF_ctrl_buffer(9 downto 8) <= IBUF_stat_buffer(11 downto 10);
   REPLYOBUF_ctrl_buffer(31 downto 10) <= (others => '0');
 
-
-  gen0a: if USE_ACKNOWLEDGE = 0 generate
-    STAT_LOCKED <= (others => '0');
-    REPLYOBUF_ctrl_locked <= (others => '0');
-    REPLYIBUF_ctrl_locked <= (others => '0');
-    INITOBUF_ctrl_locked  <= (others => '0');
-    INITIBUF_ctrl_locked  <= (others => '0');
-  end generate;
-  gen0: if USE_ACKNOWLEDGE = 1 generate
-    STAT_LOCKED(0) <= INIT_IS_LOCKED;
-    STAT_LOCKED(1) <= REPLY_IS_LOCKED;
-    STAT_LOCKED(31 downto 2) <= (others => '0');
-  
-    STAT_GEN  <= (others => '0');
+  STAT_GEN  <= (others => '0');
   
-    REPLYOBUF_ctrl_locked(15 downto 2) <= (others => '0');
-    REPLYIBUF_ctrl_locked(15 downto 2) <= (others => '0');
-    INITOBUF_ctrl_locked(15 downto 2) <= (others => '0');
-    INITIBUF_ctrl_locked(15 downto 2) <= (others => '0');
-  
-  -- comb part of the locking control
-    comb_locked : process (INIT_IS_LOCKED, REPLY_IS_LOCKED, INITIBUF_stat_locked,
-                        REPLYOBUF_stat_locked, REPLYIBUF_stat_locked,
-                        INITOBUF_stat_locked,  CTRL_LOCKED)
-      
-      begin  -- process
-        next_INIT_IS_LOCKED <= INIT_IS_LOCKED;
-        next_REPLY_IS_LOCKED <= REPLY_IS_LOCKED;
-        REPLYOBUF_ctrl_locked(1 downto 0) <= (others => '0');
-        REPLYIBUF_ctrl_locked(1 downto 0) <= (others => '0');
-        INITOBUF_ctrl_locked(1 downto 0) <= (others => '0');
-        INITIBUF_ctrl_locked(1 downto 0) <= (others => '0');
-    
-        if REPLY_IS_LOCKED = '1' then
-          -- listen to INITOBUF
-          if INITOBUF_stat_locked(0) = '1' or CTRL_LOCKED(1) = '1' then
-            next_REPLY_IS_LOCKED <= '0';
-            REPLYIBUF_ctrl_locked(0) <= '1';
-          else
-            next_REPLY_IS_LOCKED <= '1';
-          end if;
-        else
-          -- listen to REPLYIBUF itself
-          if REPLYIBUF_stat_locked(0) = '1' then
-            next_REPLY_IS_LOCKED <= '1';
-            INITOBUF_ctrl_locked(0) <= '1';
-          else
-            next_REPLY_IS_LOCKED <= '0';
-          end if;
-        end if;
-        
-        if INIT_IS_LOCKED = '1' then
-          -- listen to REPLYOBUF
-          if REPLYOBUF_stat_locked(0) = '1' or CTRL_LOCKED(0) = '1' then
-            next_INIT_IS_LOCKED <= '0';
-            INITIBUF_ctrl_locked(0) <= '1';
-          else
-            next_INIT_IS_LOCKED <= '1';
-          end if;
-        else
-          -- listen to INITIBUF itself
-          if INITIBUF_stat_locked(0) = '1' then
-            next_INIT_IS_LOCKED <= '1';
-            REPLYOBUF_ctrl_locked(0) <= '1';
-          else
-            next_INIT_IS_LOCKED <= '0';
-          end if;
-        end if;  
-    
-      end process;
-  
-    reg_locked: process(CLK)
-      begin
-        if rising_edge(CLK) then
-          if RESET = '1' then
-            INIT_IS_LOCKED <= '0';
-            REPLY_IS_LOCKED <= '1';
-          elsif CLK_EN = '1' then
-            INIT_IS_LOCKED <= next_INIT_IS_LOCKED;
-            REPLY_IS_LOCKED <= next_REPLY_IS_LOCKED;
-          end if;
-        end if;
-      end process;
-  end generate;
-
 end architecture;
index e8123f9820747187073f050b74b4a0360273138c..2364112ebe25b06f928120a91b2bcfe360d27029 100644 (file)
@@ -32,8 +32,6 @@ entity trb_net16_obuf is
     INT_PACKET_NUM_IN  : in  std_logic_vector (c_NUM_WIDTH-1  downto 0);
     INT_READ_OUT       : out std_logic;
     -- Status and control port
-    STAT_LOCKED       : out std_logic_vector (15 downto 0);
-    CTRL_LOCKED       : in  std_logic_vector (15 downto 0);
     STAT_BUFFER       : out std_logic_vector (31 downto 0);
     CTRL_BUFFER       : in  std_logic_vector (31 downto 0)
     );
@@ -87,8 +85,6 @@ architecture trb_net16_obuf_arch of trb_net16_obuf is
   signal SEND_ACK_IN         : STD_LOGIC;
   signal GOT_ACK_IN          : STD_LOGIC;
   
-  signal is_locked, got_locked,release_locked : std_logic;
-
   signal transfer_counter    : std_logic_vector(1 downto 0);
   signal saved_packet_type   : std_logic_vector(2 downto 0);
   signal reg_SEND_ACK_IN_2,next_SEND_ACK_IN_2  : std_logic;
@@ -168,9 +164,6 @@ begin
     reg_SEND_ACK_IN <= '0';
     reg_SEND_ACK_IN_2 <= '0';
     send_DATA <= '1';
-    got_locked <= '0';
-    release_locked <= '0';
-    is_locked <= '0';
     CURRENT_DATA_COUNT <= (others => '0');
     max_DATA_COUNT_minus_one <= (others => '0');
     next_max_DATA_COUNT_minus_one <= (others => '0');
@@ -318,7 +311,6 @@ begin
 
   gen3 : if USE_ACKNOWLEDGE = 0 generate
     STAT_BUFFER <= (others => '0');
-    STAT_LOCKED <= (others => '0');
     TRANSMITTED_BUFFERS <= (others => '0');
   end generate;
 
@@ -379,30 +371,7 @@ begin
         end if;
       end process;
   
-    comb_locked : process (MED_READ_IN, saved_packet_type, transfer_counter, release_locked, is_locked)
-      begin  -- process
-        got_locked  <= is_locked and not release_locked;
-        if MED_READ_IN = '1' then
-          if saved_packet_type = TYPE_TRM and transfer_counter = "11" and release_locked = '0' then
-            got_locked  <= '1';
-          end if;
-        end if;
-      end process;
-  
-    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';
-          elsif CLK_EN = '1' then
-            is_locked <= got_locked;
-          end if;
-        end if;
-      end process;
+
   end generate;
 
 end architecture;
\ No newline at end of file
index ae316b287a8c0d9c59e2147f1c4acb31638778fc..465c49ff2c8c61293f15934864b7d41426c53da8 100644 (file)
@@ -17,8 +17,6 @@ entity trb_net16_obuf_nodata is
     MED_PACKET_NUM_OUT : out std_logic_vector (c_NUM_WIDTH-1  downto 0);
     MED_READ_IN        : in  std_logic;
     --STAT
-    STAT_LOCKED       : out std_logic_vector (15 downto 0);
-    CTRL_LOCKED       : in  std_logic_vector (15 downto 0);
     STAT_BUFFER       : out std_logic_vector (31 downto 0);
     CTRL_BUFFER       : in  std_logic_vector (31 downto 0)
     );
@@ -120,7 +118,6 @@ begin
       end if;
     end process;
 
-  STAT_LOCKED <= (others => '0');
   STAT_BUFFER <= (others => '0');
 
 end architecture;