]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
*** empty log message ***
authorhadeshyp <hadeshyp>
Thu, 22 Jan 2009 15:15:45 +0000 (15:15 +0000)
committerhadeshyp <hadeshyp>
Thu, 22 Jan 2009 15:15:45 +0000 (15:15 +0000)
testbenches/testbench_hublogic_ipudata.vhd
trb_net16_api_base.vhd
trb_net16_endpoint_0_trg_1_api.vhd
trb_net16_hub_base.vhd
trb_net16_hub_func.vhd
trb_net16_hub_ipu_logic.vhd
trb_net16_hub_logic.vhd
trb_net16_ibuf.vhd
trb_net16_io_multiplexer.vhd
trb_net16_obuf.vhd
trb_net_std.vhd

index 9b291aa0c537e7e7365d25adbc1c0696f3d8ddd5..7955041be4002da383cd63eff683ecd835c801a7 100644 (file)
@@ -533,7 +533,7 @@ APL_SEND_IN(0) <= not APL_RUN_OUT(0);
                   when others =>
                     IPU_DATA_IN((i*32+31) downto i*32) <= std_logic_vector(to_unsigned(counter(i)+1000,16)) & std_logic_vector(to_unsigned(counter(i),16));
                 end case;
-                if counter(i) = i+2 then
+                if counter(i) = i+2 then --normal: 2
                   IPU_DATAREADY_IN(i) <= '0';
                   IPU_READOUT_FINISHED_IN(i) <= '1';
                   state(i) <= 3;
index 8b5d64b8586ea2c599532a6a6966f7ea61a3653c..4e9a9f0a20edfebf6c82ab79c65cd9ffbd437de3 100644 (file)
@@ -14,8 +14,8 @@ entity trb_net16_api_base is
     FORCE_REPLY       : integer range 0 to 1 := std_FORCE_REPLY;
     SBUF_VERSION      : integer range 0 to 1 := std_SBUF_VERSION;
     USE_VENDOR_CORES  : integer range 0 to 1 := c_YES;
-    SECURE_MODE_TO_APL: integer range 0 to 1 := c_YES;
-    SECURE_MODE_TO_INT: integer range 0 to 1 := c_YES;
+    SECURE_MODE_TO_APL: integer range 0 to 1 := c_NO;
+    SECURE_MODE_TO_INT: integer range 0 to 1 := c_NO;
     APL_WRITE_ALL_WORDS:integer range 0 to 1 := c_NO;
     BROADCAST_BITMASK : std_logic_vector(7 downto 0) := x"FF"
     );
@@ -821,7 +821,7 @@ INT_MASTER_DATAREADY_OUT  <= buf_INT_MASTER_DATAREADY_OUT;
             end if;
           when RUNNING =>
             fifo_to_int_read <= not fifo_to_int_empty and sbuf_free and not master_counter(2);
-            next_INT_MASTER_DATAREADY_OUT <= sbuf_free and (fifo_to_int_read_before or master_counter(2));
+            next_INT_MASTER_DATAREADY_OUT <= sbuf_free and (fifo_to_int_read_before or (master_counter(2) and not fifo_to_int_empty);
             if APL_SEND_IN = '0' then --and fifo_was_not_empty = '1' then       -- terminate the transfer
               update_registered_trailer <= '1';
               if fifo_to_int_empty = '1' and master_counter = c_F3 and sbuf_free = '1' then
index ec1fe9d620602b9ec52c549fdb2960e6c50b75cb..22a163b1735df3f56a83de9f0eb6c03748e361c7 100644 (file)
@@ -80,8 +80,6 @@ entity trb_net16_endpoint_0_trg_1_api is
     STAT_api_control_signals: out std_logic_vector(31 downto 0);
     STAT_MPLEX:        out std_logic_vector(31 downto 0);
     CTRL_GEN:          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);
     MPLEX_CTRL: in  std_logic_vector (31 downto 0);
     API_STAT_FIFO_TO_INT: out std_logic_vector(31 downto 0);
     API_STAT_FIFO_TO_APL: out std_logic_vector(31 downto 0);
@@ -153,7 +151,6 @@ architecture trb_net16_endpoint_0_trg_1_api_arch of trb_net16_endpoint_0_trg_1_a
       STAT_GEN:               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);
-      STAT_CTRL_IBUF_BUFFER:  in  std_logic_vector (31 downto 0);
       STAT_INIT_OBUF_DEBUG      : out std_logic_vector (31 downto 0);
       STAT_REPLY_OBUF_DEBUG     : out std_logic_vector (31 downto 0)
       );
@@ -598,7 +595,6 @@ IOBUF: trb_net16_iobuf
     STAT_GEN               => STAT_GEN,
     STAT_IBUF_BUFFER       => buf_STAT_INIT_BUFFER,
     CTRL_GEN               => CTRL_GEN,
-    STAT_CTRL_IBUF_BUFFER  => STAT_CTRL_INIT_BUFFER,
     STAT_INIT_OBUF_DEBUG   => STAT_INIT_OBUF_DEBUG,
     STAT_REPLY_OBUF_DEBUG  => STAT_REPLY_OBUF_DEBUG
     );
index 9973b7e50da9e762e3e56bd9ca8e239789d808fb..6a612ceb9396e1c0b5e356b7d940bd8ac64f872a 100644 (file)
@@ -21,23 +21,12 @@ entity trb_net16_hub_base is
     COMPILE_VERSION         : std_logic_vector(15 downto 0) := x"0001";
     HARDWARE_VERSION        : std_logic_vector(31 downto 0) := x"12345678";
   --media interfaces
-    MII_NUMBER              : integer range 2 to c_MAX_MII_PER_HUB := 2;
+    MII_NUMBER              : integer range 2 to c_MAX_MII_PER_HUB := 4;
     MII_IBUF_DEPTH          : hub_iobuf_config_t := std_HUB_IBUF_DEPTH;
