]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
removed some ranges in entities, Jan
authorhadeshyp <hadeshyp>
Mon, 10 Dec 2007 10:35:12 +0000 (10:35 +0000)
committerhadeshyp <hadeshyp>
Mon, 10 Dec 2007 10:35:12 +0000 (10:35 +0000)
trb_net16_endpoint_0_trg_1_api.vhd
trb_net16_endpoint_1_trg_0_api.vhd
trb_net16_endpoint_1_trg_1_api.vhd
trb_net16_endpoint_2_trg_1_api.vhd
trb_net16_endpoint_2_trg_2_api.vhd
trb_net16_hub_base.vhd
trb_net16_hub_func.vhd
trb_net16_hub_logic.vhd
trb_net16_ibuf.vhd
trb_net16_iobuf.vhd
trb_net16_obuf.vhd

index a13b9ab9581e1819e13819ebc62f9a6c75e6e23a..9902240e5f7c23c6e818ae9b1fba93d3086b3a05 100644 (file)
@@ -19,7 +19,7 @@ entity trb_net16_endpoint_0_trg_1_api is
     SBUF_VERSION            : integer range 0 to 1 := 0;
     MUX_WIDTH               : integer range 1 to 5 := 3;
     MUX_SECURE_MODE         : integer range 0 to 1 := 0;
-    DAT_CHANNEL             : integer range 0 to 2**(MUX_WIDTH-1) := 0;
+    DAT_CHANNEL             : integer range 0 to 3 := 0; --range 0 to 2**(MUX_WIDTH-1)
     DATA_WIDTH              : integer := 16;
     NUM_WIDTH               : integer := 2
     );
index a14d00877be61a6bb4a915ba16863f25b321a2cd..f0398cb50508e946806459e7b869ac8d647c3a23 100644 (file)
@@ -11,15 +11,14 @@ use work.trb_net_std.all;
 entity trb_net16_endpoint_1_trg_0_api is
 
   generic (
-    TRG_INIT_DEPTH : integer := 0;     -- Depth of the FIFO, 2^(n+1), if
-                                          -- the initibuf
-    TRG_REPLY_DEPTH : integer := 0;    -- or the replyibuf
-    MUX_WIDTH  : integer := 3;
-    MUX_SECURE_MODE : integer := 0;
-    TRG_CHANNEL : integer := 0;
-    DATA_WIDTH   : integer := 16;   --not to be changed
-    NUM_WIDTH   : integer := 2;    --not to be changed
-    TRG_SECURE_MODE : integer := 0 -- if 0, error pattern and dtype must be valid until next
+    TRG_INIT_DEPTH    : integer := 0;
+    TRG_REPLY_DEPTH   : integer := 0; 
+    MUX_WIDTH         : integer := 3;
+    MUX_SECURE_MODE   : integer := 0;
+    TRG_CHANNEL       : integer := 0;
+    DATA_WIDTH        : integer := 16;   --not to be changed
+    NUM_WIDTH         : integer := 2;    --not to be changed
+    TRG_SECURE_MODE   : integer := 0 -- if 0, error pattern and dtype must be valid until next
                                    -- trigger comes in. if 1 these can be valid on falling edge of hold_trm only
     );
 
index 5d6019cee7106fdc6f762a8b2de22cf09117cf5d..4d425b6fd1428d89fadfc726f8a05186f775d683 100644 (file)
@@ -27,8 +27,8 @@ entity trb_net16_endpoint_1_trg_1_api is
    --Multiplexer
     MUX_WIDTH        : integer range 1 to 5 := 3;
     MUX_SECURE_MODE  : integer range 0 to 1 := 0;
-    TRG_CHANNEL      : integer range 0 to 2**(MUX_WIDTH-1) := 0;
-    DAT_CHANNEL      : integer range 0 to 2**(MUX_WIDTH-1) := 2;
+    TRG_CHANNEL      : integer range 0 to 3 := 0; --range 0 to 2**(MUX_WIDTH-1)
+    DAT_CHANNEL      : integer range 0 to 3 := 2; --range 0 to 2**(MUX_WIDTH-1)
    --General
     DATA_WIDTH       : integer range 16 to 16 := 16;
     NUM_WIDTH        : integer range 2 to 2 := 2
index dcfb4350ddc269b640587feb5032c8f6585bedbc..6dacb844175376c387381f7ba394707958144bb5 100644 (file)
@@ -30,9 +30,9 @@ entity trb_net16_endpoint_2_trg_1_api is
    --Multiplexer
     MUX_WIDTH        : integer range 1 to 5 := 3;
     MUX_SECURE_MODE  : integer range 0 to 1 := 0;
-    TRG1_CHANNEL     : integer range 0 to 2**(MUX_WIDTH-1) := 0;
-    TRG2_CHANNEL     : integer range 0 to 2**(MUX_WIDTH-1) := 1;
-    DAT_CHANNEL      : integer range 0 to 2**(MUX_WIDTH-1) := 3;
+    TRG1_CHANNEL     : integer range 0 to 3 := 0; --range 0 to 2**(MUX_WIDTH-1)
+    TRG2_CHANNEL     : integer range 0 to 3 := 1; --range 0 to 2**(MUX_WIDTH-1)
+    DAT_CHANNEL      : integer range 0 to 3 := 3; --range 0 to 2**(MUX_WIDTH-1)
    --General
     DATA_WIDTH       : integer range 16 to 16 := 16;
     NUM_WIDTH        : integer range 2 to 2 := 2
