]> jspc29.x-matter.uni-frankfurt.de Git - cri.git/commitdiff
add calculation of is_downlink and is_uplink to generalize hub creation
authorAdrian Weber <adrian.a.weber@exp2.physik.uni-giessen.de>
Wed, 13 Oct 2021 12:58:02 +0000 (14:58 +0200)
committerAdrian Weber <adrian.a.weber@exp2.physik.uni-giessen.de>
Wed, 13 Oct 2021 12:58:02 +0000 (14:58 +0200)
src/hub/cri_hub_func.vhd
src/hub/trb_net16_cri_hub.vhd

index 59c34d39ef9429d7e24bff0c8f98e5fb5907301c..14be682fbd017cc3cb93769714174b4ed6616671 100644 (file)
@@ -27,6 +27,14 @@ package cri_hub_func is
     
   function calc_number_config_hub_ports (MII_NUMBER   : integer)
     return integer; 
+
+  function calc_datahub_downlink_number (DOWNLINK_NUM   : integer;
+                                         HUB   : integer)
+    return hub_mii_config_t;    
+    
+  function calc_datahub_uplink_number (DOWNLINK_NUM   : integer;
+                                       HUB   : integer)
+    return hub_mii_config_t;
     
 end package cri_hub_func;
 
@@ -114,6 +122,36 @@ package body cri_hub_func is
       
       return tmp;
     end function;    
-    
+
+
+  function calc_datahub_downlink_number (DOWNLINK_NUM   : integer;
+                                         HUB   : integer)
+    return hub_mii_config_t is       -- 0 1 2 3 4 5 6 7 8 9 a b c d e f
+    variable tmp : hub_mii_config_t := (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+    variable needed_links : integer := 0;
+    begin
+      if (((HUB+1)*12) <= DOWNLINK_NUM ) then
+        tmp := calc_downlink_number(12);
+      else
+        needed_links := (DOWNLINK_NUM mod 12);
+        tmp := calc_downlink_number(needed_links);
+      end if;
+      return tmp;
+    end function;
+
+  function calc_datahub_uplink_number (DOWNLINK_NUM   : integer;
+                                       HUB   : integer)
+    return hub_mii_config_t is       -- 0 1 2 3 4 5 6 7 8 9 a b c d e f
+    variable tmp : hub_mii_config_t := (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+    variable needed_links : integer := 0;
+    begin
+      if (((HUB+1)*12) <= DOWNLINK_NUM ) then
+        tmp := calc_uplink_number(12,0);
+      else
+        needed_links := (DOWNLINK_NUM mod 12);
+        tmp := calc_uplink_number(needed_links,0);
+      end if;
+      return tmp;
+    end function;
 
 end package body;
index 0451a7e7599f23d7e7de26acc2874ba99231fcd5..c7cdc78264588f218fdeb775923a4fc9eead92a5 100644 (file)
@@ -38,9 +38,9 @@ entity trb_net16_cri_hub is
   --media interfaces
     MII_NUMBER              : integer range 0 to 32 := 4;  --TODO increase to 48; will be a problem due to reg sizes
     MII_IBUF_DEPTH          : hub_iobuf_config_t := std_HUB_IBUF_DEPTH;
-    MII_IS_UPLINK           : hub_mii_config_t := (others => c_YES);
-    MII_IS_DOWNLINK         : hub_mii_config_t := (others => c_YES);
-    MII_IS_UPLINK_ONLY      : hub_mii_config_t := (others => c_NO);
+    --MII_IS_UPLINK           : hub_mii_config_t := (others => c_YES);
+    --MII_IS_DOWNLINK         : hub_mii_config_t := (others => c_YES);
+    --MII_IS_UPLINK_ONLY      : hub_mii_config_t := (others => c_NO);
   -- settings for external api connections
     INT_NUMBER              : integer range 0 to c_MAX_API_PER_HUB := 1;
     INT_CHANNELS            : hub_api_config_t := (others => 3);
@@ -328,9 +328,9 @@ THE_HUB_1 : entity work.trb_net16_cri_hub_base
       HUB_USED_CHANNELS   => (0,1,0,1),
       INIT_ADDRESS        => INIT_ADDRESS,
       MII_NUMBER          => links,
-      MII_IS_UPLINK       => MII_IS_UPLINK,
-      MII_IS_DOWNLINK     => MII_IS_DOWNLINK,
-      MII_IS_UPLINK_ONLY  => MII_IS_UPLINK_ONLY,
+      MII_IS_UPLINK       => calc_datahub_uplink_number(downlinks,i),
+      MII_IS_DOWNLINK     => calc_datahub_downlink_number(downlinks,i),
+      MII_IS_UPLINK_ONLY  => calc_datahub_uplink_number(downlinks,i),
       --USE_ONEWIRE         => c_YES,
       HARDWARE_VERSION    => HARDWARE_VERSION,
       INCLUDED_FEATURES   => INCLUDED_FEATURES,