-  -- settings for apis
-    API_NUMBER              : integer range 0 to c_MAX_API_PER_HUB := 0;
-    API_CHANNELS            : hub_api_config_t := (3,3,3,3,3,3,3,3);
-    API_TYPE                : hub_api_config_t := (0,0,0,0,0,0,0,0);
-    API_FIFO_TO_INT_DEPTH   : hub_api_config_t := (1,1,1,1,1,1,1,1);
-    API_FIFO_TO_APL_DEPTH   : hub_api_config_t := (1,1,1,1,1,1,1,1);
-    SECURE_MODE_TO_APL      : integer range 0 to 1 := c_YES;
-    SECURE_MODE_TO_INT      : integer range 0 to 1 := c_YES;
-    APL_WRITE_ALL_WORDS     : hub_api_config_t := (0,0,0,0,0,0,0,0);
-    BROADCAST_BITMASK       : hub_api_broadcast_t := (x"FF",x"FF",x"FF",x"FF",x"FF",x"FF",x"FF",x"FF");
-
-  --trigger reading interfaces
-    TRG_NUMBER              : integer range 0 to c_MAX_TRG_PER_HUB := 0;
-    TRG_SECURE_MODE         : integer range 0 to 1 := c_NO;
-    TRG_CHANNELS            : hub_api_config_t := (0,1,0,0,0,0,0,0)
+  -- settings for external api connections
+    INT_NUMBER              : integer range 0 to c_MAX_API_PER_HUB := 0;
+    INT_CHANNELS            : hub_api_config_t := (3,3,3,3,3,3,3,3);
+    INT_IBUF_DEPTH          : hub_api_config_t := (6,6,6,6,6,6,6,6)
     );
   port (
     CLK    : in std_logic;
@@ -55,25 +44,23 @@ entity trb_net16_hub_base is
     MED_READ_OUT      : out std_logic_vector (MII_NUMBER-1 downto 0);
     MED_STAT_OP       : in  std_logic_vector (MII_NUMBER*16-1 downto 0);
     MED_CTRL_OP       : out std_logic_vector (MII_NUMBER*16-1 downto 0);
-    --API: interfaces
-    APL_DATA_IN           : in  std_logic_vector (VAL(API_NUMBER*c_DATA_WIDTH) downto 0);
-    APL_PACKET_NUM_IN     : in  std_logic_vector (VAL(API_NUMBER*c_NUM_WIDTH) downto 0);
-    APL_DATAREADY_IN      : in  std_logic_vector (VAL(API_NUMBER) downto 0);
-    APL_READ_OUT          : out std_logic_vector (VAL(API_NUMBER) downto 0);
-    APL_SHORT_TRANSFER_IN : in  std_logic_vector (VAL(API_NUMBER) downto 0);
-    APL_DTYPE_IN          : in  std_logic_vector (VAL(API_NUMBER*4) downto 0);
-    APL_ERROR_PATTERN_IN  : in  std_logic_vector (VAL(API_NUMBER*32) downto 0);
-    APL_SEND_IN           : in  std_logic_vector (VAL(API_NUMBER) downto 0);
-    APL_TARGET_ADDRESS_IN : in  std_logic_vector (VAL(API_NUMBER*16) downto 0);
-    APL_DATA_OUT          : out std_logic_vector (VAL(API_NUMBER*c_DATA_WIDTH) downto 0);
-    APL_PACKET_NUM_OUT    : out std_logic_vector (VAL(API_NUMBER*c_NUM_WIDTH) downto 0);
-    APL_TYP_OUT           : out std_logic_vector (VAL(API_NUMBER*3) downto 0);
-    APL_DATAREADY_OUT     : out std_logic_vector (VAL(API_NUMBER) downto 0);
-    APL_READ_IN           : in  std_logic_vector (VAL(API_NUMBER) downto 0);
-    APL_RUN_OUT           : out std_logic_vector (VAL(API_NUMBER) downto 0);
-    APL_MY_ADDRESS_IN     : in  std_logic_vector (VAL(API_NUMBER*16) downto 0);
-    APL_SEQNR_OUT         : out std_logic_vector (VAL(API_NUMBER*8) downto 0);
-    APL_LENGTH_IN         : in  std_logic_vector (VAL(API_NUMBER*16) downto 0);
+    --INT: interfaces to connect APIs
+    INT_INIT_DATAREADY_OUT    : out std_logic_vector (INT_NUMBER downto 0);
+    INT_INIT_DATA_OUT         : out std_logic_vector (INT_NUMBER*c_DATA_WIDTH downto 0);
+    INT_INIT_PACKET_NUM_OUT   : out std_logic_vector (INT_NUMBER*c_NUM_WIDTH  downto 0);
+    INT_INIT_READ_IN          : in  std_logic_vector (INT_NUMBER downto 0) := (others => '0');
+    INT_INIT_DATAREADY_IN     : in  std_logic_vector (INT_NUMBER downto 0) := (others => '0');
+    INT_INIT_DATA_IN          : in  std_logic_vector (INT_NUMBER*c_DATA_WIDTH downto 0) := (others => '0');
+    INT_INIT_PACKET_NUM_IN    : in  std_logic_vector (INT_NUMBER*c_NUM_WIDTH  downto 0) := (others => '0');
+    INT_INIT_READ_OUT         : out std_logic_vector (INT_NUMBER downto 0);
+    INT_REPLY_DATAREADY_OUT   : out std_logic_vector (INT_NUMBER downto 0);
+    INT_REPLY_DATA_OUT        : out std_logic_vector (INT_NUMBER*c_DATA_WIDTH downto 0);
+    INT_REPLY_PACKET_NUM_OUT  : out std_logic_vector (INT_NUMBER*c_NUM_WIDTH  downto 0);
+    INT_REPLY_READ_IN         : in  std_logic_vector (INT_NUMBER downto 0) := (others => '0');
+    INT_REPLY_DATAREADY_IN    : in  std_logic_vector (INT_NUMBER downto 0) := (others => '0');
+    INT_REPLY_DATA_IN         : in  std_logic_vector (INT_NUMBER*c_DATA_WIDTH downto 0) := (others => '0');
+    INT_REPLY_PACKET_NUM_IN   : in  std_logic_vector (INT_NUMBER*c_NUM_WIDTH downto 0) := (others => '0');
+    INT_REPLY_READ_OUT        : out std_logic_vector (INT_NUMBER downto 0);
     ONEWIRE               : inout std_logic;
     --Fixed status and control ports
     HUB_STAT_CHANNEL      : out std_logic_vector (2**(c_MUX_WIDTH-1)*16-1 downto 0);
@@ -97,7 +84,7 @@ entity trb_net16_hub_base is
 end entity;
 
 architecture trb_net16_hub_base_arch of trb_net16_hub_base is
-  constant total_point_num : integer := MII_NUMBER*2**(c_MUX_WIDTH-1) + API_NUMBER + TRG_NUMBER + 1;
+  constant total_point_num : integer := MII_NUMBER*2**(c_MUX_WIDTH-1) + INT_NUMBER + 1;
   signal m_DATAREADY_OUT : std_logic_vector (MII_NUMBER*2**(c_MUX_WIDTH)-1 downto 0);
   signal m_DATA_OUT      : std_logic_vector (MII_NUMBER*2**(c_MUX_WIDTH)*c_DATA_WIDTH-1 downto 0);
   signal m_PACKET_NUM_OUT: std_logic_vector (MII_NUMBER*2**(c_MUX_WIDTH)*c_NUM_WIDTH-1 downto 0);
@@ -127,7 +114,6 @@ architecture trb_net16_hub_base_arch of trb_net16_hub_base is
   signal buf_to_hub_REPLY_DATA        : std_logic_vector (total_point_num*c_DATA_WIDTH-1 downto 0);
   signal buf_to_hub_REPLY_PACKET_NUM  : std_logic_vector (total_point_num*c_NUM_WIDTH-1 downto 0);
   signal buf_to_hub_REPLY_READ        : std_logic_vector (total_point_num-1 downto 0);
-  signal buf_to_hub_REPLY_SEND_HEADER : std_logic_vector (total_point_num-1 downto 0);
 
   signal HUB_INIT_DATAREADY_OUT    : std_logic_vector (total_point_num-1 downto 0);
   signal HUB_INIT_DATA_OUT         : std_logic_vector (total_point_num*c_DATA_WIDTH-1 downto 0);
@@ -145,7 +131,6 @@ architecture trb_net16_hub_base_arch of trb_net16_hub_base is
   signal HUB_REPLY_DATA_IN         : std_logic_vector (total_point_num*c_DATA_WIDTH-1 downto 0);
   signal HUB_REPLY_PACKET_NUM_IN   : std_logic_vector (total_point_num*c_NUM_WIDTH-1 downto 0);
   signal HUB_REPLY_READ_OUT        : std_logic_vector (total_point_num-1 downto 0);
-  signal HUB_REPLY_SEND_HEADER_OUT : std_logic_vector (total_point_num-1 downto 0);
 
   signal buf_HUB_STAT_CHANNEL      : std_logic_vector (2**(c_MUX_WIDTH-1)*16-1 downto 0);
   signal buf_STAT_POINTS_locked    : std_logic_vector (2**(c_MUX_WIDTH-1)*32-1 downto 0);
@@ -164,7 +149,6 @@ architecture trb_net16_hub_base_arch of trb_net16_hub_base is
   signal HC_DTYPE_IN      :  std_logic_vector (3 downto 0);
   signal HC_ERROR_PATTERN_IN :   std_logic_vector (31 downto 0);
   signal HC_SEND_IN       :  std_logic;
-  signal HC_TARGET_ADDRESS_IN :  std_logic_vector (15 downto 0);
   signal HC_DATA_OUT      :  std_logic_vector (c_DATA_WIDTH-1 downto 0);
   signal HC_PACKET_NUM_OUT:  std_logic_vector (c_NUM_WIDTH-1 downto 0);
   signal HC_TYP_OUT       :  std_logic_vector (2 downto 0);
@@ -184,18 +168,16 @@ architecture trb_net16_hub_base_arch of trb_net16_hub_base is
   signal HUB_CTRL_activepoints        : std_logic_vector (2**(c_MUX_WIDTH-1)*32-1 downto 0);
   signal HUB_CTRL_GEN                 : std_logic_vector (31 downto 0);
   signal HUB_ADDRESS                  : std_logic_vector (15 downto 0);
-  singal HUBLOGIC_IPU_STAT_DEBUG      : std_logic_vector (31 downto 0);
+  signal HUBLOGIC_IPU_STAT_DEBUG      : std_logic_vector (31 downto 0);
 
-  signal IOBUF_STAT_GEN               :  std_logic_vector ((MII_NUMBER*2**(c_MUX_WIDTH-1) + API_NUMBER + TRG_NUMBER)*32-1 downto 0);
-  signal IOBUF_IBUF_BUFFER            :  std_logic_vector ((MII_NUMBER*2**(c_MUX_WIDTH-1) + API_NUMBER + TRG_NUMBER)*32-1 downto 0);
-  signal IOBUF_CTRL_GEN               :  std_logic_vector ((MII_NUMBER*2**(c_MUX_WIDTH-1) + API_NUMBER + TRG_NUMBER)*32-1 downto 0);
-  signal IOBUF_STAT_INIT_OBUF_DEBUG   :  std_logic_vector ((MII_NUMBER*2**(c_MUX_WIDTH-1) + API_NUMBER + TRG_NUMBER)*32-1 downto 0);
-  signal IOBUF_STAT_REPLY_OBUF_DEBUG  :  std_logic_vector ((MII_NUMBER*2**(c_MUX_WIDTH-1) + API_NUMBER + TRG_NUMBER)*32-1 downto 0);
+  signal IOBUF_STAT_GEN               :  std_logic_vector ((MII_NUMBER*2**(c_MUX_WIDTH-1))*32-1 downto 0);
+  signal IOBUF_IBUF_BUFFER            :  std_logic_vector ((MII_NUMBER*2**(c_MUX_WIDTH-1))*32-1 downto 0);
+  signal IOBUF_CTRL_GEN               :  std_logic_vector ((MII_NUMBER*2**(c_MUX_WIDTH-1))*32-1 downto 0);
+  signal IOBUF_STAT_INIT_OBUF_DEBUG   :  std_logic_vector ((MII_NUMBER*2**(c_MUX_WIDTH-1))*32-1 downto 0);
+  signal IOBUF_STAT_REPLY_OBUF_DEBUG  :  std_logic_vector ((MII_NUMBER*2**(c_MUX_WIDTH-1))*32-1 downto 0);
 
   signal resync : std_logic_vector(MII_NUMBER-1 downto 0);
   signal combined_resync : std_logic;
-  signal reg_resync : std_logic;
-  signal resync_counter : std_logic_vector(7 downto 0);
   signal IDRAM_DATA_IN, IDRAM_DATA_OUT : std_logic_vector(15 downto 0);
   signal IDRAM_WR_IN : std_logic;
   signal IDRAM_ADDR_IN : std_logic_vector(2 downto 0);
@@ -626,7 +608,7 @@ MED_DATA_OUT       <= buf_MED_DATA_OUT;
       gen_iobuf: if HUB_USED_CHANNELS(k) = 1 generate
         IOBUF: trb_net16_iobuf
           generic map (
-            IBUF_DEPTH =>  calc_depth(i,MII_IBUF_DEPTH, API_FIFO_TO_APL_DEPTH, MII_NUMBER, API_NUMBER, c_MUX_WIDTH, HUB_CTRL_DEPTH),
+            IBUF_DEPTH =>  calc_depth(i,MII_IBUF_DEPTH, INT_IBUF_DEPTH, MII_NUMBER, INT_NUMBER, c_MUX_WIDTH, HUB_CTRL_DEPTH),
             USE_CHECKSUM          => USE_CHECKSUM(k),
             IBUF_SECURE_MODE      => IBUF_SECURE_MODE,
             SBUF_VERSION          => std_SBUF_VERSION,
@@ -732,7 +714,7 @@ MED_DATA_OUT       <= buf_MED_DATA_OUT;
         APL_DTYPE_IN          => HC_DTYPE_IN(3 downto 0),
         APL_ERROR_PATTERN_IN  => HC_ERROR_PATTERN_IN(31 downto 0),
         APL_SEND_IN           => HC_SEND_IN,
-        APL_TARGET_ADDRESS_IN => HC_TARGET_ADDRESS_IN(15 downto 0),
+        APL_TARGET_ADDRESS_IN => (others => '0'),
         -- Receiver port
         APL_DATA_OUT          => HC_DATA_OUT(c_DATA_WIDTH-1 downto 0),
         APL_PACKET_NUM_OUT    => HC_PACKET_NUM_OUT(c_NUM_WIDTH-1 downto 0),
@@ -766,181 +748,43 @@ MED_DATA_OUT       <= buf_MED_DATA_OUT;
         STAT_FIFO_TO_APL          => open
         );
   end generate;
-  gen_apisa : if API_NUMBER /= 0 generate
-    gen_apis : for i in 2**(c_MUX_WIDTH-1)*MII_NUMBER+1 to 2**(c_MUX_WIDTH-1)*MII_NUMBER+API_NUMBER generate
-                      --+1 because of hub_ctrl
-      constant offset : integer := 2**(c_MUX_WIDTH-1)*MII_NUMBER + 1;
-      constant aploffset : integer := i - offset;
+  gen_int : if INT_NUMBER /= 0 generate
+    gen_int1 : for i in 0 to INT_NUMBER-1 generate
+      constant j : integer := i + 2**(c_MUX_WIDTH-1)*MII_NUMBER+1;
     begin
-      gen_pas_api : if API_TYPE(aploffset) = 0 generate
-        constant t : integer := 0;
-      begin
-        PAS_API : trb_net16_api_base
-          generic map(
-            API_TYPE               => API_TYPE(aploffset),
-            FIFO_TO_INT_DEPTH      => API_FIFO_TO_INT_DEPTH(aploffset),
-            FIFO_TO_APL_DEPTH      => API_FIFO_TO_APL_DEPTH(aploffset),
-            FORCE_REPLY            => cfg_FORCE_REPLY(API_CHANNELS(aploffset)),
-            SBUF_VERSION           => std_SBUF_VERSION,
-            USE_VENDOR_CORES       => USE_VENDOR_CORES,
-            SECURE_MODE_TO_APL     => SECURE_MODE_TO_APL,
-            SECURE_MODE_TO_INT     => SECURE_MODE_TO_INT,
-            APL_WRITE_ALL_WORDS    => APL_WRITE_ALL_WORDS(aploffset),
-            BROADCAST_BITMASK      => BROADCAST_BITMASK(aploffset)
-            )
-          port map(
-            --  Misc
-            CLK    => CLK,
-            RESET  => RESET,
-            CLK_EN => CLK_EN,
-            -- APL Transmitter port
-            APL_DATA_IN           => APL_DATA_IN((aploffset+1)*c_DATA_WIDTH-1 downto aploffset * c_DATA_WIDTH),
-            APL_PACKET_NUM_IN     => APL_PACKET_NUM_IN((aploffset+1)*c_NUM_WIDTH-1 downto aploffset * c_NUM_WIDTH),
-            APL_DATAREADY_IN      => APL_DATAREADY_IN(aploffset),
-            APL_READ_OUT          => APL_READ_OUT(aploffset),
-            APL_SHORT_TRANSFER_IN => APL_SHORT_TRANSFER_IN(aploffset),
-            APL_DTYPE_IN          => APL_DTYPE_IN((aploffset+1)*4-1 downto aploffset*4),
-            APL_ERROR_PATTERN_IN  => APL_ERROR_PATTERN_IN((aploffset+1)*32-1 downto aploffset*32),
-            APL_SEND_IN           => APL_SEND_IN(aploffset),
-            APL_TARGET_ADDRESS_IN => APL_TARGET_ADDRESS_IN((aploffset+1)*16-1 downto aploffset*16),
-            -- Receiver port
-            APL_DATA_OUT          => APL_DATA_OUT((aploffset+1)*c_DATA_WIDTH-1 downto aploffset * c_DATA_WIDTH),
-            APL_PACKET_NUM_OUT    => APL_PACKET_NUM_OUT((aploffset+1)*c_NUM_WIDTH-1 downto aploffset * c_NUM_WIDTH),
-            APL_TYP_OUT           => APL_TYP_OUT((aploffset+1)*3-1 downto aploffset*3),
-            APL_DATAREADY_OUT     => APL_DATAREADY_OUT(aploffset),
-            APL_READ_IN           => APL_READ_IN(aploffset),
-            -- APL Control port
-            APL_RUN_OUT           => APL_RUN_OUT(aploffset),
-            APL_MY_ADDRESS_IN     => APL_MY_ADDRESS_IN((aploffset+1)*16-1 downto aploffset*16),
-            APL_SEQNR_OUT         => APL_SEQNR_OUT((aploffset+1)*8-1 downto aploffset*8),
-            APL_LENGTH_IN         => APL_LENGTH_IN((aploffset+1)*16-1 downto aploffset*16),
-            -- Internal direction port
-            INT_MASTER_DATAREADY_OUT  => buf_to_hub_REPLY_DATAREADY(i),
-            INT_MASTER_DATA_OUT       => buf_to_hub_REPLY_DATA((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH),
-            INT_MASTER_PACKET_NUM_OUT => buf_to_hub_REPLY_PACKET_NUM((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH),
-            INT_MASTER_READ_IN        => buf_to_hub_REPLY_READ(i),
-            INT_MASTER_DATAREADY_IN   => hub_to_buf_REPLY_DATAREADY(i),
-            INT_MASTER_DATA_IN        => hub_to_buf_REPLY_DATA((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH),
-            INT_MASTER_PACKET_NUM_IN  => hub_to_buf_REPLY_PACKET_NUM((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH),
-            INT_MASTER_READ_OUT       => hub_to_buf_REPLY_READ(i),
-            INT_SLAVE_DATAREADY_OUT   => buf_to_hub_INIT_DATAREADY(i),
-            INT_SLAVE_DATA_OUT        => buf_to_hub_INIT_DATA((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH),
-            INT_SLAVE_PACKET_NUM_OUT  => buf_to_hub_INIT_PACKET_NUM((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH),
-            INT_SLAVE_READ_IN         => buf_to_hub_INIT_READ(i),
-            INT_SLAVE_DATAREADY_IN    => hub_to_buf_INIT_DATAREADY(i),
-            INT_SLAVE_DATA_IN         => hub_to_buf_INIT_DATA((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH),
-            INT_SLAVE_PACKET_NUM_IN   => hub_to_buf_INIT_PACKET_NUM((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH),
-            INT_SLAVE_READ_OUT        => hub_to_buf_INIT_READ(i),
-            -- Status and control port
-            STAT_FIFO_TO_INT          => open,
-            STAT_FIFO_TO_APL          => open
-            );
-      end generate;
-      gen_act_api : if API_TYPE(aploffset) = 1 generate
-        constant t : integer := 0;
-      begin
-        ACT_API : trb_net16_api_base
-          generic map(
-            API_TYPE               => API_TYPE(aploffset),
-            FIFO_TO_INT_DEPTH      => API_FIFO_TO_INT_DEPTH(aploffset),
-            FIFO_TO_APL_DEPTH      => API_FIFO_TO_APL_DEPTH(aploffset),
-            FORCE_REPLY            => cfg_FORCE_REPLY(API_CHANNELS(aploffset)),
-            SBUF_VERSION           => std_SBUF_VERSION,
-            USE_VENDOR_CORES       => USE_VENDOR_CORES,
-            SECURE_MODE_TO_APL     => SECURE_MODE_TO_APL,
-            SECURE_MODE_TO_INT     => SECURE_MODE_TO_INT,
-            APL_WRITE_ALL_WORDS    => APL_WRITE_ALL_WORDS(aploffset),
-            BROADCAST_BITMASK      => BROADCAST_BITMASK(aploffset)
-            )
-          port map(
-            --  Misc
-            CLK    => CLK,
-            RESET  => RESET,
-            CLK_EN => CLK_EN,
-            -- APL Transmitter port
-            APL_DATA_IN           => APL_DATA_IN((aploffset+1)*c_DATA_WIDTH-1 downto aploffset * c_DATA_WIDTH),
-            APL_PACKET_NUM_IN     => APL_PACKET_NUM_IN((aploffset+1)*c_NUM_WIDTH-1 downto aploffset * c_NUM_WIDTH),
-            APL_DATAREADY_IN      => APL_DATAREADY_IN(aploffset),
-            APL_READ_OUT          => APL_READ_OUT(aploffset),
-            APL_SHORT_TRANSFER_IN => APL_SHORT_TRANSFER_IN(aploffset),
-            APL_DTYPE_IN          => APL_DTYPE_IN((aploffset+1)*4-1 downto aploffset*4),
-            APL_ERROR_PATTERN_IN  => APL_ERROR_PATTERN_IN((aploffset+1)*32-1 downto aploffset*32),
-            APL_SEND_IN           => APL_SEND_IN(aploffset),
-            APL_TARGET_ADDRESS_IN => APL_TARGET_ADDRESS_IN((aploffset+1)*16-1 downto aploffset*16),
-            -- Receiver port
-            APL_DATA_OUT          => APL_DATA_OUT((aploffset+1)*c_DATA_WIDTH-1 downto aploffset * c_DATA_WIDTH),
-            APL_PACKET_NUM_OUT    => APL_PACKET_NUM_OUT((aploffset+1)*c_NUM_WIDTH-1 downto aploffset * c_NUM_WIDTH),
-            APL_TYP_OUT           => APL_TYP_OUT((aploffset+1)*3-1 downto aploffset*3),
-            APL_DATAREADY_OUT     => APL_DATAREADY_OUT(aploffset),
-            APL_READ_IN           => APL_READ_IN(aploffset),
-            -- APL Control port
-            APL_RUN_OUT           => APL_RUN_OUT(aploffset),
-            APL_MY_ADDRESS_IN     => APL_MY_ADDRESS_IN((aploffset+1)*16-1 downto aploffset*16),
-            APL_SEQNR_OUT         => APL_SEQNR_OUT((aploffset+1)*8-1 downto aploffset*8),
-            APL_LENGTH_IN         => APL_LENGTH_IN((aploffset+1)*16-1 downto aploffset*16),
-            -- Internal direction port
-            INT_MASTER_DATAREADY_OUT  => buf_to_hub_INIT_DATAREADY(i),
-            INT_MASTER_DATA_OUT       => buf_to_hub_INIT_DATA((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH),
-            INT_MASTER_PACKET_NUM_OUT => buf_to_hub_INIT_PACKET_NUM((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH),
-            INT_MASTER_READ_IN        => buf_to_hub_INIT_READ(i),
-            INT_MASTER_DATAREADY_IN   => hub_to_buf_INIT_DATAREADY(i),
-            INT_MASTER_DATA_IN        => hub_to_buf_INIT_DATA((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH),
-            INT_MASTER_PACKET_NUM_IN  => hub_to_buf_INIT_PACKET_NUM((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH),
-            INT_MASTER_READ_OUT       => hub_to_buf_INIT_READ(i),
-            INT_SLAVE_DATAREADY_OUT   => buf_to_hub_REPLY_DATAREADY(i),
-            INT_SLAVE_DATA_OUT        => buf_to_hub_REPLY_DATA((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH),
-            INT_SLAVE_PACKET_NUM_OUT  => buf_to_hub_REPLY_PACKET_NUM((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH),
-            INT_SLAVE_READ_IN         => buf_to_hub_REPLY_READ(i),
-            INT_SLAVE_DATAREADY_IN    => hub_to_buf_REPLY_DATAREADY(i),
-            INT_SLAVE_DATA_IN         => hub_to_buf_REPLY_DATA((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH),
-            INT_SLAVE_PACKET_NUM_IN   => hub_to_buf_REPLY_PACKET_NUM((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH),
-            INT_SLAVE_READ_OUT        => hub_to_buf_REPLY_READ(i),
-            -- Status and control port
-            STAT_FIFO_TO_INT          => open,
-            STAT_FIFO_TO_APL          => open
-            );
-      end generate;
+      buf_to_hub_REPLY_DATAREADY(j) <= INT_REPLY_DATAREADY_IN(i);
+      buf_to_hub_REPLY_DATA((j+1)*c_DATA_WIDTH-1 downto j*c_DATA_WIDTH) <= INT_REPLY_DATA_IN((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH);
+      buf_to_hub_REPLY_PACKET_NUM((j+1)*c_NUM_WIDTH-1 downto j*c_NUM_WIDTH) <= INT_REPLY_PACKET_NUM_IN((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH);
+      INT_REPLY_READ_OUT(i)       <= buf_to_hub_REPLY_READ(j);
+
+      INT_REPLY_DATAREADY_OUT(i)  <= hub_to_buf_REPLY_DATAREADY(j);
+      INT_REPLY_DATA_OUT((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH)<= hub_to_buf_REPLY_DATA((j+1)*c_DATA_WIDTH-1 downto j*c_DATA_WIDTH);
+      INT_REPLY_PACKET_NUM_OUT((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH) <= hub_to_buf_REPLY_PACKET_NUM((j+1)*c_NUM_WIDTH-1 downto j*c_NUM_WIDTH);
+      hub_to_buf_REPLY_READ(j) <= INT_REPLY_READ_IN(i);
+      buf_to_hub_INIT_DATAREADY(j) <= INT_INIT_DATAREADY_IN(i);
+      buf_to_hub_INIT_DATA((j+1)*c_DATA_WIDTH-1 downto j*c_DATA_WIDTH) <= INT_INIT_DATA_IN((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH);
+      buf_to_hub_INIT_PACKET_NUM((j+1)*c_NUM_WIDTH-1 downto j*c_NUM_WIDTH) <= INT_INIT_PACKET_NUM_IN((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH);
+      INT_INIT_READ_OUT(i)        <= buf_to_hub_INIT_READ(j);
+      INT_INIT_DATAREADY_OUT(i)   <= hub_to_buf_INIT_DATAREADY(j);
+      INT_INIT_DATA_OUT((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH) <= hub_to_buf_INIT_DATA((j+1)*c_DATA_WIDTH-1 downto j*c_DATA_WIDTH);
+      INT_INIT_PACKET_NUM_OUT((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH)  <= hub_to_buf_INIT_PACKET_NUM((j+1)*c_NUM_WIDTH-1 downto j*c_NUM_WIDTH);
+      hub_to_buf_INIT_READ(j) <= INT_INIT_READ_IN(i);
     end generate;
   end generate;
+  INT_INIT_DATAREADY_OUT(INT_NUMBER) <= '0';
+  INT_INIT_DATA_OUT(INT_NUMBER*c_DATA_WIDTH) <= '0';
+  INT_INIT_PACKET_NUM_OUT(INT_NUMBER*c_NUM_WIDTH) <= '0';
+  INT_INIT_READ_OUT(INT_NUMBER) <= '0';
+  INT_REPLY_DATAREADY_OUT(INT_NUMBER) <= '0';
+  INT_REPLY_DATA_OUT(INT_NUMBER*c_DATA_WIDTH) <= '0';
+  INT_REPLY_PACKET_NUM_OUT(INT_NUMBER*c_NUM_WIDTH) <= '0';
+  INT_REPLY_READ_OUT(INT_NUMBER) <= '0';
 
---  gen_trgapi : if TRG_NUMBER /= 0 generate
---    gen_apis : for i in 2**(c_MUX_WIDTH-1)*MII_NUMBER+1+API_NUMBER to 2**(c_MUX_WIDTH-1)*MII_NUMBER+API_NUMBER+TRG_NUMBER generate
---      constant trg_offset : integer := i -  (2**(c_MUX_WIDTH-1)*MII_NUMBER+1+API_NUMBER);
---    begin
---     TRG : trb_net16_term
---       generic map (
---         SECURE_MODE => TRG_SECURE_MODE
---         )
---       port map(
---         --  Misc
---         CLK     => CLK,
---         RESET   => RESET,
---         CLK_EN  => CLK_EN,
---         INT_DATAREADY_OUT     => buf_to_hub_REPLY_DATAREADY(i),
---         INT_DATA_OUT          => buf_to_hub_REPLY_DATA((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH),
---         INT_PACKET_NUM_OUT    => buf_to_hub_REPLY_PACKET_NUM((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH),
---         INT_READ_IN           => buf_to_hub_REPLY_READ(i),
---         INT_DATAREADY_IN      => hub_to_buf_INIT_DATAREADY(i),
---         INT_DATA_IN           => hub_to_buf_INIT_DATA((i+1)*c_DATA_WIDTH-1 downto i*c_DATA_WIDTH),
---         INT_PACKET_NUM_IN     => hub_to_buf_INIT_PACKET_NUM((i+1)*c_NUM_WIDTH-1 downto i*c_NUM_WIDTH),
---         INT_READ_OUT          => hub_to_buf_INIT_READ(i),
---         -- "mini" APL, just to see the triggers coming in
---         APL_DTYPE_OUT         => TRG_DTYPE_OUT((trg_offset+1)*3-1 downto trg_offset*3),
---         APL_ERROR_PATTERN_OUT => TRG_ERROR_PATTERN_OUT((trg_offset+1)*32-1 downto trg_offset*32),
---         APL_SEQNR_OUT         => TRG_SEQNR_OUT((trg_offset+1)*8-1 downto trg_offset*8),
---         APL_GOT_TRM           => TRG_GOT_TRIGGER_OUT(trg_offset),
---         APL_RELEASE_TRM       => TRG_RELEASE_IN(trg_offset),
---         APL_ERROR_PATTERN_IN  => TRG_ERROR_PATTERN_IN((trg_offset+1)*32-1 downto trg_offset*32)
---         -- Status and control port
---         );
---    end generate;
---  end generate;
 
 --rearrange vectors for hub logic
   gen_rearrange : for CHANNEL in 0 to 2**(c_MUX_WIDTH-1)-1 generate
-    constant api_num         : integer := calc_special_number(CHANNEL, API_NUMBER, API_CHANNELS);
-    constant trg_num         : integer := calc_special_number(CHANNEL, 0, TRG_CHANNELS);
-    constant first_point_num : integer := calc_first_point_number(MII_NUMBER, CHANNEL, HUB_CTRL_CHANNELNUM, API_NUMBER, API_CHANNELS, 0, TRG_CHANNELS);
+    constant int_num         : integer := calc_special_number(CHANNEL, INT_NUMBER, INT_CHANNELS);
+    constant first_point_num : integer := calc_first_point_number(MII_NUMBER, CHANNEL, HUB_CTRL_CHANNELNUM, INT_NUMBER, INT_CHANNELS);
     constant is_ctrl_channel : integer := calc_is_ctrl_channel(CHANNEL, HUB_CTRL_CHANNELNUM);
   begin
     gen_hublogicsignals1 : for mii in 0 to MII_NUMBER-1 generate
@@ -1023,13 +867,13 @@ MED_DATA_OUT       <= buf_MED_DATA_OUT;
       HUB_REPLY_READ_IN (hublogic_num)
                                 <= hub_to_buf_REPLY_READ(buf_to_hub_num);
     end generate;
-    g5: if api_num /= 0 generate
-      gen_hublogicsignals2 : for api in 0 to API_NUMBER-1 generate
-        constant hublogic_num   : integer := first_point_num + MII_NUMBER + is_ctrl_channel + calc_special_number(CHANNEL, api, API_CHANNELS);
-        constant buf_to_hub_num : integer := 2**(c_MUX_WIDTH-1)*MII_NUMBER + 1 + api;
+    g5: if int_num /= 0 generate
+      gen_hublogicsignals2 : for int in 0 to INT_NUMBER-1 generate
+        constant hublogic_num   : integer := first_point_num + MII_NUMBER + is_ctrl_channel + calc_special_number(CHANNEL, int, INT_CHANNELS);
+        constant buf_to_hub_num : integer := 2**(c_MUX_WIDTH-1)*MII_NUMBER + 1 + int;
                     --calc_special_number(CHANNEL, api, API_CHANNELS)
       begin
-        h1: if API_CHANNELS(api) = CHANNEL generate
+        h1: if INT_CHANNELS(int) = CHANNEL generate
           HUB_INIT_DATAREADY_IN (hublogic_num)
                                     <= buf_to_hub_INIT_DATAREADY(buf_to_hub_num);
           HUB_INIT_DATA_IN ((hublogic_num+1)*c_DATA_WIDTH-1 downto hublogic_num*c_DATA_WIDTH)
@@ -1068,50 +912,6 @@ MED_DATA_OUT       <= buf_MED_DATA_OUT;
         end generate;
       end generate;
     end generate;
---     g3: if trg_num /= 0 generate
---       gen_hublogicsignals3 : for trg in 0 to TRG_NUMBER-1 generate
---         constant hublogic_num   : integer := first_point_num + MII_NUMBER + is_ctrl_channel + calc_special_number(CHANNEL, API_NUMBER, API_CHANNELS) + calc_special_number(CHANNEL, trg, TRG_CHANNELS);
---         constant buf_to_hub_num : integer := 2**(c_MUX_WIDTH-1)*MII_NUMBER + 1 + API_NUMBER + trg;
---       begin
---         h1: if TRG_CHANNELS(trg) = CHANNEL generate
---           HUB_INIT_DATAREADY_IN (hublogic_num)
---                                     <= buf_to_hub_INIT_DATAREADY(buf_to_hub_num);
---           HUB_INIT_DATA_IN ((hublogic_num+1)*c_DATA_WIDTH-1 downto hublogic_num*c_DATA_WIDTH)
---                                     <= buf_to_hub_INIT_DATA((buf_to_hub_num+1)*c_DATA_WIDTH-1 downto buf_to_hub_num*c_DATA_WIDTH);
---           HUB_INIT_PACKET_NUM_IN ((hublogic_num+1)*c_NUM_WIDTH-1 downto hublogic_num*c_NUM_WIDTH)
---                                     <= buf_to_hub_INIT_PACKET_NUM((buf_to_hub_num+1)*c_NUM_WIDTH-1 downto buf_to_hub_num*c_NUM_WIDTH);
---           buf_to_hub_INIT_READ(buf_to_hub_num)
---                                     <= HUB_INIT_READ_OUT(hublogic_num);
---
---           hub_to_buf_INIT_DATAREADY(buf_to_hub_num)
---                                     <= HUB_INIT_DATAREADY_OUT(hublogic_num);
---           hub_to_buf_INIT_DATA((buf_to_hub_num+1)*c_DATA_WIDTH-1 downto buf_to_hub_num*c_DATA_WIDTH)
---                                     <= HUB_INIT_DATA_OUT((hublogic_num+1)*c_DATA_WIDTH-1 downto hublogic_num*c_DATA_WIDTH);
---           hub_to_buf_INIT_PACKET_NUM((buf_to_hub_num+1)*c_NUM_WIDTH-1 downto buf_to_hub_num*c_NUM_WIDTH)
---                                     <= HUB_INIT_PACKET_NUM_OUT((hublogic_num+1)*c_NUM_WIDTH-1 downto hublogic_num*c_NUM_WIDTH);
---           HUB_INIT_READ_IN (hublogic_num)
---                                     <= hub_to_buf_INIT_READ(buf_to_hub_num);
---
---           HUB_REPLY_DATAREADY_IN (hublogic_num)
---                                     <= buf_to_hub_REPLY_DATAREADY(buf_to_hub_num);
---           HUB_REPLY_DATA_IN ((hublogic_num+1)*c_DATA_WIDTH-1 downto hublogic_num*c_DATA_WIDTH)
---                                     <= buf_to_hub_REPLY_DATA((buf_to_hub_num+1)*c_DATA_WIDTH-1 downto buf_to_hub_num*c_DATA_WIDTH);
---           HUB_REPLY_PACKET_NUM_IN ((hublogic_num+1)*c_NUM_WIDTH-1 downto hublogic_num*c_NUM_WIDTH)
---                                     <= buf_to_hub_REPLY_PACKET_NUM((buf_to_hub_num+1)*c_NUM_WIDTH-1 downto buf_to_hub_num*c_NUM_WIDTH);
---           buf_to_hub_REPLY_READ(buf_to_hub_num)
---                                     <= HUB_REPLY_READ_OUT(hublogic_num);
---
---           hub_to_buf_REPLY_DATAREADY(buf_to_hub_num)
---                                     <= HUB_REPLY_DATAREADY_OUT(hublogic_num);
---           hub_to_buf_REPLY_DATA((buf_to_hub_num+1)*c_DATA_WIDTH-1 downto buf_to_hub_num*c_DATA_WIDTH)
---                                     <= HUB_REPLY_DATA_OUT((hublogic_num+1)*c_DATA_WIDTH-1 downto hublogic_num*c_DATA_WIDTH);
---           hub_to_buf_REPLY_PACKET_NUM((buf_to_hub_num+1)*c_NUM_WIDTH-1 downto buf_to_hub_num*c_NUM_WIDTH)
---                                     <= HUB_REPLY_PACKET_NUM_OUT((hublogic_num+1)*c_NUM_WIDTH-1 downto hublogic_num*c_NUM_WIDTH);
---           HUB_REPLY_READ_IN (hublogic_num)
---                                     <= hub_to_buf_REPLY_READ(buf_to_hub_num);
---         end generate;
---       end generate;
---     end generate;
   end generate;
 
   gen_MED_CON : for i in 0 to MII_NUMBER-1 generate
@@ -1123,7 +923,6 @@ MED_DATA_OUT       <= buf_MED_DATA_OUT;
           HUB_MED_CONNECTED(i) <= '1';
         end if;
       end process;
-
   end generate;
 
 
@@ -1132,8 +931,8 @@ HUB_MED_CONNECTED(31 downto MII_NUMBER) <= (others => '1');
 
 --generate hub logic
   gen_hub_logic: for i in 0 to 2**(c_MUX_WIDTH-1)-1 generate
-    constant point_num       : integer := calc_point_number      (MII_NUMBER, i, HUB_CTRL_CHANNELNUM, API_NUMBER, API_CHANNELS, 0, TRG_CHANNELS);
-    constant first_point_num : integer := calc_first_point_number(MII_NUMBER, i, HUB_CTRL_CHANNELNUM, API_NUMBER, API_CHANNELS, 0, TRG_CHANNELS);
+    constant point_num       : integer := calc_point_number      (MII_NUMBER, i, HUB_CTRL_CHANNELNUM, INT_NUMBER, INT_CHANNELS);
+    constant first_point_num : integer := calc_first_point_number(MII_NUMBER, i, HUB_CTRL_CHANNELNUM, INT_NUMBER, INT_CHANNELS);
     constant next_point_num  : integer := first_point_num + point_num;
   begin
     gen_logic : if HUB_USED_CHANNELS(i) = 1 generate
@@ -1156,7 +955,6 @@ HUB_MED_CONNECTED(31 downto MII_NUMBER) <= (others => '1');
             INIT_DATA_OUT         => HUB_INIT_DATA_OUT(next_point_num*c_DATA_WIDTH-1 downto first_point_num*c_DATA_WIDTH),
             INIT_PACKET_NUM_OUT   => HUB_INIT_PACKET_NUM_OUT(next_point_num*c_NUM_WIDTH-1 downto first_point_num*c_NUM_WIDTH),
             INIT_READ_IN          => HUB_INIT_READ_IN(next_point_num-1 downto first_point_num),
-            REPLY_HEADER_OUT      => HUB_REPLY_SEND_HEADER_OUT(next_point_num-1 downto first_point_num),
             REPLY_DATAREADY_IN    => HUB_REPLY_DATAREADY_IN(next_point_num-1 downto first_point_num),
             REPLY_DATA_IN         => HUB_REPLY_DATA_IN(next_point_num*c_DATA_WIDTH-1 downto first_point_num*c_DATA_WIDTH),
             REPLY_PACKET_NUM_IN   => HUB_REPLY_PACKET_NUM_IN(next_point_num*c_NUM_WIDTH-1 downto first_point_num*c_NUM_WIDTH),
@@ -1204,6 +1002,7 @@ HUB_MED_CONNECTED(31 downto MII_NUMBER) <= (others => '1');
             CTRL                  => HUB_CTRL_CHANNEL((i+1)*16-1 downto i*16),
             CTRL_activepoints     => HUB_CTRL_final_activepoints((i+1)*32-1 downto i*32)
             );
+            buf_HUB_STAT_CHANNEL((i+1)*16-1 downto i*16) <= (others => '0');
       end generate;
     end generate;
   end generate;
@@ -1333,7 +1132,7 @@ HUB_MED_CONNECTED(31 downto MII_NUMBER) <= (others => '1');
   HUB_CTRL_CHANNEL      <= HC_CTRL_REGS(160+2**(c_MUX_WIDTH-1)*16-1 downto 160);
 
 
-
+  IOBUF_CTRL_GEN <= (others => '0');
   --map regio registers to stat & ctrl outputs
   STAT_COMMON_STAT_REGS <= HC_COMMON_STAT_REGS;
   STAT_COMMON_CTRL_REGS <= HC_COMMON_CTRL_REGS;
index 081641f78a8034b836e36df01ca1e503e3819943..7a4f3c8e149d6aa96084283f2095f23f6e5a1e40 100644 (file)
@@ -38,28 +38,25 @@ package trb_net16_hub_func is
   function calc_point_number (MII_NUMBER   : integer;
                               CHANNEL      : integer;
                               HUB_CTRL_CHANNEL : integer;
-                              API_NUMBER   : integer;
-                              API_CHANNELS : hub_api_config_t;
-                              TRG_NUMBER   : integer;
-                              TRG_CHANNELS : hub_api_config_t)
+                              INT_NUMBER   : integer;
+                              INT_CHANNELS : hub_api_config_t)
     return integer;
 
-  function calc_depth(POINT           : integer;
-                      MII_DEPTH       : hub_iobuf_config_t;
-                      API_DEPTH       : hub_api_config_t;
-                      MII_NUMBER      : integer;
-                      API_NUMBER      : integer;
-                      MUX_WIDTH       : integer;
+  function calc_depth(POINT        : integer;
+                      MII_DEPTH    : hub_iobuf_config_t;
+                      INT_DEPTH    : hub_api_config_t;
+                      MII_NUMBER   : integer;
+                      INT_NUMBER   : integer;
+                      MUX_WIDTH    : integer;
                       HUB_CTRL_DEPTH : integer)
     return integer;
 
-  function calc_first_point_number (MII_NUMBER : integer;
-                              CHANNEL      : integer;
-                              HUB_CTRL_CHANNEL : integer;
-                              API_NUMBER   : integer;
-                              API_CHANNELS : hub_api_config_t;
-                              TRG_NUMBER   : integer;
-                              TRG_CHANNELS : hub_api_config_t)
+  function calc_first_point_number (MII_NUMBER   : integer;
+                                    CHANNEL      : integer;
+                                    HUB_CTRL_CHANNEL : integer;
+                                    INT_NUMBER   : integer;
+                                    INT_CHANNELS : hub_api_config_t
+                                    )
     return integer;
 
   function calc_special_number(CHANNEL  : integer;
@@ -111,10 +108,8 @@ package body trb_net16_hub_func is
   function calc_point_number (MII_NUMBER   : integer;
                               CHANNEL      : integer;
                               HUB_CTRL_CHANNEL : integer;
-                              API_NUMBER   : integer;
-                              API_CHANNELS : hub_api_config_t;
-                              TRG_NUMBER   : integer;
-                              TRG_CHANNELS : hub_api_config_t)
+                              INT_NUMBER   : integer;
+                              INT_CHANNELS : hub_api_config_t)
     return integer is
     variable tmp : integer := 0;
     begin
@@ -122,16 +117,9 @@ package body trb_net16_hub_func is
       if HUB_CTRL_CHANNEL = CHANNEL then
         tmp := tmp + 1;
       end if;
-      if API_NUMBER /= 0 then
-        for i in 0 to API_NUMBER-1 loop
-          if(API_CHANNELS(i) = CHANNEL) then
-            tmp := tmp + 1;
-          end if;
-        end loop;
-      end if;
-      if TRG_NUMBER /= 0 then
-        for i in 0 to TRG_NUMBER-1 loop
-          if(TRG_CHANNELS(i) = CHANNEL) then
+      if INT_NUMBER /= 0 then
+        for i in 0 to INT_NUMBER-1 loop
+          if(INT_CHANNELS(i) = CHANNEL) then
             tmp := tmp + 1;
           end if;
         end loop;
@@ -156,11 +144,12 @@ package body trb_net16_hub_func is
       return tmp;
     end function;
 
+
   function calc_depth(POINT        : integer;
                       MII_DEPTH    : hub_iobuf_config_t;
-                      API_DEPTH    : hub_api_config_t;
+                      INT_DEPTH    : hub_api_config_t;
                       MII_NUMBER   : integer;
-                      API_NUMBER   : integer;
+                      INT_NUMBER   : integer;
                       MUX_WIDTH    : integer;
                       HUB_CTRL_DEPTH : integer)
     return integer is
@@ -170,10 +159,10 @@ package body trb_net16_hub_func is
         return MII_DEPTH((POINT / 2**(MUX_WIDTH-1))*4 + (POINT mod 2**(MUX_WIDTH-1)));
       elsif(POINT = MII_NUMBER*2**(MUX_WIDTH-1)) then
         return HUB_CTRL_DEPTH;
-      elsif POINT < MII_NUMBER*2**(MUX_WIDTH-1) + API_NUMBER then
-        return API_DEPTH(POINT-(MII_NUMBER*2**(MUX_WIDTH-1)));
+      elsif POINT < MII_NUMBER*2**(MUX_WIDTH-1) + INT_NUMBER then
+        return INT_DEPTH(POINT-(MII_NUMBER*2**(MUX_WIDTH-1)));
       else
-        return 0;
+        return -1;
       end if;
     end function;
 
@@ -181,10 +170,9 @@ package body trb_net16_hub_func is
   function calc_first_point_number (MII_NUMBER   : integer;
                                     CHANNEL      : integer;
                                     HUB_CTRL_CHANNEL : integer;
-                                    API_NUMBER   : integer;
-                                    API_CHANNELS : hub_api_config_t;
-                                    TRG_NUMBER   : integer;
-                                    TRG_CHANNELS : hub_api_config_t)
+                                    INT_NUMBER   : integer;
+                                    INT_CHANNELS : hub_api_config_t
+                                    )
     return integer is
     variable tmp : integer := 0;
     begin
@@ -193,7 +181,7 @@ package body trb_net16_hub_func is
       end if;
       tmp := 0;
       for i in 0 to CHANNEL-1 loop
-        tmp := tmp + calc_point_number(MII_NUMBER,i,HUB_CTRL_CHANNEL,API_NUMBER,API_CHANNELS,TRG_NUMBER,TRG_CHANNELS);
+        tmp := tmp + calc_point_number(MII_NUMBER,i,HUB_CTRL_CHANNEL,INT_NUMBER,INT_CHANNELS);
       end loop;
       return tmp;
     end function;
index 108b43a4369adcb0958ef9a2c93dc6fa4cba2a25..efdc542a4348795699f0222ec297e94f32757912 100644 (file)
@@ -9,7 +9,7 @@ use work.trb_net_std.all;
 entity trb_net16_hub_ipu_logic is
   generic (
   --media interfaces
-    POINT_NUMBER        : integer range 2 to 17 := 11
+    POINT_NUMBER        : integer range 2 to 17 := 16
     );
   port (
     CLK    : in std_logic;
@@ -244,6 +244,8 @@ architecture trb_net16_hub_ipu_logic_arch of trb_net16_hub_ipu_logic is
   signal got_all_DHDR          : std_logic;
   signal got_all_reply_starts  : std_logic;
   signal not_reading_HDR       : std_logic;
+  signal number_of_replies     : unsigned(4 downto 0);
+  signal expected_replies      : std_logic_vector(POINT_NUMBER-1 downto 0);
 
 begin
 
@@ -550,7 +552,9 @@ begin
       );
 
   reply_adder_input(POINT_NUMBER*16-1 downto 0) <= last_dhdr_data;
-  reply_adder_input(reply_adder_input'left downto POINT_NUMBER*16) <= (others => '0');
+  gen_spare_bits : if POINT_NUMBER < 17 generate
+    reply_adder_input(reply_adder_input'left downto POINT_NUMBER*16) <= (others => '0');
+  end generate;
 
   process(CLK)
     begin
@@ -609,7 +613,7 @@ begin
           for i in 0 to POINT_NUMBER-1 loop
             if REPLY_DATAREADY_IN(i) = '1' and REPLY_PACKET_NUM_IN(i*3+2 downto i*3) = c_H0 and REPLY_DATA_IN(i*16+2 downto i*16) = TYPE_TRM then
               reading_padding(i) <= '0';
-            elsif start_read_padding(i) = '1' and REPLY_PACKET_NUM_IN(i*3+2 downto i*3) /= c_F3 then
+            elsif start_read_padding(i) = '1' then
               reading_padding(i) <= '1';
             else
               reading_padding(i) <= saved_reading_padding(i);
@@ -717,7 +721,7 @@ begin
       );
 
   reply_arbiter_reset <= RESET or not locked;
-  reply_arbiter_input  <= REPLY_DATAREADY_IN and not current_reply_reading_TRM and current_reply_reading_DHDR and not saved_reading_padding and not start_read_padding;
+  reply_arbiter_input  <= REPLY_DATAREADY_IN and not current_reply_reading_TRM and current_reply_reading_DHDR and not saved_reading_padding;
 --  reply_arbiter_CLK_EN <= not next_point_lock;
   REPLY_MUX_reading <= reply_arbiter_result;
 
@@ -750,7 +754,7 @@ begin
   end generate;
 
   comb_REPLY_muxed_DATAREADY <= or_all(reply_arbiter_result and REPLY_DATAREADY_IN and not current_reply_reading_trm
-                                       and not reply_reading_H0 and not saved_reading_padding and not start_read_padding)
+                                       and not reply_reading_H0 and not saved_reading_padding)
                                   and REPLY_POOL_next_read;
 
 --temporary!
@@ -767,7 +771,7 @@ reply_compare_finished <= reply_compare_start;
                                 real_activepoints, locked, MY_ADDRESS_IN, reply_adder_ready, reply_adder_result,
                                 reply_combined_trm_F3, reply_compare_finished, reply_adder_ready,
                                 reply_adder_overflow, reply_adder_result, current_reply_reading_DHDR,
-                                evt_seqnr, evt_dtype, evt_random_code, evt_number, start_read_padding,
+                                evt_seqnr, evt_dtype, evt_random_code, evt_number, number_of_replies,
                                 current_muxed_reading_DAT,reply_data_counter, current_point_length,
                                 reply_arbiter_result, REPLY_DATAREADY_IN, saved_reply_arbiter_CLK_EN)
     begin
@@ -825,9 +829,9 @@ reply_compare_finished <= reply_compare_start;
         when GEN_LENGTH =>  --now, all HDR are stored, calc sum of HDR lengths
           last_dhdr_addr <= "010";
           comb_REPLY_POOL_DATAREADY <= '0';
+          comb_REPLY_POOL_DATA <= reply_adder_result;
           if reply_adder_ready = '1' then --packet_counter = c_F2
             comb_REPLY_POOL_DATAREADY <= REPLY_POOL_next_read;
-            comb_REPLY_POOL_DATA <= reply_adder_result;
           end if;
           if packet_counter = c_F3 then
             last_dhdr_addr <= "100";
@@ -859,19 +863,18 @@ reply_compare_finished <= reply_compare_start;
             when c_F1 =>
               last_dhdr_addr <= "101";
               reply_compare_start <= '1';
+              comb_REPLY_POOL_DATA <= evt_number;
               if reply_compare_finished = '1' then
                 comb_REPLY_POOL_DATAREADY <= REPLY_POOL_next_read;
-                comb_REPLY_POOL_DATA <= evt_number;
                 last_dhdr_addr <= "110";
               end if;
             when c_F2 =>
               reply_adder_start <= '1';
               last_dhdr_addr <= "110";
+              comb_REPLY_POOL_DATA <= std_logic_vector(unsigned(reply_adder_result) + number_of_replies);
               if reply_adder_ready = '1' then
                 reply_adder_start <= '0';
                 comb_REPLY_POOL_DATAREADY <= REPLY_POOL_next_read;
-                comb_REPLY_POOL_DATA <= std_logic_vector(unsigned(reply_adder_result) +
-                                              to_unsigned(count_ones(real_activepoints and not locking_point),16));
               end if;
             when others => --c_F3
               comb_REPLY_POOL_DATA <= MY_ADDRESS_IN;
@@ -889,7 +892,7 @@ reply_compare_finished <= reply_compare_start;
           reply_arbiter_enable <= '1';
           last_dhdr_addr <= "110"; --length
           if packet_counter = c_H0
-                     and not (comb_REPLY_muxed_PACKET_NUM = c_H0 and comb_REPLY_muxed_DATA(2 downto 0) = TYPE_TRM)
+--                     and not (comb_REPLY_muxed_PACKET_NUM = c_H0 and comb_REPLY_muxed_DATA(2 downto 0) = TYPE_TRM)
                      and     current_muxed_reading_DAT = '1' then
             comb_REPLY_POOL_DATAREADY         <= REPLY_POOL_next_read;
             comb_REPLY_POOL_DATA(2 downto 0)  <= TYPE_DAT;
@@ -901,10 +904,13 @@ reply_compare_finished <= reply_compare_start;
             comb_REPLY_POOL_PACKET_NUM <= packet_counter;
           end if;
 
-          if packet_counter(0) = '0' and reply_data_counter = current_point_length then
-            reply_arbiter_CLK_EN <= '1';
-            reply_data_counter_reset <= '1';
-            start_read_padding <= reply_arbiter_result;
+          if reply_data_counter = current_point_length then
+            if packet_counter(0) = '0' then
+              reply_arbiter_CLK_EN <= '1';
+              reply_data_counter_reset <= '1';
+            else
+              start_read_padding <= reply_arbiter_result;
+            end if;
           elsif or_all(reply_arbiter_result and REPLY_DATAREADY_IN)='1' then
             reply_arbiter_CLK_EN <= '0';
           else
@@ -928,7 +934,6 @@ reply_compare_finished <= reply_compare_start;
 
         when SENDING_REPLY_TRM =>
           comb_REPLY_POOL_DATAREADY <= REPLY_POOL_next_read;
-
           case packet_counter is
             when c_F0 =>
               comb_REPLY_POOL_DATA <= (others => '0');
@@ -985,6 +990,8 @@ reply_compare_finished <= reply_compare_start;
           saved_reply_arbiter_CLK_EN <= reply_arbiter_CLK_EN;
           got_all_reply_starts <= not or_all(current_waiting_for_reply);
           not_reading_HDR <= not or_all(current_reply_reading_HDR);
+          number_of_replies <= to_unsigned(count_ones(expected_replies),5);
+          expected_replies <= real_activepoints and not locking_point;
         end if;
       end if;
     end process;
index 5ce3a6ca022ab35c8e864dcb9b7d1d06f3b3008c..179eddd047732ab616fed4135518ddab51882c57 100644 (file)
@@ -10,7 +10,7 @@ use work.trb_net_std.all;
 entity trb_net16_hub_logic is
   generic (
   --media interfaces
-    POINT_NUMBER        : integer range 2 to 32 := 3
+    POINT_NUMBER        : integer range 2 to 32 := 17
     );
   port (
     CLK    : in std_logic;
@@ -627,8 +627,8 @@ STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
     begin
       next_point_lock <= reply_point_lock;
       REPLY_MUX_reading <= reply_arbiter_result;
-      next_reading_last_hdr <= (others => '0');
-      next_resending_header <= '0';
+--       next_reading_last_hdr <= (others => '0');
+--       next_resending_header <= '0';
       --release lock if TRM is read
       if comb_REPLY_muxed_PACKET_NUM = c_H0 and or_all(REPLY_MUX_reading and REPLY_DATAREADY_IN) = '1' then
         if comb_REPLY_muxed_DATA(2 downto 0) = TYPE_TRM then
@@ -638,20 +638,20 @@ STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
         end if;
       end if;
 
-      --release lock when input timed out after even number of data packets (even: because of 32bit alignment)
-
-
-      --trigger resending of header upon switch of arbiter when necessary
-      if or_all(not last_reply_arbiter_result and reply_arbiter_result and not got_trm and read_from_point_before) = '1'
-         or resending_header = '1' then
-        next_resending_header <= '1';
-        next_reading_last_hdr <= reply_arbiter_result;
-        REPLY_MUX_reading <= (others => '0');
-        if resending_header = '1' and comb_REPLY_muxed_PACKET_NUM = c_F3 and comb_REPLY_muxed_DATAREADY = '1' then
-          next_resending_header <= '0';
-          next_reading_last_hdr <= (others => '0');
-        end if;
-      end if;
+--       --release lock when input timed out after even number of data packets (even: because of 32bit alignment)
+--
+--
+--       --trigger resending of header upon switch of arbiter when necessary
+--       if or_all(not last_reply_arbiter_result and reply_arbiter_result and not got_trm and read_from_point_before) = '1'
+--          or resending_header = '1' then
+--         next_resending_header <= '1';
+--         next_reading_last_hdr <= reply_arbiter_result;
+--         REPLY_MUX_reading <= (others => '0');
+--         if resending_header = '1' and comb_REPLY_muxed_PACKET_NUM = c_F3 and comb_REPLY_muxed_DATAREADY = '1' then
+--           next_resending_header <= '0';
+--           next_reading_last_hdr <= (others => '0');
+--         end if;
+--       end if;
     end process;
 
 --if last_point_lock = 0 and read_from_point_before = 1 and REPLY_MUX_reading \= last_REPLY_MUX_reading then resend_header
@@ -664,14 +664,15 @@ STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
         else
           reply_point_lock <=next_point_lock;
           last_reply_arbiter_result <= reply_arbiter_result;
-          resending_header <= next_resending_header;
-          reading_last_hdr <= next_reading_last_hdr;
+--           resending_header <= next_resending_header;
+--           reading_last_hdr <= next_reading_last_hdr;
         end if;
       end if;
     end process;
 
   reply_arbiter_CLK_EN <= not next_point_lock;
-
+  resending_header <= '0';
+  reading_last_hdr <= (others => '0');
 
 
 --REPLY mux
@@ -710,7 +711,7 @@ STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
   reply_state_machine : process(REPLY_POOL_next_READ, current_state, packet_counter, REPLY_combined_trm_F0,
                                 send_reply_trm, SEQ_NR, REPLY_combined_trm_F1, REPLY_combined_trm_F2,
                                 comb_REPLY_muxed_DATAREADY, comb_REPLY_muxed_DATA, init_locked,
-                                comb_REPLY_muxed_PACKET_NUM, waiting_for_init_finish)
+                                comb_REPLY_muxed_PACKET_NUM, waiting_for_init_finish, REPLY_combined_trm_F3)
     begin
       release_locked <= '0';
       next_state <= current_state;
index 2703620d83571893e4b3a131fb9abcdc057cfd99..07a00b67f99eb8258ede8d00e52e5674dc75726f 100644 (file)
@@ -16,7 +16,7 @@ entity trb_net16_ibuf is
     USE_ACKNOWLEDGE  : integer range 0 to 1 := std_USE_ACKNOWLEDGE;
     USE_CHECKSUM     : integer range 0 to 1 := c_YES;
     SBUF_VERSION     : integer range 0 to 1 := std_SBUF_VERSION;
-    SECURE_MODE      : integer range 0 to 1 := c_YES;
+    SECURE_MODE      : integer range 0 to 1 := c_NO;
     REPLY_CAN_RECEIVE_DATA : integer range 0 to 1 := c_YES
     );
   port(
index 5ae8ef58e47d686fdd8252d442e68cf0ab277be7..bc8e47eaafd79b6bd72d47f11b04ec9f9d5bfe01 100644 (file)
@@ -338,18 +338,15 @@ ARBITER: trb_net_priority_arbiter
       k := 0;
       var_mux_buffer := (others => '0');
       for i in 0 to 2**c_MUX_WIDTH-1 loop
-        for j in 0 to c_DATA_WIDTH+c_NUM_WIDTH-1 loop
-          if j < c_DATA_WIDTH then
-            var_mux_buffer(j) := var_mux_buffer(j) or (INT_DATA_IN(c_DATA_WIDTH*i+j) and current_INT_READ_OUT(i));
-          else
-            var_mux_buffer(j) := var_mux_buffer(j) or (INT_PACKET_NUM_IN(c_NUM_WIDTH*i+j-c_DATA_WIDTH) and current_INT_READ_OUT(i));
-          end if;
-          if current_INT_READ_OUT(i) = '1' and INT_PACKET_NUM_IN(c_NUM_WIDTH*(i+1)-1 downto c_NUM_WIDTH*i) = "100" then
-            k := i;
-          else
-            k := k;
-          end if;
+        for j in 0 to c_DATA_WIDTH-1 loop
+          var_mux_buffer(j) := var_mux_buffer(j) or (INT_DATA_IN(c_DATA_WIDTH*i+j) and current_INT_READ_OUT(i));
+        end loop;
+        for j in c_DATA_WIDTH to c_DATA_WIDTH + c_NUM_WIDTH-1 loop
+          var_mux_buffer(j) := var_mux_buffer(j) or (INT_PACKET_NUM_IN(c_NUM_WIDTH*i+j-c_DATA_WIDTH) and current_INT_READ_OUT(i));
         end loop;
+        if current_INT_READ_OUT(i) = '1' and INT_PACKET_NUM_IN(c_NUM_WIDTH*(i+1)-1 downto c_NUM_WIDTH*i) = "100" then
+          k := i;
+        end if;
       end loop;
       var_mux_buffer(3+c_MUX_WIDTH-1 downto 3) := var_mux_buffer(3+c_MUX_WIDTH-1 downto 3) or conv_std_logic_vector(k, c_MUX_WIDTH);
       current_mux_buffer <= var_mux_buffer;
index 93fa04643935e271df91925a2dd038a44d0f42fb..1d106751a11d10e7970bc0cb503c94beb86ea570 100644 (file)
@@ -195,7 +195,7 @@ begin
   end generate;
 
   GENERATE_WORDS : process(transfer_counter, SEND_BUFFER_SIZE_IN, INT_DATA_IN,
-                           CURRENT_DATA_COUNT, CRC, saved_packet_type)
+                           CURRENT_DATA_COUNT, CRC, saved_packet_type,buffer_number, CTRL_BUFFER)
     begin
       current_NOP_word  <= (others => '0');
       current_ACK_word  <= (others => '0');
index e90ed721fecaea074515590a77d0f221c2c7a3dc..15ad93eca3e04de4dd8f887ae20b0b44c3dbd9c1 100644 (file)
@@ -259,15 +259,15 @@ package body trb_net_std is
       end function log2;
 
   function count_ones( input:std_logic_vector ) return integer is
-    variable temp:integer;
+    variable temp:std_logic_vector(input'range);
     begin
-      temp := 0;
+      temp := (others => '0');
       for i in input'range loop
-        if input(i) = '1' then
-          temp := temp + 1;
-        end if;
+--        if input(i) = '1' then
+          temp := temp + input(i);
+--        end if;
       end loop;
-      return temp;
+      return conv_integer(temp);
       end function count_ones;