index 9ae544570836f04e5d828d49395453ba8526a276..196a736196c1cd62fdca9b00d0306b545d7307fb 100644 (file)
@@ -35,10 +35,10 @@ entity trb_net16_endpoint_2_trg_2_api is
    --Multiplexer
     MUX_WIDTH        : integer range 1 to 5 := 3;
     MUX_SECURE_MODE  : integer range 0 to 1 := 0;
-    TRG1_CHANNEL     : integer range 0 to 2**(MUX_WIDTH-1) := 0;
-    TRG2_CHANNEL     : integer range 0 to 2**(MUX_WIDTH-1) := 1;
-    DAT1_CHANNEL      : integer range 0 to 2**(MUX_WIDTH-1) := 2;
-    DAT2_CHANNEL      : integer range 0 to 2**(MUX_WIDTH-1) := 3;
+    TRG1_CHANNEL     : integer range 0 to 3 := 0; --range 0 to 2**(MUX_WIDTH-1)
+    TRG2_CHANNEL     : integer range 0 to 3 := 1; --range 0 to 2**(MUX_WIDTH-1)
+    DAT1_CHANNEL     : integer range 0 to 3 := 2; --range 0 to 2**(MUX_WIDTH-1)
+    DAT2_CHANNEL     : integer range 0 to 3 := 3; --range 0 to 2**(MUX_WIDTH-1)
    --General
     DATA_WIDTH       : integer range 16 to 16 := 16;
     NUM_WIDTH        : integer range 2 to 2 := 2
