From 0e7e5f568bfd7f215345de33af9ea75b4250b099 Mon Sep 17 00:00:00 2001 From: Adrian Weber Date: Wed, 13 Oct 2021 14:58:02 +0200 Subject: [PATCH] add calculation of is_downlink and is_uplink to generalize hub creation --- src/hub/cri_hub_func.vhd | 40 ++++++++++++++++++++++++++++++++++- src/hub/trb_net16_cri_hub.vhd | 12 +++++------ 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/hub/cri_hub_func.vhd b/src/hub/cri_hub_func.vhd index 59c34d3..14be682 100644 --- a/src/hub/cri_hub_func.vhd +++ b/src/hub/cri_hub_func.vhd @@ -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; diff --git a/src/hub/trb_net16_cri_hub.vhd b/src/hub/trb_net16_cri_hub.vhd index 0451a7e..c7cdc78 100644 --- a/src/hub/trb_net16_cri_hub.vhd +++ b/src/hub/trb_net16_cri_hub.vhd @@ -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, -- 2.43.0