index 80dfab94403f1cff4c7b0c57b0a018a5fee7649f..488f215e7537c54d6d3c054dcb1d57312be0830d 100644 (file)
@@ -11,50 +11,50 @@ entity trb_net16_hub_base is
   generic (
   --general settings
     MUX_SECURE_MODE         : integer range 0 to 1 := 0;
-    MUX_WIDTH               : integer range 1 to 3 := 3;
+    MUX_WIDTH               : integer range 1 to 3 := 1;
     DATA_WIDTH              : integer range 16 to 16 := 16;
     NUM_WIDTH               : integer range 2 to 2 := 2;
   --hub control
     HUB_ADDRESS             : std_logic_vector(15 downto 0) := x"F001";
-    HUB_CTRL_CHANNELNUM     : integer range 0 to 2**(MUX_WIDTH-1)-1 := 3;
+    HUB_CTRL_CHANNELNUM     : integer range 0 to 3 := 3;
     HUB_CTRL_DEPTH          : integer range 0 to 6 := 1;
     HUB_CTRL_REG_ADDR_WIDTH : integer range 1 to 7 := 4;
   --media interfaces
-    MII_NUMBER              : integer range 2 to 16 := 2;
+    MII_NUMBER              : integer range 2 to 16 := 12;
 --each row is one media interface and each column is one channel. starting with 0,0, ending with 15,15
                                     --CHANNEL  3 2 1 0
-    MII_INIT_DEPTH    : hub_iobuf_config_t := (1,1,0,0,    --MII 0
-                                               1,1,0,0,
-                                               1,1,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0);   --MII 15
-    MII_REPLY_DEPTH    : hub_iobuf_config_t := (1,1,0,0,    --MII 0
-                                               1,1,0,0,
-                                               1,1,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0,
-                                               0,0,0,0);   --MII 15
+    MII_INIT_DEPTH    : hub_iobuf_config_t := (6,6,6,6,    --MII 6
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6);   --MII 65
+    MII_REPLY_DEPTH    : hub_iobuf_config_t := (6,6,6,6,    --MII 6
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6,
+                                               6,6,6,6);   --MII 15
   -- settings for apis
     API_NUMBER              : integer range 0 to 16 := 0;
     API_CHANNELS            : hub_api_config_t := (3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3);
@@ -63,7 +63,7 @@ entity trb_net16_hub_base is
     API_FIFO_TO_INT_DEPTH   : hub_api_config_t := (1,1,1,1,1,1,1,1,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,1,1,1,1,1,1,1,1);
   --trigger reading interfaces
-    TRG_NUMBER              : integer range 0 to 16 := 2;
+    TRG_NUMBER              : integer range 0 to 16 := 0;
     TRG_SECURE_MODE         : integer range 0 to 1 := 0;
     TRG_CHANNELS            : hub_api_config_t := (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
     );
@@ -74,46 +74,44 @@ entity trb_net16_hub_base is
          
     --Media interfacces
     --each port is one bit bigger than actually necessary to avoid error messages
-    MED_DATAREADY_OUT : out std_logic_vector (MII_NUMBER+1 downto 0);
-    MED_DATA_OUT      : out std_logic_vector (MII_NUMBER*DATA_WIDTH+1 downto 0);
-    MED_PACKET_NUM_OUT: out std_logic_vector (MII_NUMBER*NUM_WIDTH+1 downto 0);
-    MED_READ_IN       : in  std_logic_vector (MII_NUMBER+1 downto 0);
-    MED_DATAREADY_IN  : in  std_logic_vector (MII_NUMBER+1 downto 0);
-    MED_DATA_IN       : in  std_logic_vector (MII_NUMBER*DATA_WIDTH+1 downto 0);
-    MED_PACKET_NUM_IN : in  std_logic_vector (MII_NUMBER*NUM_WIDTH+1 downto 0);
-    MED_READ_OUT      : out std_logic_vector (MII_NUMBER+1 downto 0); -- buffer reads a word from media
-    MED_ERROR_IN      : in  std_logic_vector (MII_NUMBER*3+1 downto 0);
+    MED_DATAREADY_OUT : out std_logic_vector (MII_NUMBER-1 downto 0);
+    MED_DATA_OUT      : out std_logic_vector (MII_NUMBER*DATA_WIDTH-1 downto 0);
+    MED_PACKET_NUM_OUT: out std_logic_vector (MII_NUMBER*NUM_WIDTH-1 downto 0);
+    MED_READ_IN       : in  std_logic_vector (MII_NUMBER-1 downto 0);
+    MED_DATAREADY_IN  : in  std_logic_vector (MII_NUMBER-1 downto 0);
+    MED_DATA_IN       : in  std_logic_vector (MII_NUMBER*DATA_WIDTH-1 downto 0);
+    MED_PACKET_NUM_IN : in  std_logic_vector (MII_NUMBER*NUM_WIDTH-1 downto 0);
+    MED_READ_OUT      : out std_logic_vector (MII_NUMBER-1 downto 0); -- buffer reads a word from media
+    MED_ERROR_IN      : in  std_logic_vector (MII_NUMBER*3-1 downto 0);
     --API: interfaces
-    APL_DATA_IN       : in  std_logic_vector (API_NUMBER*DATA_WIDTH downto 0);
-    APL_PACKET_NUM_IN : in  std_logic_vector (API_NUMBER*NUM_WIDTH downto 0);
-    APL_WRITE_IN      : in  std_logic_vector (API_NUMBER downto 0);
-    APL_FIFO_FULL_OUT : out std_logic_vector (API_NUMBER downto 0);
-    APL_SHORT_TRANSFER_IN : in  std_logic_vector (API_NUMBER downto 0);
-    APL_DTYPE_IN      : in  std_logic_vector (API_NUMBER*4 downto 0);
-    APL_ERROR_PATTERN_IN : in  std_logic_vector (API_NUMBER*32 downto 0);
-    APL_SEND_IN       : in  std_logic_vector (API_NUMBER downto 0);
-    APL_TARGET_ADDRESS_IN : in  std_logic_vector (API_NUMBER*16 downto 0);
-    APL_DATA_OUT      : out std_logic_vector (API_NUMBER*16 downto 0);
-    APL_PACKET_NUM_OUT: out std_logic_vector (API_NUMBER*NUM_WIDTH downto 0);
-    APL_TYP_OUT       : out std_logic_vector (API_NUMBER*3 downto 0);
-    APL_DATAREADY_OUT : out std_logic_vector (API_NUMBER downto 0);
-    APL_READ_IN       : in  std_logic_vector (API_NUMBER downto 0);
-    APL_RUN_OUT       : out std_logic_vector (API_NUMBER downto 0);
-    APL_MY_ADDRESS_IN : in  std_logic_vector (API_NUMBER*16 downto 0);
-    APL_SEQNR_OUT     : out std_logic_vector (API_NUMBER*8 downto 0);
+    APL_DATA_IN       : in  std_logic_vector (VAL(API_NUMBER*DATA_WIDTH) downto 0);
+    APL_PACKET_NUM_IN : in  std_logic_vector (VAL(API_NUMBER*NUM_WIDTH) downto 0);
+    APL_WRITE_IN      : in  std_logic_vector (VAL(API_NUMBER) downto 0);
+    APL_FIFO_FULL_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*16) downto 0);
+    APL_PACKET_NUM_OUT: out std_logic_vector (VAL(API_NUMBER*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);
     --TRG interfaces
-    TRG_GOT_TRIGGER_OUT   : out std_logic_vector (TRG_NUMBER downto 0);
-    TRG_ERROR_PATTERN_OUT : out std_logic_vector (TRG_NUMBER*32 downto 0);
-    TRG_DTYPE_OUT         : out std_logic_vector (TRG_NUMBER*4 downto 0);
-    TRG_SEQNR_OUT         : out std_logic_vector (TRG_NUMBER*8 downto 0);
-    TRG_ERROR_PATTERN_IN  : in  std_logic_vector (TRG_NUMBER*32 downto 0);
-    TRG_RELEASE_IN        : in  std_logic_vector (TRG_NUMBER downto 0);
+    TRG_GOT_TRIGGER_OUT   : out std_logic_vector (VAL(TRG_NUMBER) downto 0);
+    TRG_ERROR_PATTERN_OUT : out std_logic_vector (VAL(TRG_NUMBER*32) downto 0);
+    TRG_DTYPE_OUT         : out std_logic_vector (VAL(TRG_NUMBER*4) downto 0);
+    TRG_SEQNR_OUT         : out std_logic_vector (VAL(TRG_NUMBER*8) downto 0);
+    TRG_ERROR_PATTERN_IN  : in  std_logic_vector (VAL(TRG_NUMBER*32) downto 0);
+    TRG_RELEASE_IN        : in  std_logic_vector (VAL(TRG_NUMBER) downto 0);
     --Status ports (for debugging)
     HUB_STAT_CHANNEL             : out std_logic_vector (2**(MUX_WIDTH-1)*16-1 downto 0);
     HUB_STAT_GEN                 : out std_logic_vector (31 downto 0);
---    HUB_CTRL_CHANNEL             : in  std_logic_vector (2**(MUX_WIDTH-1)*16-1 downto 0);
---    HUB_CTRL_activepoints        : in  std_logic_vector (2**(MUX_WIDTH-1)*32-1 downto 0);
---    HUB_CTRL_GEN                 : in  std_logic_vector (31 downto 0);
+
     MPLEX_CTRL                   : in  std_logic_vector (MII_NUMBER*32-1 downto 0);
     MPLEX_STAT                   : out std_logic_vector (MII_NUMBER*32-1 downto 0)
     );
@@ -485,10 +483,7 @@ end component;
 begin
 
 --set unused signals
-    MED_DATAREADY_OUT(MII_NUMBER+1 downto MII_NUMBER) <= "00";
-    MED_DATA_OUT(MII_NUMBER*DATA_WIDTH+1 downto MII_NUMBER*DATA_WIDTH) <= "00";
-    MED_PACKET_NUM_OUT(MII_NUMBER*NUM_WIDTH+1 downto MII_NUMBER*NUM_WIDTH) <= "00";
-    MED_READ_OUT(MII_NUMBER+1 downto MII_NUMBER) <= "00";
+  
 
 
 
@@ -897,9 +892,9 @@ begin
                                 <= 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_num-1 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**(MUX_WIDTH-1)*MII_NUMBER + is_ctrl_channel + api;
+        constant buf_to_hub_num : integer := 2**(MUX_WIDTH-1)*MII_NUMBER + 1 + api;
                     --calc_special_number(CHANNEL, api, API_CHANNELS)
       begin
         h1: if API_CHANNELS(api) = CHANNEL generate
@@ -942,9 +937,9 @@ begin
       end generate;
     end generate;
     g3: if trg_num /= 0 generate
-      gen_hublogicsignals3 : for trg in 0 to trg_num-1 generate
-        constant hublogic_num   : integer := first_point_num + MII_NUMBER + is_ctrl_channel + calc_special_number(CHANNEL, api_num, TRG_CHANNELS) + calc_special_number(CHANNEL, trg, TRG_CHANNELS);
-        constant buf_to_hub_num : integer := 2**(MUX_WIDTH-1)*MII_NUMBER + is_ctrl_channel + api_num + trg;
+      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**(MUX_WIDTH-1)*MII_NUMBER + 1 + API_NUMBER + trg;
       begin
         h1: if TRG_CHANNELS(trg) = CHANNEL generate
           HUB_INIT_DATAREADY_IN (hublogic_num)
@@ -1106,7 +1101,7 @@ HUB_MED_CONNECTED(31 downto MII_NUMBER) <= (others => '1');
 
   HC_STAT_REGS(31 downto 0) <= buf_HUB_STAT_GEN;
   HC_STAT_REGS(32+2**(MUX_WIDTH-1)*16-1 downto 32) <= buf_HUB_STAT_CHANNEL;
-  
+
   HUB_CTRL_GEN     <= HC_CTRL_REGS(31 downto 0);
   HUB_CTRL_CHANNEL <= HC_CTRL_REGS(32+2**(MUX_WIDTH-1)*16-1 downto 32);
   HUB_CTRL_activepoints <= HC_CTRL_REGS(128+2**(MUX_WIDTH-1)*32-1 downto 128);
index c141117688df84a6df278c8d91bed3bbf892e64a..aba2b295dac8dccfb083fd02b47cdb2c98d3c1a7 100644 (file)
@@ -48,11 +48,23 @@ package trb_net16_hub_func is
   function reportint(i : integer)
     return integer;
 
+  function VAL(i : integer)
+    return integer;
 
 end package trb_net16_hub_func;
 
 package body trb_net16_hub_func is
 
+  function VAL(i : integer)
+    return integer is
+    begin
+      if i > 0 then
+        return i-1;
+      else
+        return 0;
+      end if;
+    end function;
+
   function calc_is_ctrl_channel(CHANNEL : integer; HUB_CTRL_CHANNEL : integer)
     return integer is
     begin
index 87d9dbf4a43e58cd5f56636594718abd3bdf7109..c086fa8060221477c8e879eac736c1ebc66496a0 100644 (file)
@@ -9,7 +9,7 @@ use work.trb_net_std.all;
 entity trb_net16_hub_logic is
   generic (
   --media interfaces
-    POINT_NUMBER        : integer range 2 to 32 := 5;
+    POINT_NUMBER        : integer range 2 to 32 := 12;
 
   --general settings
     DATA_WIDTH          : integer range 16 to 16 := 16;
@@ -115,7 +115,7 @@ architecture trb_net16_hub_logic_arch of trb_net16_hub_logic is
   signal get_locked, release_locked          : std_logic;
   signal got_trm                             : std_logic_vector(POINT_NUMBER-1  downto 0);
   signal locking_point, next_locking_point   : std_logic_vector(POINT_NUMBER-1  downto 0);
-  signal reading_from_point                  : std_logic_vector(POINT_NUMBER-1  downto 0);
+  signal reading_from_point,next_reading_from_point : std_logic_vector(POINT_NUMBER-1  downto 0);
   signal send_reply_trm                      : std_logic;
 
   signal init_locked, next_init_locked       : std_logic;
@@ -135,8 +135,7 @@ architecture trb_net16_hub_logic_arch of trb_net16_hub_logic is
   signal comb_REPLY_POOL_next_read           : std_logic;
 
 
-  signal reply_point_lock                    : std_logic;
-  signal release_point_lock, get_point_lock  : std_logic;
+  signal reply_point_lock, next_point_lock   : std_logic;
   signal tmp_REPLY_READ_OUT                  : std_logic_vector(POINT_NUMBER-1 downto 0);
 
   signal comb_REPLY_muxed_DATAREADY           : std_logic;
@@ -159,7 +158,7 @@ REPLY_HEADER_OUT <= (others => '0');
 
 STAT(7  downto 0) <= (others => '0');
 STAT(15 downto 8) <= data_counter;
-STAT_POINTS_locked(POINT_NUMBER-1 downto 0) <= not got_trm when locked = '1' else (others => '0');
+STAT_POINTS_locked(POINT_NUMBER-1 downto 0) <= not got_trm;
 STAT_POINTS_locked(31 downto POINT_NUMBER)  <= (others => '0');
 STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
 
@@ -209,10 +208,12 @@ STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
 
 --Datapool for Init-Channel
   INIT_muxed_DATAREADY <= or_all(INIT_DATAREADY_IN) and not init_locked and INIT_muxed_READ;
-  INIT_POOL_READ <= and_all(INIT_READ_IN or init_has_read_from_pool or locking_point);
+  INIT_POOL_READ <= and_all(INIT_READ_IN or init_has_read_from_pool or locking_point or not CTRL_activepoints(POINT_NUMBER-1 downto 0));
   INIT_READ_OUT <= buf_INIT_READ_OUT;
 
-  buf_INIT_READ_OUT <= init_arbiter_read_out when init_locked = '0' else (others => '0');
+  gen_iro : for i in 0 to POINT_NUMBER-1 generate
+    buf_INIT_READ_OUT(i) <= init_arbiter_read_out(i) and not init_locked;
+  end generate;
 
   gen_init_pool_data0: for i in 0 to DATA_WIDTH-1 generate
     process(INIT_DATA_IN, buf_INIT_READ_OUT)
@@ -246,10 +247,8 @@ STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
         if rising_edge(CLK) then
           if RESET = '1' or INIT_POOL_READ = '1' then
             init_has_read_from_pool(i) <= '0';
-          else
-            if INIT_POOL_DATAREADY = '1' and INIT_READ_IN(i) = '1' then
-              init_has_read_from_pool(i) <= '1';
-            end if;
+          elsif INIT_POOL_DATAREADY = '1' and INIT_READ_IN(i) = '1' then
+            init_has_read_from_pool(i) <= '1';
           end if;
         end if;
       end process;
@@ -268,8 +267,8 @@ STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
 --locked signals
 --locked: transfer is running
 --init_locked: waiting for reply channel to finish
-  send_reply_trm <= '1' when and_all(got_trm) = '1'
-                         else '0';
+  --send_reply_trm <= '1' when and_all(got_trm) = '1' else '0';
+  send_reply_trm <= and_all(got_trm);
   get_locked     <= INIT_muxed_DATAREADY;
   next_locked    <= (get_locked or locked) and not release_locked;
   next_locking_point <= (buf_INIT_READ_OUT and INIT_DATAREADY_IN) when (locked = '0' and REPLY_POOL_DATAREADY = '0') else locking_point;
@@ -305,7 +304,8 @@ STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
                     REPLY_reading_trm;
   REPLY_READ_OUT <= buf_REPLY_READ_OUT;
 
-  REPLY_MUX_real_reading <= or_all(REPLY_MUX_reading) and REPLY_POOL_next_read;
+  REPLY_MUX_real_reading <=  REPLY_POOL_next_read; --or_all(REPLY_MUX_reading) and
+                           --REPLY_MUX_reading always contains a 1 (?)
 
 --saving necessary data
 ----------------------------------
@@ -377,14 +377,19 @@ STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
 
 
   gen_reading_trmFn : for i in 0 to POINT_NUMBER-1 generate
-    reading_trmF1(i) <= '1' when REPLY_PACKET_NUM_IN((i+1)*NUM_WIDTH-1 downto i*NUM_WIDTH) = "01"
-                                  and REPLY_reading_trm(i) = '1'
-                                  and REPLY_DATAREADY_IN(i) = '1'
-                            else '0';
-    reading_trmF2(i) <= '1' when REPLY_PACKET_NUM_IN((i+1)*NUM_WIDTH-1 downto i*NUM_WIDTH) = "10"
-                                  and REPLY_reading_trm(i) = '1'
-                                  and REPLY_DATAREADY_IN(i) = '1'
-                            else '0';
+--     reading_trmF1(i) <= '1' when REPLY_PACKET_NUM_IN((i+1)*NUM_WIDTH-1 downto i*NUM_WIDTH) = "01"
+--                                   and REPLY_reading_trm(i) = '1'
+--                                   and REPLY_DATAREADY_IN(i) = '1'
+--                             else '0';
+--     reading_trmF2(i) <= '1' when REPLY_PACKET_NUM_IN((i+1)*NUM_WIDTH-1 downto i*NUM_WIDTH) = "10"
+--                                   and REPLY_reading_trm(i) = '1'
+--                                   and REPLY_DATAREADY_IN(i) = '1'
+--                             else '0';
+    reading_trmF1(i) <= not REPLY_PACKET_NUM_IN((i+1)*NUM_WIDTH-1) and REPLY_PACKET_NUM_IN(i*NUM_WIDTH)
+                     and REPLY_reading_trm(i) and REPLY_DATAREADY_IN(i);
+
+    reading_trmF2(i) <= REPLY_PACKET_NUM_IN((i+1)*NUM_WIDTH-1) and not REPLY_PACKET_NUM_IN(i*NUM_WIDTH)
+                     and REPLY_reading_trm(i) and REPLY_DATAREADY_IN(i);
   end generate;
 
   gen_combining_trm : for j in 0 to DATA_WIDTH-1 generate
@@ -471,17 +476,18 @@ STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
 
   -- we have to care to read multiples of four packets from every point
   -- release is currently done after first packet of TRM
-  gen_reply_point_lock : process(comb_REPLY_POOL_PACKET_NUM, comb_REPLY_POOL_DATAREADY, REPLY_DATAREADY_IN,
-                                 saved_REPLY_TYPE, comb_REPLY_muxed_PACKET_NUM, comb_REPLY_muxed_DATAREADY, 
-                                 comb_REPLY_muxed_DATA, buf_REPLY_READ_OUT, REPLY_MUX_reading)
+  gen_reply_point_lock : process(reply_point_lock, reading_from_point, comb_REPLY_muxed_PACKET_NUM, REPLY_MUX_reading,
+                                 REPLY_DATAREADY_IN, comb_REPLY_muxed_DATA, REPLY_MUX_reading)
     begin
-      release_point_lock <= '0';
-      get_point_lock <= '0';
+      next_point_lock <= reply_point_lock;
+      next_reading_from_point <= reading_from_point;
       if comb_REPLY_muxed_PACKET_NUM = "00" and or_all(REPLY_MUX_reading and REPLY_DATAREADY_IN) = '1' then
         if comb_REPLY_muxed_DATA(2 downto 0) = TYPE_TRM then
-          release_point_lock <= '1';
+          next_point_lock <= '0';
+          next_reading_from_point <= (others => '0');
         else
-          get_point_lock <= '1';
+          next_point_lock <= '1';
+          reading_from_point <= REPLY_MUX_reading;
         end if;
       end if;
     end process;
@@ -489,17 +495,17 @@ STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
   gen_point_lock : process(CLK)
     begin
       if rising_edge(CLK) then
-        if RESET = '1' or release_point_lock = '1' then
+        if RESET = '1' then
           reply_point_lock <= '0';
           reading_from_point <= (others => '0');
-        elsif get_point_lock = '1' then
-          reply_point_lock <= '1';
-          reading_from_point <= REPLY_MUX_reading;
+        else
+          reply_point_lock <=next_point_lock;
+          reading_from_point <= next_reading_from_point;
         end if;
       end if;
     end process;
 
-  reply_arbiter_CLK_EN <= not reply_point_lock;        
+  reply_arbiter_CLK_EN <= not reply_point_lock;        --1 cycle too late?
 
 
 
index 6a55e2575d9e53a85d3a8f003c90b2a42b730ad6..49b482aa662213de030b775f1c08d4686d130046 100644 (file)
@@ -11,7 +11,8 @@ use work.trb_net_std.all;
 entity trb_net16_ibuf is
   generic (
     DEPTH : integer range 0 to 7 := 1;
-    SBUF_VERSION : integer range 0 to 1 := 0
+    IBUF_SECURE_MODE : integer range 0 to 1 := 1
+                 --use sbuf in med_to_api direction?
     );
   port(
     --  Misc
@@ -120,6 +121,7 @@ architecture trb_net16_ibuf_arch of trb_net16_ibuf is
   type ERROR_STATE is (IDLE, GOT_OVERFLOW_ERROR, GOT_LOCKED_ERROR, GOT_UNDEFINED_ERROR);
   signal current_error_state, next_error_state : ERROR_STATE;
   signal next_rec_buffer_size_out, current_rec_buffer_size_out: std_logic_vector(3 downto 0);
+  signal buf_INT_DATAREADY_OUT : std_logic;
 
 begin
   FIFO: trb_net16_fifo
@@ -191,16 +193,17 @@ begin
           if MED_PACKET_NUM_IN = "10" then
             next_rec_buffer_size_out <= MED_DATA_IN(3 downto 0);
           end if;
-        elsif fifo_full = '0' then
-          fifo_write <=  '1';
-          next_read_out <=  '1';
-        elsif fifo_full = '1' then
-          next_error_state <= GOT_OVERFLOW_ERROR;
-        elsif is_locked = '1' then
-          next_error_state <= GOT_LOCKED_ERROR;
-        end if;                         -- end TYPE
-      end if;                           -- end MED_DATAREADY_IN
-      if fifo_full = '0' then -- and is_locked = '0' then
+        else
+          if fifo_full = '0' then
+            fifo_write <=  '1';
+          else
+            next_error_state <= GOT_OVERFLOW_ERROR;
+          end if;
+--         elsif is_locked = '1' then
+--           next_error_state <= GOT_LOCKED_ERROR;
+        end if;
+      end if;
+      if fifo_full = '0' then
         next_read_out <=  '1';
       end if;
     end process;
@@ -224,53 +227,81 @@ begin
     end if;
   end process;
 
+  gensecure : if IBUF_SECURE_MODE = 1 generate
+    SBUF: trb_net16_sbuf
+      generic map (DATA_WIDTH => 16, NUM_WIDTH => 2, Version => 0)
+      port map (
+        CLK   => CLK,
+        RESET  => RESET,
+        CLK_EN => CLK_EN,
+        COMB_DATAREADY_IN => tmp_INT_DATAREADY_OUT,
+        COMB_next_READ_OUT => comb_next_read,
+        COMB_READ_IN => '1',
+        COMB_DATA_IN => tmp_INT_DATA_OUT,
+        COMB_PACKET_NUM_IN => tmp_INT_PACKET_NUM_OUT,
+        SYN_DATAREADY_OUT => INT_DATAREADY_OUT,
+        SYN_DATA_OUT => INT_DATA_OUT,
+        SYN_PACKET_NUM_OUT => INT_PACKET_NUM_OUT,
+        SYN_READ_IN => INT_READ_IN
+        );
 
-  SBUF: trb_net16_sbuf
-    generic map (DATA_WIDTH => 16, NUM_WIDTH => 2, Version => SBUF_VERSION)
-    port map (
-      CLK   => CLK,
-      RESET  => RESET,
-      CLK_EN => CLK_EN,
-      COMB_DATAREADY_IN => tmp_INT_DATAREADY_OUT,
-      COMB_next_READ_OUT => comb_next_read,
-      COMB_READ_IN => '1',
-      COMB_DATA_IN => tmp_INT_DATA_OUT,
-      COMB_PACKET_NUM_IN => tmp_INT_PACKET_NUM_OUT,
-      SYN_DATAREADY_OUT => INT_DATAREADY_OUT,
-      SYN_DATA_OUT => INT_DATA_OUT,
-      SYN_PACKET_NUM_OUT => INT_PACKET_NUM_OUT,
-      SYN_READ_IN => INT_READ_IN
-      );
-  
-  sbuf_free <= comb_next_read or INT_READ_IN;  --sbuf killed
+    sbuf_free <= comb_next_read or INT_READ_IN;  --sbuf killed
 
--- this process controls what will be forwarded to the internal point
-  DATA_OUT : process (INT_HEADER_IN, fifo_data_out,
-                      release_locked, is_locked, sbuf_free, fifo_empty,
-                      fifo_packet_num_out, current_fifo_packet_type)
-  begin
-    tmp_INT_DATA_OUT <= fifo_data_out;
-    tmp_INT_PACKET_NUM_OUT <= fifo_packet_num_out;
-    tmp_INT_DATAREADY_OUT <= '0';
-    got_eob_out <= '0';
-    got_locked  <= is_locked;
-    fifo_read <= sbuf_free and not fifo_empty;
-    if current_fifo_packet_type = TYPE_EOB and fifo_packet_num_out = "00" then
-      tmp_INT_DATA_OUT(2 downto 0) <= TYPE_DAT;
-    end if;
-    if fifo_empty = '0' and sbuf_free = '1' then
-      tmp_INT_DATAREADY_OUT <= '1';
-      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';
+  -- this process controls what will be forwarded to the internal point
+    DATA_OUT : process (INT_HEADER_IN, fifo_data_out,
+                        release_locked, is_locked, sbuf_free, fifo_empty,
+                        fifo_packet_num_out, current_fifo_packet_type)
+    begin
+      tmp_INT_DATA_OUT <= fifo_data_out;
+      tmp_INT_PACKET_NUM_OUT <= fifo_packet_num_out;
+      tmp_INT_DATAREADY_OUT <= '0';
+      got_eob_out <= '0';
+      got_locked  <= is_locked;
+      fifo_read <= sbuf_free and not fifo_empty;
+      if current_fifo_packet_type = TYPE_EOB and fifo_packet_num_out = "00" then
+        tmp_INT_DATA_OUT(2 downto 0) <= TYPE_DAT;
       end if;
-      if current_fifo_packet_type = TYPE_TRM then
-        got_locked <= is_locked or not release_locked;
+      if fifo_empty = '0' and sbuf_free = '1' then
+        tmp_INT_DATAREADY_OUT <= '1';
+        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;
+        end if;
       end if;
-    end if;
+    end process;
+  end generate;
 
+  gen_notsecure : if IBUF_SECURE_MODE = 0 generate
+   DATA_OUT : process (INT_HEADER_IN, fifo_data_out,
+                        release_locked, is_locked, sbuf_free, fifo_empty,
+                        fifo_packet_num_out, current_fifo_packet_type)
+    begin
+      INT_DATA_OUT <= fifo_data_out;
+      INT_PACKET_NUM_OUT <= fifo_packet_num_out;
+      buf_INT_DATAREADY_OUT <= '0';
+      got_eob_out <= '0';
+      got_locked  <= is_locked;
+      fifo_read <= INT_READ_IN and buf_INT_DATAREADY_OUT and not fifo_empty;
+      if current_fifo_packet_type = TYPE_EOB and fifo_packet_num_out = "00" then
+        INT_DATA_OUT(2 downto 0) <= TYPE_DAT;
+      end if;
+      if fifo_empty = '0' then
+        INT_DATAREADY_OUT <= '1';
+        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;
+        end if;
+      end if;
+    end process;
+  end generate;
 
-  end process;
+  INT_DATAREADY_OUT <= buf_INT_DATAREADY_OUT;
 
 --BUGBUG HDR retransmit needed
 
index 4a3c1a2f066099ea868292e1d619058271ff40d5..9f1eb338c86941d9b0553fb55d3cd706f5a8fb8e 100644 (file)
@@ -12,9 +12,11 @@ use work.trb_net_std.all;
 --Entity decalaration for clock generator
 entity trb_net16_iobuf is
   generic (
-    --FIFO size is given in 2^(n+1) 64Bit-packets i.e. 2^(n+3) 16bit packets
     INIT_DEPTH : integer := 1;
-    REPLY_DEPTH : integer := 1);
+    REPLY_DEPTH : integer := 1;
+    IBUF_SECURE_MODE : integer range 0 to 1 := 0
+               --use sbuf in med_to_api direction?
+    );
   port(
     --  Misc
     CLK    : in std_logic;
@@ -115,7 +117,8 @@ architecture trb_net16_iobuf_arch of trb_net16_iobuf is
   component trb_net16_ibuf is
     generic (
       DEPTH : integer range 0 to 7 := 1;
-      SBUF_VERSION : integer range 0 to 1 := 0
+      IBUF_SECURE_MODE : integer range 0 to 1 := 1
+               --use sbuf in med_to_api direction?
       );
     port(
       --  Misc
@@ -199,7 +202,8 @@ begin
   GEN_INIT_IBUF: if INIT_DEPTH>0 generate
     INITIBUF : trb_net16_ibuf
       generic map (
-        DEPTH => INIT_DEPTH)
+        DEPTH => INIT_DEPTH,
+        IBUF_SECURE_MODE => IBUF_SECURE_MODE)
       port map (
         CLK       => CLK,
         RESET     => RESET,
@@ -224,7 +228,8 @@ begin
   GEN_REPLY_IBUF : if REPLY_DEPTH > 0 generate
     REPLYIBUF : trb_net16_ibuf
       generic map (
-        DEPTH => REPLY_DEPTH)
+        DEPTH => REPLY_DEPTH,
+        IBUF_SECURE_MODE => IBUF_SECURE_MODE)
       port map (
         CLK       => CLK,
         RESET     => RESET,
@@ -293,10 +298,6 @@ begin
   end generate;
 
   INITOBUF : trb_net16_obuf
-
---    generic map (
---      DATA_COUNT_WIDTH => 16
---      )
     port map (
       CLK       => CLK,
       RESET     => RESET,
@@ -316,9 +317,6 @@ begin
       );
 
   REPLYOBUF : trb_net16_obuf
---    generic map (
---      DATA_COUNT_WIDTH => 16
---      )
     port map (
       CLK       => CLK,
       RESET     => RESET,
index ade5d12798045192f47da709762333d7f1901590..546c6255300c28c0f099096121da6e18fa8a9ebc 100644 (file)
@@ -77,7 +77,6 @@ architecture trb_net16_obuf_arch of trb_net16_obuf is
   signal CURRENT_DATA_COUNT, next_DATA_COUNT : STD_LOGIC_VECTOR (DATA_COUNT_WIDTH-1  downto 0);
 --  signal max_DATA_COUNT, next_max_DATA_COUNT : STD_LOGIC_VECTOR (15 downto 0);
   signal max_DATA_COUNT_minus_one, next_max_DATA_COUNT_minus_one : STD_LOGIC_VECTOR (DATA_COUNT_WIDTH-1 downto 0);
-  signal max_DATA_COUNT_minus_two, next_max_DATA_COUNT_minus_two : STD_LOGIC_VECTOR (DATA_COUNT_WIDTH-1 downto 0);
   signal TRANSMITTED_BUFFERS, next_TRANSMITTED_BUFFERS : STD_LOGIC_VECTOR (1 downto 0);
   signal increase_TRANSMITTED_BUFFERS, decrease_TRANSMITTED_BUFFERS : STD_LOGIC;
 
@@ -126,7 +125,6 @@ begin
   send_EOB     <= '1' when (CURRENT_DATA_COUNT = max_DATA_COUNT_minus_one) else '0';
 
 
-
   -- buffer registers
   STAT_BUFFER(1 downto 0)   <= TRANSMITTED_BUFFERS;
   STAT_BUFFER(14 downto 2)  <= (others => '0');