/******************************************************************************/
// @copyright   Copyright Notification
//   No part may be reproduced except as authorized by written permission.
//   The copyright and the foregoing restriction extend to reproduction in all media.
//   Trademark 2010, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC).
//   All rights reserved.
// @version: IWD_10wk37
// $Date: 2010-09-14 12:57:53 +0200 (Tue, 14 Sep 2010) $
// $Rev: 3868 $
/******************************************************************************/
module EUTRA_CellInfo {
  import from EUTRA_RRC_ASN1_Definitions language "ASN.1:1997" all;
  import from CommonDefs all;
  import from EUTRA_CommonDefs all;
  import from EUTRA_ASP_TypeDefs all;
  import from NAS_CommonTypeDefs all;
  import from CommonIratDefs all;
  
  import from Parameters all;
   import from EUTRA_Parameters all;
  
  import from EUTRA_RRC_Templates all;
  import from EUTRA_SysInfo_Templates all;
  
  import from EUTRA_AuxiliaryFunctions all;
  import from EUTRA_CellInfoFrequency all;
  
  /*******************************************************************************/
  //------------------------------TYPES-------------------------------------------
  /*******************************************************************************/
  
  // ------------------------------------------------------
  //    EUTRA cell info type
  type enumerated Combination_Type {c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11};   /* @status    APPROVED */
  
  type record RNTI_Type {                       /* @status    APPROVED */
    C_RNTI       C_RNTI
  };
  
  type  record EUTRA_CellSysInfo_Type {         /* @status    APPROVED */
    // type defined to contain all sysinfo related to  a cell
    BcchInfo_Type       BCCH_Info,              // BCCH PDUs
    Combination_Type    Combination,            // Combinations of system information blocks  (combinition acc. 36.508 cl. 4.4.3.1.1)
    boolean             SB1_ValueTagChanged     // set to TRUE after SB1ValueTag changed, set to FALSE after SB1 delivered to SS.
  };
  
  type record NAS_Parameter_Type {              /* @status    APPROVED */
    GutiParameters_Type      Guti_Parameters,             // Guti parameters: MME groupId, MME code, M_TMSI
    TrackingAreaCode         TrackingAreaCode,            // TAC applied in the cell
    NAS_Lac                  LocationAreaCode             // Location Area Id, to be used in combined procedures and CS fallback
  };
  
  type record EUTRA_FDD_TDD_CellInfo_Type {     /* @status    APPROVED */
    EUTRA_FDD_TDD_Mode_Type         FDD_TDD,                 // FDD or TDD mode
    CQI_ReportPeriodic              cqi_ReportConfig,
    SoundingRS_UL_ConfigDedicated   soundingRS_UL_Config,
    PUCCH_ConfigDedicated           pucch_Config,
    TDD_SubframeAssignment_Type     TDD_SubframeAssignment  optional,  // @sic R5-096691 sic@
    SR_ConfigIndex_Type             sr_ConfigIndex  // @sic R5-102177 sic@
  };
  
  type record Frequency_IE_Type {               /* @status    APPROVED */
    FrequencyBand_Type FrequencyBandIndicator,       // Frequency band indicator
    Dl_Bandwidth_Type  DL_ChBandwidth,               // DL channel bandwidth
    Ul_Bandwidth_Type  UL_ChBandwidth  optional,     // UL channel bandwidth
    CarrierFreqEUTRA   UL_DL_Earfcn                  // UL and DL EARFCN
  };
  
  type record CellIdentities_Type {             /* @status    APPROVED */
    CellIdentity             CellIdentity,           // Cell ID
    PhysCellId               PhysicalCellId          // Physical cell ID
  };
  
  type record ReferenceCellPower_Type {         /* @status    APPROVED */
    AbsoluteCellPower_Type         MaxReferencePower,
    Attenuation_Type               Attenuation
  };
  
  type record PhysicalParameters_Type {        /* @status    APPROVED
                                                  @sic R5s090180 sic@ */
    CfiValue_Type                    Cfi,
    RACH_TimingAdvance_Type          RAR_TA,   // Random access response Timing Advance @sic R5-096691 sic@
    SR_PUCCH_ResourceIndex_Type      sr_PUCCH_ResourceIndex, // @sic R5s090312  sic@
    P_b_Type                         PDSCH_p_b  // @sic R5-100786 sic@
  };
  
  type record AntennaInfo_Type {               /* @status    APPROVED */
    AntennaInfoCommon                               SS_AntennaInfoCommon,
    AntennaInfoCommon                               AntennaInfoCommon   optional,
    AntennaInfoDedicated                            SS_AntennaInfoDedicated,
    PhysicalConfigDedicated_AntennaInfo_Type        AntennaInfoDedicated
  };
  
  type record EUTRA_CellInfo_Type {             /* @status    APPROVED */
    // this structure contain the information describing an EUTRA cell configuration
    CellIdentities_Type            CellIds,                     // cell ID + physical cell ID
    Frequency_IE_Type              Frequency,                   // Band, Bandwidth, UL EARFCN, DL EARFCN
    EUTRA_FDD_TDD_CellInfo_Type    FDD_TDD_Info,                // Include all FDD/TDD related cell information
    EUTRA_CellSysInfo_Type         Sysinfo,                     // Sysinfo
    NAS_Parameter_Type             NAS_Parameters,              // PLMN_List, TAC, Guti @sic R5s100240 delete PcchConfiguration field sic@
    CellTimingInfo_Type            CellTimingInfo,              // Tcell and SFN offset
    ReferenceCellPower_Type        ReferencePower,              // Cell power configuration
    CellConfigCapability_Type      CellConfigCapability,        // broadcastOnlyCell, minimumUplinkCell, fullCell
    RNTI_Type                      RNTI,                        // RNTI associated to the cell
    PhysicalParameters_Type        PhysicalParameters,          // Additional physical parameters
    AntennaInfo_Type               AntennaInfo                  // Parameters for antenna info @sic R5-100786 sic@
  };
  
  type record length(tsc_EUTRA_MaxNumberOfCells) of EUTRA_CellInfo_Type EUTRA_CellInfoList_Type;    /* array of Cells;     @status    APPROVED */
  
  // ------------------------------------------------------
  //    Channel bandwidth dependant parameters Type
  
  type record ChannelBandwidthDependency_Type { /* @status    APPROVED */
    /* type defined to hold the bandwidth dependant parameters
       for the implementation of:
       - table 4.4.3.4-1 in 36.508
       - table 4.3.4.1-1 and 4.3.4.1-2 in 36.508 cl 4.3.4  and
       - table 4.6.8-1 in 36.508 cl 4.6.8 */
    SiPeriodicity_Type              SIB3_periodicity,
    SiPeriodicity_Type              SIB4_periodicity,
    SiPeriodicity_Type              SIB5_periodicity,
    SiPeriodicity_Type              SIB6_periodicity,
    SiPeriodicity_Type              SIB7_periodicity,
    SiPeriodicity_Type              SIB8_periodicity,
    SiPeriodicity_Type              SIB10_periodicity,  // @sic R5-100112 sic@
    SiPeriodicity_Type              SIB11_periodicity,  // @sic R5-100112 sic@
    AllowedMeasBandwidth            AllowedMeasBandwidth,
    Prach_FrequencyOffset_Type      Prach_FrequencyOffset,
    N_RB_CQI_Type                   N_RB_CQI,
    PUSCH_HoppingOffset_Type        Pusch_HoppingOffset,
    SR_PUCCH_ResourceIndex_Type     sr_PUCCH_ResourceIndex,         // @sic R5s090312  sic@
    SrsBandwidthConfiguration_Type  SrsBandwidthConfiguration,      //inline type ENUMERATED {bw0, bw1, bw2, bw3, bw4, bw5, bw6, bw7}srsBandwidth
    CfiValue_Type                   Cfi                             // @sic R5s090180: CFI value dependant on the bandwidth sic@
  };
  
  const M_TMSI_Type            tsc_M_TMSI1 := oct2bit('12345678'O);     /* @status    APPROVED */
  const AbsoluteCellPower_Type tsc_ServingCellRS_EPRE := -85;           /* @status    APPROVED */
  const AbsoluteCellPower_Type tsc_SuitableCellRS_EPRE := -97;          /* @status    APPROVED */
  const AbsoluteCellPower_Type tsc_NonSuitableCellRS_EPRE := -115;      /* @status    APPROVED */
  const AbsoluteCellPower_Type tsc_NonSuitableOffCellRS_EPRE := -145;   /* @status    APPROVED */
  const AbsoluteCellPower_Type tsc_Suitable_NeighbourIntraFreq_CellRS_EPRE := -91;
  
  const RACH_TimingAdvance_Type tsc_RACH_TA_Def := 0;                   /* @status    APPROVED
                                                                           @sic R5s090180 sic@ */
  const P_b_Type tsc_P_b_1Tx := 0;    /* acc. to 36.508 Table Table 4.6.3-5;
                                         @status    APPROVED */
  const P_b_Type tsc_P_b_2Tx := 1;    // acc. to 36.508 Table Table 4.6.3-5
  
  
  /******************************************************************************/
  // --------------------------  TEMPLATES --------------------------------------
  /*******************************************************************************/

  template (value) PLMN_IdentityList cs_PlmnIdList_1Entry (template (value) PLMN_Identity p_PLMN_Id):=
  { /* @status    APPROVED */
    {
      plmn_Identity := p_PLMN_Id,
      cellReservedForOperatorUse := notReserved
    }
  };
  
  template (value) EUTRA_CellInfo_Type cs_EUTRA_CellInfoDef(template (value) CellIdentities_Type     p_CellIds,
                                                            template (value) Combination_Type        p_Combination,
                                                            template (value) FrequencyBand_Type      p_FrequencyBand,
                                                            template (value) CarrierFreqEUTRA        p_UL_DL_Earfcn,
                                                            Dl_Bandwidth_Type       p_DL_ChBandwidth,
                                                            template (omit)  Ul_Bandwidth_Type       p_UL_ChBandwidth,
                                                            template (value) NAS_Parameter_Type      p_NAS_Param,
                                                            template (value) BcchInfo_Type           p_BCCH_Info,
                                                            template (value) CellTimingInfo_Type     p_CellTimingInfo,
                                                            template (value) EUTRA_FDD_TDD_CellInfo_Type   p_FDD_TDD_Info,
                                                            CfiValue_Type                            p_CfiValue,
                                                            RACH_TimingAdvance_Type                  p_RAR_TA,
                                                            SR_PUCCH_ResourceIndex_Type              p_SR_PUCCH_ResourceIndex   // @sic R5s090312 sic@
                                                            ) :=
  { /* @desc      Default cell info value
     * @status    APPROVED */
    CellIds      :=  p_CellIds,
    Frequency := {
      FrequencyBandIndicator :=  p_FrequencyBand,
      DL_ChBandwidth := p_DL_ChBandwidth,
      UL_ChBandwidth := p_UL_ChBandwidth,
      UL_DL_Earfcn           :=  p_UL_DL_Earfcn
    },

    FDD_TDD_Info := p_FDD_TDD_Info,
    Sysinfo := {
      BCCH_Info           :=  p_BCCH_Info,
      Combination         :=  p_Combination,
      SB1_ValueTagChanged :=  false
    },
    NAS_Parameters    :=  p_NAS_Param,
    CellTimingInfo    :=  p_CellTimingInfo,
    ReferencePower := {
      MaxReferencePower := tsc_ServingCellRS_EPRE,
      Attenuation := {Off := true}
    },
    CellConfigCapability := fullCell,         // all cells are intialised by default with fullCell
    RNTI  := { C_RNTI := tsc_C_RNTI_Def },
    PhysicalParameters := {
      Cfi := p_CfiValue,
      RAR_TA := p_RAR_TA,
      sr_PUCCH_ResourceIndex := p_SR_PUCCH_ResourceIndex,
      PDSCH_p_b := tsc_P_b_1Tx      // acc to 36.508 Table 4.6.3-5: PDSCH-ConfigCommon-DEFAULT @sic R5-100786 sic@
    },
    AntennaInfo := {  // default value for 1TX   @sic R5-100786 sic@
      SS_AntennaInfoCommon := cs_AntennaInfoCommon_1Port,
      AntennaInfoCommon := omit,
      SS_AntennaInfoDedicated := cs_AntennaInfoDedicated_Def,
      AntennaInfoDedicated := cs_PhysicalConfigDedicated_AntennaInfo_Def
    }
  };
  
  template (value) PLMN_Identity cs_HPLMN_Def := { mcc := {0,0,1},  mnc :={0,1} };        /* @status    APPROVED */
  template (value) PLMN_Identity cs_HPLMN_001_11 := { mcc := {0,0,1},  mnc :={1,1} };     /* @status    (APPROVED) */
  template (value) PLMN_Identity cs_HPLMN_001_21 := { mcc := {0,0,1},  mnc :={2,1} };     /* @status    (APPROVED) */
  template (value) PLMN_Identity cs_HPLMN_001_31 := { mcc := {0,0,1},  mnc :={3,1} };     /* @status    (APPROVED) */
  template (value) PLMN_Identity cs_HPLMN_002_11 := { mcc := {0,0,2},  mnc :={1,1} };     /* @status    APPROVED */
  template (value) PLMN_Identity cs_HPLMN_003_21 := { mcc := {0,0,3},  mnc :={2,1} };     /* @status    APPROVED */
  template (value) PLMN_Identity cs_HPLMN_004_31 := { mcc := {0,0,4},  mnc :={3,1} };     /* @status    APPROVED */
  template (value) PLMN_Identity cs_HPLMN_001_02 := { mcc := {0,0,1},  mnc :={0,2} };     /* @status    APPROVED */
  template (value) PLMN_Identity cs_HPLMN_002_101 := { mcc := {0,0,2},  mnc :={1,0,1} };  /* @status    APPROVED */
  template (value) PLMN_Identity cs_HPLMN_003_101 := { mcc := {0,0,3},  mnc :={1,0,1} };  /* @status    APPROVED */
  template (value) PLMN_Identity cs_HPLMN_010_12 := { mcc := {0,1,0},  mnc :={1,2} };     /* @status    (APPROVED) */
  
  template (value) GutiParameters_Type cs_Guti(template (value) PLMN_Identity p_PLMN,
                                               integer p_MmeGroupId,
                                               integer p_MmeCode) :=
  { /* @status    APPROVED */
    PLMN_Identity := p_PLMN,
    MME_GroupId := int2bit(p_MmeGroupId,16),
    MME_Code := int2bit(p_MmeCode,8),
    M_TMSI  := tsc_M_TMSI1
  };
  
  
  template (value) EUTRA_FDD_TDD_CellInfo_Type cs_EUTRA_FDD_Info :=
  { /* @status    APPROVED */
    FDD_TDD   :=  FDD,
    cqi_ReportConfig := cs_CQI_ReportingPeriodic_FDD,
    soundingRS_UL_Config := cs_508_SoundingRsUl_ConfigDedicated_Default_FDD,
    pucch_Config := cs_508_PUCCH_ConfigDedicated_Default_FDD,
    TDD_SubframeAssignment := omit,   // Applicable for TDD only
    sr_ConfigIndex := 30 // @sic R5-102177 sic@
  };
  
  
  template (value) EUTRA_FDD_TDD_CellInfo_Type cs_EUTRA_TDD_Info (TDD_SubframeAssignment_Type p_TDD_SubframeAssignment) :=
  { /* @status    APPROVED */
    FDD_TDD   :=  TDD,
    cqi_ReportConfig := cds_CQI_ReportingPeriodic_TDD,
    soundingRS_UL_Config := cds_508_SoundingRsUl_ConfigDedicated_Default_TDD,
    pucch_Config := cds_508_PUCCH_ConfigDedicated_Default_TDD,
    TDD_SubframeAssignment := p_TDD_SubframeAssignment,
    sr_ConfigIndex := 27 // @sic R5-102177 sic@
  };
  
  /******************************************************************************/
  // --------------------------  FUNCTIONS --------------------------------------
  /*******************************************************************************/
  /*
   * @desc      Return the index corresponding to p_CellId
   *            local function used only in that module
   * @param     p_CellId
   * @return    integer
   * @status    APPROVED
   * @sic R5096440 sic@
   */
  function f_EUTRA_CellInfo_GetIndex ( CellId_Type p_CellId ) return integer
  {
    var integer v_Index := 0;
    
    select (p_CellId) {
      case (eutra_CellA, eutra_Cell1) {
        v_Index := 0;
      }
      case (eutra_CellB, eutra_Cell2) {
        v_Index := 1;
      }
      case (eutra_CellC, eutra_Cell3) {
        v_Index := 2;
      }
      case (eutra_CellD, eutra_Cell4) {
        v_Index := 3;
      }
      case (eutra_CellE, eutra_Cell6) {
        v_Index := 4;
      }
      case (eutra_Cell10) {
        v_Index := 5;
      }
      case (eutra_CellG, eutra_Cell11) {
        v_Index := 6;
      }
      case (eutra_CellH, eutra_Cell12) {
        v_Index := 7;
      }
      case (eutra_CellI, eutra_Cell13) {
        v_Index := 8;
      }
      case (eutra_CellJ, eutra_Cell14) {
        v_Index := 9;
      }
      case (eutra_Cell23, eutra_CellK) {
        v_Index := 10;
      }
      case (eutra_CellL) {
        v_Index := 11;
      }
      case (eutra_CellM) {
        v_Index := 12;
      }
      case else  {
        FatalError (__FILE__, __LINE__, "Invalid CellId");
      }
    }
    return v_Index;
  };
  
  
  /*******************************************************************************/
  // ============================ Initialisation functions =================
  /*
   * @desc      Initialise the cell physical ID according to 36.508 Table 4.4.2-1A and 36.523-3 cl 7.4.4
   * @param     p_CellId
   * @return    PhysCellId
   * @status    APPROVED
   * @sic R5096440 sic@
   */
  function fl_EUTRA_InitPhysicalCellId (CellId_Type p_CellId) return PhysCellId
  {
    var PhysCellId v_PhysicalCellId;
    select (p_CellId) {
      case (eutra_Cell1) {
        v_PhysicalCellId := 0;
      }
      case (eutra_CellA) {
        v_PhysicalCellId := 1;
      }
      case (eutra_CellB, eutra_Cell2) {
        v_PhysicalCellId := 2;
      }
      case (eutra_CellC, eutra_Cell3) {
        v_PhysicalCellId := 3;
      }
      case (eutra_CellD, eutra_Cell4) {
        v_PhysicalCellId := 4;
      }
      case (eutra_Cell6) {
        v_PhysicalCellId := 6;
      }
      case (eutra_Cell10) {
        v_PhysicalCellId := 10;  // @sic R5s100392 sic@
      }
      case (eutra_CellG, eutra_Cell11) {
        v_PhysicalCellId := 11;
      }
      case (eutra_CellH, eutra_Cell12) {
        v_PhysicalCellId := 12;
      }
      case (eutra_CellI, eutra_Cell13) {
        v_PhysicalCellId := 13;
      }
      case (eutra_CellJ, eutra_Cell14) {
        v_PhysicalCellId := 14;
      }
      case (eutra_CellK) {
        v_PhysicalCellId := 15;
      }
      case (eutra_CellL) {
        v_PhysicalCellId := 16;
      }
      case (eutra_CellM) {
        v_PhysicalCellId := 17;
      }
      case (eutra_CellE, eutra_Cell23) {
        v_PhysicalCellId := 23;
      }
      case else  {
        FatalError (__FILE__, __LINE__, "Invalid CellId");
      }
    }
    return v_PhysicalCellId;
  }
  
  //------------------------------------------------------------------------------------------
  /*
   * @desc      Initialise the physical cell identity and the E-UTRAN cell identity according to 36.508 table 4.4.2-1A
   * @param     p_CellId
   * @return    CellIdentities_Type
   * @status    APPROVED
   * @sic R5096440 sic@
   */
  function fl_EUTRA_InitCellIdentities ( CellId_Type p_CellId ) return CellIdentities_Type
  {
    var CellIdentities_Type v_CellIds;
    
    // Initialise the physical cell indentiy
    v_CellIds.PhysicalCellId := fl_EUTRA_InitPhysicalCellId (p_CellId);
    
    // Initialise the cell Identity: E-NodeB (20 bits) + Cell Identity (8 bits)
    // Values according to 36.508 Table 4.4.2-1A
    select (p_CellId) {
      case (eutra_Cell1) {
        v_CellIds.CellIdentity := int2bit(1, 20) & int2bit(0, 8);
      }
      case (eutra_Cell2) {
        v_CellIds.CellIdentity := int2bit(1, 20) & int2bit(2, 8);
      }
      case (eutra_Cell3) {
        v_CellIds.CellIdentity := int2bit(2, 20) & int2bit(3, 8);
      }
      case (eutra_Cell4) {
        v_CellIds.CellIdentity := int2bit(3, 20) & int2bit(4, 8);
      }
      case (eutra_Cell6) {
        v_CellIds.CellIdentity := int2bit(4, 20) & int2bit(6, 8);
      }
      case (eutra_Cell10) {
        v_CellIds.CellIdentity := int2bit(5, 20) & int2bit(10, 8);
      }
      case (eutra_Cell11) {
        v_CellIds.CellIdentity := int2bit(6, 20) & int2bit(11, 8);
      }
      case (eutra_Cell12) {
        v_CellIds.CellIdentity := int2bit(2, 20) & int2bit(12, 8);
      }
      case (eutra_Cell13) {
        v_CellIds.CellIdentity := int2bit(4, 20) & int2bit(13, 8);
      }
      case (eutra_Cell14) {
        v_CellIds.CellIdentity := int2bit(7, 20) & int2bit(14, 8);
      }
      case (eutra_Cell23) {
        v_CellIds.CellIdentity := int2bit(6, 20) & int2bit(23, 8);
      }
      case else  {
        FatalError (__FILE__, __LINE__, "Invalid CellId");
      }
    }
    return v_CellIds;
  };
  
  // ---------------------------------------------------------------------------------
  /*
   * @desc      Return the FDD or TDD mode based on the parameterised Band
   * @param     p_FrequencyBand
   * @return    EUTRA_FDD_TDD_CellInfo_Type
   * @status    APPROVED
   */
  function fl_InitFDD_TDD_FromBand (FrequencyBand_Type p_FrequencyBand) return EUTRA_FDD_TDD_CellInfo_Type
  {
    var template (value) EUTRA_FDD_TDD_CellInfo_Type v_FDD_TDD_Info;
    
    if (p_FrequencyBand < 33)   {            // Bands below 33 are reserved for FDD
      v_FDD_TDD_Info := cs_EUTRA_FDD_Info;
    } else {                                 // Bands above 33 are reserved for TDD
      v_FDD_TDD_Info := cs_EUTRA_TDD_Info( px_eTDDsubframeConfig );  //@sic R5-096691  sic@
    }
    return valueof(v_FDD_TDD_Info);          // Note: valueof cannot be avoided here
  };
  
  //------------------------------------------------------------------------------------------
  /*
   * @desc      Initialise the physical cell identity and the E-UTRAN cell identity according to 36.523-3 clause 7.4.4
   * @param     p_CellId
   * @param     p_CellsOnPLMN
   * @return    CellIdentities_Type
   * @status    APPROVED
   * @sic R5096440 sic@
   */
  function fl_EUTRA_InitCellIdentities_NAS ( CellId_Type              p_CellId,
                                             EUTRA_NAS_NumOfPLMN_Type p_CellsOnPLMN ) return CellIdentities_Type
  {
    var CellIdentities_Type v_CellIds;
    
    // Initialise the physical cell indentiy
    v_CellIds.PhysicalCellId := fl_EUTRA_InitPhysicalCellId (p_CellId);
    
    // Initialise the cell Identity: E-NodeB (20 bits) + Cell Identity (8 bits)
    
    select (p_CellsOnPLMN) {
      case (LTE_CellsOnDifferentPLMN) {
        // Values according to 36.523-3 Table 7.4.4-1
        select (p_CellId) {
          case (eutra_CellA) {
            v_CellIds.CellIdentity := int2bit(33, 20) & int2bit(1, 8);
          }
          case (eutra_CellB) {
            v_CellIds.CellIdentity := int2bit(33, 20) & int2bit(2, 8);
          }
          case (eutra_CellC) {
            v_CellIds.CellIdentity := int2bit(33, 20) & int2bit(3, 8);
          }
          case (eutra_CellD) {
            v_CellIds.CellIdentity := int2bit(33, 20) & int2bit(4, 8);
          }
          case (eutra_CellE) {
            v_CellIds.CellIdentity := int2bit(53, 20) & int2bit(23, 8);
          }
          case (eutra_CellG) {
            v_CellIds.CellIdentity := int2bit(34, 20) & int2bit(11, 8);
          }
          case (eutra_CellH) {
            v_CellIds.CellIdentity := int2bit(34, 20) & int2bit(12, 8);
          }
          case (eutra_CellI) {
            v_CellIds.CellIdentity := int2bit(35, 20) & int2bit(13, 8);
          }
          case (eutra_CellJ) {
            v_CellIds.CellIdentity := int2bit(36, 20) & int2bit(14, 8);
          }
          case (eutra_CellK) {
            v_CellIds.CellIdentity := int2bit(35, 20) & int2bit(15, 8);
          }
          case (eutra_CellL) {
            v_CellIds.CellIdentity := int2bit(35, 20) & int2bit(16, 8);
          }
          case (eutra_CellM) {
            v_CellIds.CellIdentity := int2bit(33, 20) & int2bit(17, 8);
          }
          case else {
            FatalError (__FILE__, __LINE__, "Invalid CellId");
          }
        }
      }
      case (LTE_AllCellsOnSamePLMN) {
        // Values according to 36.508 Table 6.3.2.2-2
        select (p_CellId) {
          case (eutra_CellA) {
            v_CellIds.CellIdentity := int2bit(17, 20) & int2bit(1, 8);
          }
          case (eutra_CellB) {
            v_CellIds.CellIdentity := int2bit(17, 20) & int2bit(2, 8);
          }
          case (eutra_CellC) {
            v_CellIds.CellIdentity := int2bit(18, 20) & int2bit(3, 8);
          }
          case (eutra_CellD) {
            v_CellIds.CellIdentity := int2bit(17, 20) & int2bit(4, 8);
          }
          case (eutra_CellM) {
            v_CellIds.CellIdentity := int2bit(33, 20) & int2bit(17, 8);
          }
          case else  {
            FatalError (__FILE__, __LINE__, "Invalid CellId for NAS cells on the same PLMN");
          }
        }
      }
      case else {
        FatalError (__FILE__, __LINE__, "Invalid EUTRA_NAS_NumOfPLMN");
      }
    }
    return v_CellIds;
  };
  
  // ---------------------------------------------------------------------------------
  /*
   * @desc      return the cell timing info according to 36.253-3 clause 7.4.3
   * @param     p_CellId
   * @param     p_FddOrTdd
   * @param     p_CellsOnPLMN   Parameter to be used for NAS cells
   * @return    CellTimingInfo_Type
   * @status    APPROVED
   * @sic R5-096691 sic@
   */
  function fl_EUTRA_InitialiseCellTiming (CellId_Type p_CellId,
                                          EUTRA_FDD_TDD_Mode_Type p_FddOrTdd,
                                          EUTRA_NAS_NumOfPLMN_Type p_CellsOnPLMN ) return CellTimingInfo_Type
  {
    var CellTimingInfo_Type v_CellTiming;
    var integer v_TcellTDD := 0;     // (0..307199) acc. to 36.523-3 Table 7.4.3.1-1
    var integer v_TcellFDD := 0;     // (0..307199) acc. to 36.523-3 Table 7.4.3.1-1
    var integer v_SfnOffset:= 0;     // (0..1023) acc. to 36.523-3 Table 7.4.3.1-1
    
    select (p_CellId) {
      case (eutra_Cell1, eutra_CellA) {
        v_SfnOffset := 0;
        v_TcellFDD := 0;
        v_TcellTDD := 0;
      }
      case (eutra_Cell2){
        v_SfnOffset := 124;
        v_TcellFDD := 30720;
        v_TcellTDD := 155792;
      }
      case (eutra_Cell3){
        v_SfnOffset := 257;
        v_TcellFDD := 150897;
        v_TcellTDD := 0;
      }
      case (eutra_Cell4){
        v_SfnOffset := 1000;
        v_TcellFDD := 61440;
        v_TcellTDD := 157984;
      }
      case (eutra_Cell6){
        v_SfnOffset := 657;
        v_TcellFDD := 524;
        v_TcellTDD := 0;
      }
      case (eutra_Cell10){
        v_SfnOffset := 129;
        v_TcellFDD := 43658;
        v_TcellTDD := 0;
      }
      case (eutra_Cell11){
        v_SfnOffset := 957;
        v_TcellFDD := 92160;
        v_TcellTDD := 155792;
      }
      case (eutra_Cell12){
        v_SfnOffset := 1015;
        v_TcellFDD := 181617;
        v_TcellTDD := 155792;
      }
      case (eutra_Cell13){
        v_SfnOffset := 890;
        v_TcellFDD := 31244;
        v_TcellTDD := 155792;
      }
      case (eutra_Cell14){
        v_SfnOffset := 680;
        v_TcellFDD := 300501;
        v_TcellTDD := 0;
      }
      case (eutra_Cell23) {
        v_SfnOffset := 383;
        v_TcellFDD := 212337;
        v_TcellTDD := 155792;
      }
      case (eutra_CellB) {
        v_SfnOffset := 124;
        v_TcellFDD := 30720;
        v_TcellTDD := 155792;  // @sic R5-101050 sic@
      }
      case (eutra_CellC) {
        v_SfnOffset := 257;
        if ( p_CellsOnPLMN == LTE_CellsOnDifferentPLMN) {
          v_TcellFDD := 61440;
          v_TcellTDD := 157984;
        } else {
          v_TcellFDD := 150897;
          v_TcellTDD := 0;
        };
      }
      case (eutra_CellD) {
        v_SfnOffset := 1000;
        if ( p_CellsOnPLMN == LTE_CellsOnDifferentPLMN) {
          v_TcellFDD := 92160;
          v_TcellTDD := 155792;
        } else {
          v_TcellFDD := 61440;
          v_TcellTDD := 157984;
        };
      }
      case (eutra_CellE) {
        v_SfnOffset := 657;
        if ( p_CellsOnPLMN == LTE_CellsOnDifferentPLMN) {v_TcellFDD := 92160} else {v_TcellFDD := 524};
        v_TcellTDD := 0;
      }
      case (eutra_CellG) {
        v_SfnOffset := 957;
        v_TcellFDD := 631;
        v_TcellTDD := 0;
      }
      case (eutra_CellH) {
        v_SfnOffset := 1015;
        v_TcellFDD := 31351;
        v_TcellTDD := 155792
          }
      case (eutra_CellI) {
        v_SfnOffset := 890;
        v_TcellFDD := 127200;
        v_TcellTDD := 0;
      }
      case (eutra_CellJ) {
        v_SfnOffset := 680;
        v_TcellFDD := 1327;
        v_TcellTDD := 0;
      }
      case (eutra_CellK) {
        v_SfnOffset := 383;
        v_TcellFDD := 157920;
        v_TcellTDD := 155792;
      }
      case (eutra_CellL) {
        v_SfnOffset := 562;
        v_TcellFDD := 188640;
        v_TcellTDD := 157984;
      }
      case (eutra_CellM) {
        v_SfnOffset := 471;
        if ( p_CellsOnPLMN == LTE_CellsOnDifferentPLMN) {
          v_TcellFDD := 122880;
          v_TcellTDD := 157984;
        } else {
          v_TcellFDD := 31244;
          v_TcellTDD := 155792;
        };
      }
      case else {
        FatalError (__FILE__, __LINE__, "invalid cell Idendtity");
      }
    }
    
    v_CellTiming.SfnOffset := v_SfnOffset;
    
    select (p_FddOrTdd) {
      case (TDD) {
        v_CellTiming.Tcell := v_TcellTDD;
      }
      case (FDD) {
        v_CellTiming.Tcell := v_TcellFDD;
      }
      case else {
        FatalError (__FILE__, __LINE__, "invalid mode");
      }
    }
    return v_CellTiming;
  }
  
  //------------------------------------------------------------------------------------------
  /*
   * @desc      Return PRACH Root sequence index according to
   *            - table 4.4.2-1A in 36.508 cl 4.4.2
   *            - table 6.3.2.2-2 and 6.3.2.2-3 in 36.508 cl 6.3.2.2
   * @param     p_CellId
   * @param     p_FddOrTdd
   * @param     p_CellsOnPLMN
   * @return    RootSequenceIndex_Type
   * @status    APPROVED
   * @sic R5096641 R5-104732 sic@
   */
  function f_InitialisePRACH_RootSequenceIndex ( CellId_Type p_CellId,
                                                  EUTRA_FDD_TDD_Mode_Type p_FddOrTdd,
                                                  EUTRA_NAS_NumOfPLMN_Type p_CellsOnPLMN )
    return RootSequenceIndex_Type
  {
    var RootSequenceIndex_Type v_RootSequenceIndexFDD := 0;
    var RootSequenceIndex_Type v_RootSequenceIndexTDD := 0;
    
    select (p_CellId) {
      case (eutra_Cell1) {v_RootSequenceIndexFDD:=22; v_RootSequenceIndexTDD:=0}
      case (eutra_Cell2) {v_RootSequenceIndexFDD:=86; v_RootSequenceIndexTDD:=8}
      case (eutra_Cell3) {v_RootSequenceIndexFDD:=22; v_RootSequenceIndexTDD:=0}
      case (eutra_Cell4) {v_RootSequenceIndexFDD:=150; v_RootSequenceIndexTDD:=16}
      case (eutra_Cell6) {v_RootSequenceIndexFDD:=22; v_RootSequenceIndexTDD:=0}
      case (eutra_Cell10) {v_RootSequenceIndexFDD:=22; v_RootSequenceIndexTDD:=0}
      case (eutra_Cell11) {v_RootSequenceIndexFDD:=214; v_RootSequenceIndexTDD:=24}
      case (eutra_Cell12) {v_RootSequenceIndexFDD:=86; v_RootSequenceIndexTDD:=8}
      case (eutra_Cell13) {v_RootSequenceIndexFDD:=86; v_RootSequenceIndexTDD:=8}
      case (eutra_Cell14) {v_RootSequenceIndexFDD:=22; v_RootSequenceIndexTDD:=0}
      case (eutra_Cell23) {v_RootSequenceIndexFDD:=150; v_RootSequenceIndexTDD:=16}
      case (eutra_CellA) {v_RootSequenceIndexFDD:=22; v_RootSequenceIndexTDD:=0}
      case (eutra_CellB) {v_RootSequenceIndexFDD:=86; v_RootSequenceIndexTDD:=8}
      case (eutra_CellC) {
        if (p_CellsOnPLMN==LTE_AllCellsOnSamePLMN) {
          v_RootSequenceIndexFDD:=22;
          v_RootSequenceIndexTDD:=0;
        } else {
          v_RootSequenceIndexFDD:=150;
          v_RootSequenceIndexTDD:=16;
        }
      }
      case (eutra_CellD) {
        if (p_CellsOnPLMN==LTE_AllCellsOnSamePLMN) {
          v_RootSequenceIndexFDD:=150;
          v_RootSequenceIndexTDD:=16;
        } else {
          v_RootSequenceIndexFDD:=214;
          v_RootSequenceIndexTDD:=24;
        }
      }
      case (eutra_CellE) {
        v_RootSequenceIndexFDD:=22;
        v_RootSequenceIndexTDD:=0;
      }
      case (eutra_CellG) {
        v_RootSequenceIndexFDD:=86;
        v_RootSequenceIndexTDD:=8;
      }
      case (eutra_CellH) {
        v_RootSequenceIndexFDD:=150;
        v_RootSequenceIndexTDD:=16;
      }
      case (eutra_CellI) {
        v_RootSequenceIndexFDD:=22;
        v_RootSequenceIndexTDD:=0;
      }
      case (eutra_CellJ) {
        v_RootSequenceIndexFDD:=22;
        v_RootSequenceIndexTDD:=0;
      }
      case (eutra_CellK) {
        v_RootSequenceIndexFDD:=86;
        v_RootSequenceIndexTDD:=8;
      }
      case (eutra_CellL) {
        v_RootSequenceIndexFDD:=150;
        v_RootSequenceIndexTDD:=16;
      }
      case (eutra_CellM) {
        if (p_CellsOnPLMN==LTE_AllCellsOnSamePLMN) {
          v_RootSequenceIndexFDD:=86;
          v_RootSequenceIndexTDD:=8;
        } else {
          v_RootSequenceIndexFDD:=278;
          v_RootSequenceIndexTDD:=32;
        }
      }
      case else {
        FatalError (__FILE__, __LINE__, "invalid cellId value");
      }
    }
    if (p_FddOrTdd == FDD) {
      return v_RootSequenceIndexFDD;
    } else {
      return v_RootSequenceIndexTDD;
    }
  }
  
  //------------------------------------------------------------------------------------------
  /*
   * @desc      Return the Random Access Request Timing Advance according to 36.523-3 cl 7.4.3
   *            - table 7.4.3.1-1, 7.4.3.1-1 and 7.4.3.1-3 in 36.523-3 cl 7.4.3
   * @param     p_CellId
   * @param     p_FddOrTdd
   * @param     p_CellsOnPLMN
   * @return    RACH_TimingAdvance_Type
   * @status    APPROVED
   * @sic R5096691 sic@
   */
  function fl_InitialiseRAR_TA ( CellId_Type p_CellId,
                                 EUTRA_FDD_TDD_Mode_Type p_FddOrTdd,
                                 EUTRA_NAS_NumOfPLMN_Type p_CellsOnPLMN )
    return RACH_TimingAdvance_Type
  {
    var RACH_TimingAdvance_Type v_RAR_TA:= tsc_RACH_TA_Def;
    
    if (p_FddOrTdd == FDD) {
      v_RAR_TA := tsc_RACH_TA_Def;
    } else {
      select (p_CellId) {
        case (eutra_Cell1, eutra_Cell3, eutra_Cell6, eutra_Cell10, eutra_Cell14) {
          v_RAR_TA:=0;
        }
        case (eutra_Cell2, eutra_Cell11, eutra_Cell12, eutra_Cell13 ) {
          v_RAR_TA:=137;
        }
        case (eutra_Cell4, eutra_Cell23) {
          v_RAR_TA:=274;
        }
        case (eutra_CellA, eutra_CellE, eutra_CellG, eutra_CellI, eutra_CellJ) {
          v_RAR_TA:=0;
        }
        case (eutra_CellB, eutra_CellH, eutra_CellK) {
          v_RAR_TA:=137;
        }
        case (eutra_CellL) {
          v_RAR_TA:=274;
        }
        case (eutra_CellC) {
          if (p_CellsOnPLMN==LTE_AllCellsOnSamePLMN) {
            v_RAR_TA:=274;
          } else {
            v_RAR_TA:=0;
          }
        }
        case (eutra_CellD) {
          if (p_CellsOnPLMN==LTE_AllCellsOnSamePLMN) {
            v_RAR_TA:=137;
          } else {
            v_RAR_TA:=274;
          }
        }
        case (eutra_CellM) {
          if (p_CellsOnPLMN==LTE_AllCellsOnSamePLMN) {
            v_RAR_TA:=274;
          } else {
            v_RAR_TA:=137;
          }
        }
        case else {
          FatalError (__FILE__, __LINE__, "invalid cellId value");
        }
      }
    }
    return v_RAR_TA;
  }
  
  //------------------------------------------------------------------------------------------
   /*
   * @desc      Convert the DL bandwidth value from Dl_Bandwidth_Type to Ul_Bandwidth_Type
   * @param     p_DL_Bandwidth
   * @return    Ul_Bandwidth_Type
   * @status    APPROVED
   */
  function  f_ConvertDL_BandwidthToUL ( Dl_Bandwidth_Type p_DL_Bandwidth ) return Ul_Bandwidth_Type
  {
    var Ul_Bandwidth_Type v_UL_Bandwidth;
    select (p_DL_Bandwidth) {
      case (n6){ v_UL_Bandwidth := n6  }
      case (n15){ v_UL_Bandwidth := n15  }
      case (n25){ v_UL_Bandwidth := n25  }
      case (n50){ v_UL_Bandwidth := n50  }
      case (n75){ v_UL_Bandwidth := n75  }
      case (n100){ v_UL_Bandwidth := n100  }
      case else { FatalError (__FILE__, __LINE__, "invalid value for ChannelBandwidth"); }
    };
    return v_UL_Bandwidth;
  };

  //------------------------------------------------------------------------------------------
  /*
   * @desc      Return dependants parameters for the parameterised bandwidth as per 36.508:
   *            - table 4.4.3.4-1 in 36.508 cl 4.4.3.4
   *            - table 4.3.4.1-1 in 36.508 cl 4.3.4
   *            - table 4.6.8-1 in 36.508 cl 4.6.8
   *            - CFI vlaue acc. to 36.508 cl 4.3.3
   * @param     p_DL_ChBandwidth
   * @param     p_UL_ChBandwidth
   * @return    ChannelBandwidthDependency_Type
   * @status    APPROVED
   */
  function f_EUTRA_BandDependentParam(Dl_Bandwidth_Type p_DL_ChBandwidth,
                                      Ul_Bandwidth_Type p_UL_ChBandwidth)
    return ChannelBandwidthDependency_Type
  {
    var ChannelBandwidthDependency_Type v_ChBandDependency;
    
    // Initialise parameters related to DL Bandwidth
    select (p_DL_ChBandwidth )
    {
      case (n6){                                         //1.4MHz
        v_ChBandDependency.SIB3_periodicity := rf64;
        v_ChBandDependency.SIB4_periodicity := rf128;
        v_ChBandDependency.SIB5_periodicity := rf128;
        v_ChBandDependency.SIB6_periodicity := rf128;
        v_ChBandDependency.SIB7_periodicity := rf128;
        v_ChBandDependency.SIB8_periodicity := rf128;
        v_ChBandDependency.SIB10_periodicity := rf64;
        v_ChBandDependency.SIB11_periodicity := rf64;
        v_ChBandDependency.AllowedMeasBandwidth := mbw6;        //AllowedMeasBandwidth
        v_ChBandDependency.Cfi := 3;                            // @sic R5s090180 sic@
      }
      case (n15){                                         //3MHz
        v_ChBandDependency.SIB3_periodicity := rf64;
        v_ChBandDependency.SIB4_periodicity := rf128;
        v_ChBandDependency.SIB5_periodicity := rf128;
        v_ChBandDependency.SIB6_periodicity := rf128;
        v_ChBandDependency.SIB7_periodicity := rf128;
        v_ChBandDependency.SIB8_periodicity := rf128;
        v_ChBandDependency.SIB10_periodicity := rf64;
        v_ChBandDependency.SIB11_periodicity := rf64;
        v_ChBandDependency.AllowedMeasBandwidth := mbw15;       //AllowedMeasBandwidth
        v_ChBandDependency.Cfi := 3;                            // @sic R5s090180 sic@
      }
      case (n25){                                         //5MHz
        v_ChBandDependency.SIB3_periodicity := rf32;
        v_ChBandDependency.SIB4_periodicity := rf64;
        v_ChBandDependency.SIB5_periodicity := rf64;
        v_ChBandDependency.SIB6_periodicity := rf64;
        v_ChBandDependency.SIB7_periodicity := rf64;
        v_ChBandDependency.SIB8_periodicity := rf64;
        v_ChBandDependency.SIB10_periodicity := rf32;
        v_ChBandDependency.SIB11_periodicity := rf32;
        v_ChBandDependency.AllowedMeasBandwidth := mbw25;
        v_ChBandDependency.Cfi := 3;                            // @sic R5s090180 sic@
      }
      case (n50){                                         //10MHz
        v_ChBandDependency.SIB3_periodicity := rf32;
        v_ChBandDependency.SIB4_periodicity := rf64;
        v_ChBandDependency.SIB5_periodicity := rf64;
        v_ChBandDependency.SIB6_periodicity := rf64;
        v_ChBandDependency.SIB7_periodicity := rf64;
        v_ChBandDependency.SIB8_periodicity := rf64;
        v_ChBandDependency.SIB10_periodicity := rf32;
        v_ChBandDependency.SIB11_periodicity := rf32;
        v_ChBandDependency.AllowedMeasBandwidth := mbw50;       //AllowedMeasBandwidth
        v_ChBandDependency.Cfi := 2;                            // @sic R5s090180 sic@
      }
      case (n75){                                         //15MHz
        v_ChBandDependency.SIB3_periodicity := rf32;
        v_ChBandDependency.SIB4_periodicity := rf64;
        v_ChBandDependency.SIB5_periodicity := rf64;
        v_ChBandDependency.SIB6_periodicity := rf64;
        v_ChBandDependency.SIB7_periodicity := rf64;
        v_ChBandDependency.SIB8_periodicity := rf64;
        v_ChBandDependency.SIB10_periodicity := rf32;
        v_ChBandDependency.SIB11_periodicity := rf32;
        v_ChBandDependency.AllowedMeasBandwidth := mbw75;       //AllowedMeasBandwidth
        v_ChBandDependency.Cfi := 2;                            // @sic R5s090180 sic@
      }
      case (n100){                                         //20MHz
        v_ChBandDependency.SIB3_periodicity := rf32;
        v_ChBandDependency.SIB4_periodicity := rf64;
        v_ChBandDependency.SIB5_periodicity := rf64;
        v_ChBandDependency.SIB6_periodicity := rf64;
        v_ChBandDependency.SIB7_periodicity := rf64;
        v_ChBandDependency.SIB8_periodicity := rf64;
        v_ChBandDependency.SIB10_periodicity := rf32;
        v_ChBandDependency.SIB11_periodicity := rf32;
        v_ChBandDependency.AllowedMeasBandwidth := mbw100;       //AllowedMeasBandwidth
        v_ChBandDependency.Cfi := 2;                            // @sic R5s090180 sic@
      }
      case else {
        FatalError (__FILE__, __LINE__, "invalid value for ChannelBandwidth");
      }
    }
    
    // Initialise parameters related to UL Bandwidth
    // @sic R5s100029 sic@
    select (p_UL_ChBandwidth)    {
      case (n6){     //1.4MHz
        //v_ChBandDependency.Prach_FrequencyOffset := valueFFS;          //integer
        //v_ChBandDependency.N_RB_CQI   := valueFFS;
        //v_ChBandDependency.Pusch_HoppingOffset := valueFFS ;           //PUCCH_ConfigCommon
        //v_ChBandDependency.sr_PUCCH_ResourceIndex :=  valueFFS;
        //v_ChBandDependency.SrsBandwidthConfiguration := valueFFS;      //SoundingRS_UL_ConfigCommon.srs_BandwidthConfig
      }
      case (n15){    //3MHz
        //v_ChBandDependency.Prach_FrequencyOffset := valueFFS;           //integer
        //v_ChBandDependency.N_RB_CQI   := valueFFS;                      //PUCCH_ConfigCommon.nRB_CQI inline type - FFS in 36.331 ENUMERATED {ffs}
        //v_ChBandDependency.Pusch_HoppingOffset    valueFFS ;
        //v_ChBandDependency.sr_PUCCH_ResourceIndex :=  valueFFS;
        //v_ChBandDependency.SrsBandwidthConfiguration := valueFFS;       //SoundingRS_UL_ConfigCommon.srs_BandwidthConfig
      }
      case (n25){    //5MHz
        v_ChBandDependency.Prach_FrequencyOffset := 2;
        v_ChBandDependency.N_RB_CQI   := 2;                     //type PUCCH_ConfigCommon.nRB_CQI inline type
        v_ChBandDependency.Pusch_HoppingOffset := 4 ;
        v_ChBandDependency.sr_PUCCH_ResourceIndex :=  20;
        v_ChBandDependency.SrsBandwidthConfiguration := bw3;     //SoundingRS_UL_ConfigCommon.srs_BandwidthConfig
      }
      case (n50){     //10MHz
        v_ChBandDependency.Prach_FrequencyOffset := 4;           //integer
        v_ChBandDependency.N_RB_CQI   := 4;                      //PUCCH_ConfigCommon.nRB_CQI inline type
        v_ChBandDependency.Pusch_HoppingOffset := 8 ;
        v_ChBandDependency.sr_PUCCH_ResourceIndex :=  41;
        v_ChBandDependency.SrsBandwidthConfiguration := bw2;     //SoundingRS_UL_ConfigCommon.srs_BandwidthConfig
      }
      case (n75){   //15MHz
        v_ChBandDependency.Prach_FrequencyOffset := 6;           //integer
        v_ChBandDependency.N_RB_CQI   := 6;                      //PUCCH_ConfigCommon.nRB_CQI inline type
        v_ChBandDependency.Pusch_HoppingOffset := 12 ;
        v_ChBandDependency.sr_PUCCH_ResourceIndex :=  62;
        v_ChBandDependency.SrsBandwidthConfiguration := bw2;     //SoundingRS_UL_ConfigCommon.srs_BandwidthConfig
      }
      case (n100){    //20MHz
        v_ChBandDependency.Prach_FrequencyOffset := 8;        //integer
        v_ChBandDependency.N_RB_CQI   := 8;                   //PUCCH_ConfigCommon.nRB_CQI inline type
        v_ChBandDependency.Pusch_HoppingOffset := 16 ;
        v_ChBandDependency.sr_PUCCH_ResourceIndex :=  84;
        v_ChBandDependency.SrsBandwidthConfiguration := bw2;  //SoundingRS_UL_ConfigCommon.srs_BandwidthConfig
      }
      case else {
        FatalError (__FILE__, __LINE__, "invalid value for ChannelBandwidth");
      }
    }
    return v_ChBandDependency;
  };
  
  //----------------------------------------------------------------------------
  // ----------------- Initialise SYSINFO --------------------------------------

  /*
   * @desc      Convert the DL bandwidth value from Dl_Bandwidth_Type to EUTRA_SysinfoDL_Bandwidth_Type
   * @param     p_DL_ChBandwidth
   * @return    EUTRA_SysinfoDL_Bandwidth_Type
   * @status    APPROVED
   */
  function f_ConvertDL_Bandwidth_ToSysinfoType (Dl_Bandwidth_Type p_DL_ChBandwidth ) return EUTRA_SysinfoDL_Bandwidth_Type
  {
    var EUTRA_SysinfoDL_Bandwidth_Type v_SysinfoBandwith;
    
    select (p_DL_ChBandwidth){
      case (n6){ v_SysinfoBandwith := n6  }
      case (n15){ v_SysinfoBandwith := n15  }
      case (n25){ v_SysinfoBandwith := n25  }
      case (n50){ v_SysinfoBandwith := n50  }
      case (n75){ v_SysinfoBandwith := n75  }
      case (n100){ v_SysinfoBandwith := n100  }
      case else {
        FatalError (__FILE__, __LINE__, "invalid value for ChannelBandwidth");
      }
    }
    return v_SysinfoBandwith;
  };
  
  //------------------------------------------------------------------------------------------
  function fl_ConvertUL_Bandwidth_ToSysinfoType ( Ul_Bandwidth_Type   p_UL_ChBandwidth
                                                  ) return EUTRA_SysinfoUL_Bandwidth_Type {
    /* Convert the UL bandwidth value from Ul_Bandwidth_Type to EUTRA_SysinfoUL_Bandwidth_Type */
    var EUTRA_SysinfoUL_Bandwidth_Type v_SysinfoBandwith;

    select (p_UL_ChBandwidth){
      case (n6) {
        v_SysinfoBandwith := n6;
      }
      case (n15) {
        v_SysinfoBandwith := n15;
      }
      case (n25) {
        v_SysinfoBandwith := n25;
      }
      case (n50) {
        v_SysinfoBandwith := n50;
      }
      case (n75) {
        v_SysinfoBandwith := n75;
      }
      case (n100) {
        v_SysinfoBandwith := n100;
      }
      case else {
        FatalError (__FILE__, __LINE__, "invalid value for ChannelBandwidth");
      }
    };
    return v_SysinfoBandwith;
  };
  
  //------------------------------------------------------------------------------------------
  /*
   * @desc      return sysinfo combinition
   * @param     p_CellId
   * @param     p_SysinfoCombination
   * @return    Combination_Type
   * @status    APPROVED
   */
  function fl_CheckSysinfoCombination ( CellId_Type      p_CellId,
                                        Combination_Type p_SysinfoCombination ) return Combination_Type
  {
    var Combination_Type v_SysinfoCombination := p_SysinfoCombination;
    
    // cell14 cannot be assigned to combination c3/c9 as no content is specified for SIB5 in 36.508

    if  ((p_CellId == eutra_Cell14 or p_CellId == eutra_Cell12 or p_CellId == eutra_Cell13 ) and p_SysinfoCombination == c3) {
      v_SysinfoCombination := c1;
    };
    if  ((p_CellId == eutra_Cell14 or p_CellId == eutra_Cell12 or p_CellId == eutra_Cell13 ) and p_SysinfoCombination == c9) {
      v_SysinfoCombination := c4;
    };
    return v_SysinfoCombination;
  };
  
  //------------------------------------------------------------------------------------------
  /*
   * @desc      Initialise Sysinfo combination for NAS test cases
   * @param     p_CellId
   * @param     p_CellsOnPLMN
   * @param     p_CellTC_Type
   * @return    Combination_Type
   * @status    APPROVED
   */
  function fl_NAS_InitSysinfoCombination ( CellId_Type              p_CellId,
                                           EUTRA_NAS_NumOfPLMN_Type p_CellsOnPLMN,
                                           EUTRA_NAS_CellTC_Type    p_CellTC_Type )  return Combination_Type
  {
    var Combination_Type v_SysinfoCombination;
    
    select (p_CellTC_Type){
      case (LTEsinglecell) {
        v_SysinfoCombination := c1;
      }
      case (LTEmulticell) {
        select (p_CellsOnPLMN) {
          case (LTE_AllCellsOnSamePLMN) {
            v_SysinfoCombination := c3;    // SIB5
          }
          case (LTE_CellsOnDifferentPLMN) {
            v_SysinfoCombination := c1;    // Different PLMNs are assigned with different frequencies -> no SIB5
          }
          case else {
            FatalError (__FILE__, __LINE__, "invalid value for NAS number of PLMN type");
          }
        }
      }
      case (LTEmulticell_UsingE)  {
        select (p_CellsOnPLMN) {
          case (LTE_CellsOnDifferentPLMN) {
            select  (p_CellId) {
              case (eutra_CellI, eutra_CellK, eutra_CellL, eutra_CellE) {
                v_SysinfoCombination := c3;           // Broadcast SIB5
              }
            case else {
                v_SysinfoCombination := c1;   // Different PLMNs are assigned with different frequencies -> no SIB5
              }
            }
          }
          case else {
            FatalError (__FILE__, __LINE__, "invalid value for NAS number of PLMN type"); // When cell E is used, multiple PLMNs are used
          }
        }
      }
      case (LTEmulticell_UTRANCell)  {
        select (p_CellsOnPLMN) {
          case (LTE_AllCellsOnSamePLMN) {
            v_SysinfoCombination := c9;    // SIB5 + SIB6
          }
          case (LTE_CellsOnDifferentPLMN) {
            v_SysinfoCombination := c4;  // SIB6
          }
          case else {
            FatalError (__FILE__, __LINE__, "invalid value for NAS number of PLMN type");
          }
        }
      }
      case (LTEmulticell_GERANcell)  {
        select (p_CellsOnPLMN) {
          case (LTE_AllCellsOnSamePLMN) {
            v_SysinfoCombination := c5;    // SIB7
          }
          case (LTE_CellsOnDifferentPLMN) {
            v_SysinfoCombination := c5;  // SIB7
          }
          case else {
            FatalError (__FILE__, __LINE__, "invalid value for NAS number of PLMN type");
          }
        }
      }
      case else {
        FatalError (__FILE__, __LINE__, "invalid value for NAS test case type");
      }
    }
    return (v_SysinfoCombination);
  };
  
  //------------------------------------------------------------------------------------------
  /*
   * @desc      function initialising SIB5 for all cells except cell G,H,I,J,K,L,M and cell14
   *            Acc. To 36.508 Table 6.3.1.2-1 anf for NAS tables 6.3.2.3.2-1 and 6.3.2.3.2-2
   * @param     p_CellId
   * @param     p_AllowedMeasBandwidth
   * @param     p_DL_Bandwidth
   * @param     p_UL_Bandwidth
   * @return    template (value) SystemInformationBlockType5
   * @status    APPROVED
   * @sic R5-096641 R5-104169 sic@
   */
  function f_EUTRA_InitSystemInformation5 ( CellId_Type          p_CellId,
                                            AllowedMeasBandwidth p_AllowedMeasBandwidth,
                                            Dl_Bandwidth_Type    p_DL_Bandwidth,
                                            Ul_Bandwidth_Type    p_UL_Bandwidth ) return template (value) SystemInformationBlockType5
  {
    var template (value) SystemInformationBlockType5 v_SIB5;
    var Frequency_fList_Type v_Frequency_PrimaryBand := f_EUTRA_InitFrequency_f1Tof4 (px_ePrimaryFrequencyBand, p_DL_Bandwidth, p_UL_Bandwidth);
    
    select (p_CellId) {
      case (eutra_Cell1, eutra_Cell2, eutra_Cell4, eutra_Cell11) {
        // For cell frequency of f1:  v_Frequency_PrimaryBand.f1
        // SIB5 contents: f2, f3
        if (v_Frequency_PrimaryBand.f3.dl_CarrierFreq != tsc_DummyFrequency ) {    // f3 is defined for the Band px_ePrimaryFrequencyBand
          v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f2, p_AllowedMeasBandwidth ),
                cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f3,  p_AllowedMeasBandwidth )
                });
        } else {  // f3 not defined for the band
          v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f2, p_AllowedMeasBandwidth ) });
        }
      }
      case (eutra_Cell3, eutra_Cell23) {
        // For cell frequency of f2:         v_Frequency_PrimaryBand.f2
        // SIB5 contents: f1, f3
        if (v_Frequency_PrimaryBand.f3.dl_CarrierFreq != tsc_DummyFrequency ) {    // f3 is defined for the Band px_ePrimaryFrequencyBand
          v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f1, p_AllowedMeasBandwidth ),
                                                              cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f3, p_AllowedMeasBandwidth )
                                                             });
        } else {  // f3 not defined for the band
          v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f1, p_AllowedMeasBandwidth )
                                                           });
        }
      }
      case (eutra_Cell6) {
        // For cell frequency of f3:         v_Frequency_PrimaryBand.f3
        // SIB5 contents: f1, f2
        v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f1, p_AllowedMeasBandwidth ),
                                                            cs_InterFreqCarrierFreq ( v_Frequency_PrimaryBand.f2, p_AllowedMeasBandwidth )
                                                            });
      }
      case (eutra_Cell10) {
        // For cell frequency of f5:         v_Frequency_SecondaryBand.f1 (f5)
        // SIB5 contents: f2, f3
        if (v_Frequency_PrimaryBand.f3.dl_CarrierFreq != tsc_DummyFrequency ) {    // f3 is defined for the Band px_ePrimaryFrequencyBand
          v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f2, p_AllowedMeasBandwidth ),
                                                              cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f3, p_AllowedMeasBandwidth ) });
        } else {  // f3 not defined for the band
          v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f2, p_AllowedMeasBandwidth) });
        }
      }
      case (eutra_CellA, eutra_CellB, eutra_CellD) {
        // For cell frequency of f1:         v_Frequency_PrimaryBand.f1
        // SIB5 contents: f2
        v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f2, p_AllowedMeasBandwidth ) });
      }
      case (eutra_CellC, eutra_CellM) {
        // For cell frequency of f2:         v_Frequency_PrimaryBand.f2
        // SIB5 contents: f1
        v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f1, p_AllowedMeasBandwidth ) });
      }
      case (eutra_CellI, eutra_CellK, eutra_CellL) {    // when cell E is used
        // For cell frequency of f3:         v_Frequency_PrimaryBand.f3
        // SIB5 contents: f2
        v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f2, p_AllowedMeasBandwidth ) });
      }
      case (eutra_CellE) {
        // For cell frequency of f2:         v_Frequency_PrimaryBand.f2
        // SIB5 contents: f3
        v_SIB5 := cs_508_SystemInformationBlockType5_Def ({ cs_InterFreqCarrierFreq (v_Frequency_PrimaryBand.f3, p_AllowedMeasBandwidth ) });
      }
      case else {
        FatalError (__FILE__, __LINE__, "invalid value Cell Id for SIB5 intialisation");
      }
    }
    return v_SIB5;
  }

  
  /*
   * @desc      Return the SIB6 content with the appropriate FDD or TDD UTRA frequency list
   *            function to be used only after coordination with UTRA PTC
   * @param     p_SysInfoRx
   * @return    template (value) SystemInformationBlockType6
   * @status    APPROVED
   */
  function f_EUTRA_IRAT_InitSIB6 (IRAT_CoOrd_SysInfo_Type p_SysInfoRx) return template (value) SystemInformationBlockType6
  {
    var template (value) SystemInformationBlockType6 v_SIB6;
    
    if  (ischosen(p_SysInfoRx.Utran[0].FDD)) {
      v_SIB6 := cs_508_SystemInformationBlockType6_Def (cs_CarrierFreqListUTRA_FDD (cs_CarrierFreqUTRA_FDD ( p_SysInfoRx.Utran[0].FDD.Freq ),
                                                                                    cs_CarrierFreqUTRA_FDD ( p_SysInfoRx.Utran[2].FDD.Freq ),
                                                                                    cs_CarrierFreqUTRA_FDD ( p_SysInfoRx.Utran[3].FDD.Freq ) ),
                                                        omit);
    } else {    // TDD
      v_SIB6 :=  cs_508_SystemInformationBlockType6_Def (omit,
                                                         cs_CarrierFreqListUTRA_TDD (cs_CarrierFreqUTRA_TDD ( p_SysInfoRx.Utran[0].TDD.Freq ),
                                                                                     cs_CarrierFreqUTRA_TDD ( p_SysInfoRx.Utran[2].TDD.Freq ),
                                                                                     cs_CarrierFreqUTRA_TDD ( p_SysInfoRx.Utran[3].TDD.Freq ) ) );
    };
    return v_SIB6;
  };
  
  /*
   * @desc      Convert the GERAN Band Indicator from B1_Type (as used in GERAN side) to LTE asn.1 type BandIndicatorGERAN (as used in LTE)
   * @param     p_BandIndicator
   * @return    BandIndicatorGERAN
   * @status    APPROVED
   */
  function f_ConvertGERAN_Band (B1_Type p_BandIndicator) return BandIndicatorGERAN
  {
    var BandIndicatorGERAN v_BandIndicatorGERAN ;

    if (p_BandIndicator == '0'B) {
      v_BandIndicatorGERAN := dcs1800;
    } else {
      v_BandIndicatorGERAN := pcs1900;
    }
    
    return v_BandIndicatorGERAN;
  };
  
  /*
   * @desc      Convert the GERAN list of ARFCN CoOrd_GERANNeighCell_Type(as used in GERAN side) to LTE asn.1 type ExplicitListOfARFCNs (as used in LTE SIB7)
   * @param     p_NeighCell_Type
   * @return    ExplicitListOfARFCNs
   * @status    APPROVED
   */
  function fl_ConvertGERANNeighCell (CoOrd_GERANNeighCell_Type p_NeighCell_Type) return ExplicitListOfARFCNs
  {
    var ExplicitListOfARFCNs v_ListOfARFCNs ;
    var integer i;
    
    for (i:=0; i <= lengthof(p_NeighCell_Type); i:= i+1) {
      if ( (p_NeighCell_Type[i]>=0) and (p_NeighCell_Type[i] <= 1023)) {    // Check the value is in range of ARFCN-ValueGERAN ::=  INTEGER (0..1023)
        v_ListOfARFCNs[i] := p_NeighCell_Type[i];
      }
    };
    return v_ListOfARFCNs;
  };
  
  /*
   * @desc      Return the SIB7 content with the appropriate GERAN frequency list
   *            function to be used only after coordination with GERAN PTC
   * @param     p_SysInfoRx
   * @return    template (value) SystemInformationBlockType7
   * @status    APPROVED
   */
  function f_EUTRA_IRAT_InitSIB7 (IRAT_CoOrd_SysInfo_Type p_SysInfoRx) return template (value) SystemInformationBlockType7
  {
    var template (value) SystemInformationBlockType7 v_SIB7;
    
    v_SIB7 := cs_508_SystemInformationBlockType7_Def ( { cs_CarrierFreqsInfoGERAN (cs_CarrierFreqsGERAN (p_SysInfoRx.Geran[0].Arfcn,
                                                                                                         f_ConvertGERAN_Band(p_SysInfoRx.Geran[0].BandIndicator),
                                                                                                         fl_ConvertGERANNeighCell(p_SysInfoRx.Geran[0].NeighCells) )),
                                                         cs_CarrierFreqsInfoGERAN (cs_CarrierFreqsGERAN (p_SysInfoRx.Geran[1].Arfcn,
                                                                                                         f_ConvertGERAN_Band(p_SysInfoRx.Geran[1].BandIndicator),
                                                                                                         fl_ConvertGERANNeighCell(p_SysInfoRx.Geran[1].NeighCells) )),
                                                         cs_CarrierFreqsInfoGERAN (cs_CarrierFreqsGERAN (p_SysInfoRx.Geran[2].Arfcn,
                                                                                                         f_ConvertGERAN_Band(p_SysInfoRx.Geran[2].BandIndicator),
                                                                                                         fl_ConvertGERANNeighCell(p_SysInfoRx.Geran[2].NeighCells) )) });
    return v_SIB7;
  };

  
  /*
   * @desc      Return the SIB8 content with the appropriate CDMA2000 parameters
   *            function to be used only after coordination with CDMA2000 PTC
   * @param     p_SysInfoRx
   * @return    template (value) SystemInformationBlockType8
   * @status    APPROVED
   */
  function f_EUTRA_IRAT_InitSIB8 (IRAT_CoOrd_SysInfo_Type p_SysInfoRx) return template (value) SystemInformationBlockType8
  {
    // It is assumed that the coordination message received from C2K PTC will include 4 entries: all 4 for HRPD or all 4 for 1xRTT
    var template (value) SystemInformationBlockType8 v_SIB8;
    var template (value) BandClassListCDMA2000 v_BandClassListCDMA2000 := fl_GetBandClassListCDMA2000 ( p_SysInfoRx );
    var template (value) NeighCellListCDMA2000 v_NeighCellListCDMA2000 := fl_GetNeighCellsList( p_SysInfoRx );
    var template (omit) ParametersHRPD_Type  v_ParametersHRPD  := omit;
    var template (omit) Parameters1XRTT_Type v_Parameters1XRTT := omit;

    if (p_SysInfoRx.Cdma2000[0].IsHRPD == true) { // CDMA2000 HRPD cell environment
      // all 4 cells included in SIB8 are HRPD cells
      v_ParametersHRPD  := cs_ParametersHRPD (v_BandClassListCDMA2000, v_NeighCellListCDMA2000);

    } else {                                      // CDMA2000 1XRTT cell environment
      // all 4 cells are 1xRTT cells
      v_Parameters1XRTT := cs_Parameters1xRTT (v_BandClassListCDMA2000, v_NeighCellListCDMA2000);
    }

    v_SIB8 := cs_508_SystemInformationBlockType8_Def (v_ParametersHRPD, v_Parameters1XRTT);
    return v_SIB8;
  };
  
  /*
   * @desc      Return the Neighbourg cell list to include in SIB8 with the appropriate CDMA2000 (HRPD or 1xRTT) parameters.
   *            the content of the neigbourg cell list is according to 36.508 table 6.3.1.5-1 and table 6.3.1.6-1
   *            It is assumed that the coordination message received from C2K PTC will include 4 entries: all 4 for HRPD or all 4 for 1xRTT
   * @param     p_SysInfoRx
   * @return    template (value) NeighCellListCDMA2000
   * @status    APPROVED
   */
  function fl_GetNeighCellsList (IRAT_CoOrd_SysInfo_Type p_SysInfoRx) return template (value) NeighCellListCDMA2000
  {
    var template (value) NeighCellListCDMA2000 v_NeighCellListCDMA2000;
    
    v_NeighCellListCDMA2000 :=
               { cs_NeighCellCDMA2000 (fl_ConvertBandClassInteger_ToCDMA2000(p_SysInfoRx.Cdma2000[0].BandClass),
                           {cs_NeighCellsPerBandclassC2K (p_SysInfoRx.Cdma2000[0].Arfcn, {p_SysInfoRx.Cdma2000[0].PNOffset, p_SysInfoRx.Cdma2000[1].PNOffset}),
                            cs_NeighCellsPerBandclassC2K (p_SysInfoRx.Cdma2000[2].Arfcn, {p_SysInfoRx.Cdma2000[2].PNOffset}),
                            cs_NeighCellsPerBandclassC2K (p_SysInfoRx.Cdma2000[3].Arfcn, {p_SysInfoRx.Cdma2000[3].PNOffset})
                            }
                )};
    
    return v_NeighCellListCDMA2000;
  };
  
  /*
   * @desc      Return the band class list to include in SIB8.
   *            the content of the neigbourg cell list is according to 36.508 table 6.3.1.5-1 and table 6.3.1.6-1
   * @param     p_SysInfoRx
   * @return    template (value) BandClassListCDMA2000
   * @status    APPROVED
   */
  function fl_GetBandClassListCDMA2000 (IRAT_CoOrd_SysInfo_Type p_SysInfoRx) return template (value) BandClassListCDMA2000
  {
    var template (value) BandClassListCDMA2000 v_BandClassListCDMA2000;

    // We shall include only one instance per value e.g. {bc0, bc1} AND NOT {bc0, bc1, bc0}
    // acc to 36.508 there is only 1 bandclass
    v_BandClassListCDMA2000 :=  {cs_BandClassInfoCDMA2000 (fl_ConvertBandClassInteger_ToCDMA2000(p_SysInfoRx.Cdma2000[0].BandClass))};

    return v_BandClassListCDMA2000;
  };

  /*
   * @desc      To convert the BandClass from Integer to teh ans.1 type BandclassCDMA2000
   *            the content of the neigbourg cell list is according to 36.508 table 6.3.1.5-1 and table 6.3.1.6-1
   * @param     p_BandClassInteger
   * @return    BandclassCDMA2000
   * @status    APPROVED
   */
  function fl_ConvertBandClassInteger_ToCDMA2000 ( integer p_BandClassInteger ) return BandclassCDMA2000
  {
    var BandclassCDMA2000 v_BandclassCDMA2000 := bc0;
    
    select (p_BandClassInteger) {
      case (0) {v_BandclassCDMA2000 := bc0}
      case (1) {v_BandclassCDMA2000 := bc1}
      case (2) {v_BandclassCDMA2000 := bc2}
      case (3) {v_BandclassCDMA2000 := bc3}
      case (4) {v_BandclassCDMA2000 := bc4}
      case (5) {v_BandclassCDMA2000 := bc5}
      case (6) {v_BandclassCDMA2000 := bc6}
      case (7) {v_BandclassCDMA2000 := bc7}
      case (8) {v_BandclassCDMA2000 := bc8}
      case (9) {v_BandclassCDMA2000 := bc9}
      case (10) {v_BandclassCDMA2000 := bc10}
      case (11) {v_BandclassCDMA2000 := bc11}
      case (12) {v_BandclassCDMA2000 := bc12}
      case (13) {v_BandclassCDMA2000 := bc13}
      case (14) {v_BandclassCDMA2000 := bc14}
      case (15) {v_BandclassCDMA2000 := bc15}
      case (16) {v_BandclassCDMA2000 := bc16}
      case (17) {v_BandclassCDMA2000 := bc17}
      case else {  FatalError (__FILE__, __LINE__, "invalid BandClass value");}
    }
    return v_BandclassCDMA2000;
  };
  
  //------------------------------------------------------------------------------------------
  /*
   * @desc      function initialising the default sysinfo as per 36.508
   * @param     p_CellId
   * @param     p_CellIdentity
   * @param     p_Combination
   * @param     p_FrequencyBand
   * @param     p_DL_ChBandwidth
   * @param     p_UL_ChBandwidth
   * @param     p_PLMN_Identity
   * @param     p_TrackingAreaCode
   * @param     p_FDD_TDD
   * @param     p_RootSequenceIndex
   * @return    template (value) BcchInfo_Type
   * @status    APPROVED
   * @sic R5-096641: parameterise RootSequenceIndex  sic@
   */
  function f_EUTRA_InitSystemInformation ( CellId_Type                        p_CellId,
                                           CellIdentity                       p_CellIdentity,
                                           Combination_Type                   p_Combination,
                                           FrequencyBand_Type                 p_FrequencyBand,
                                           Dl_Bandwidth_Type                  p_DL_ChBandwidth,
                                           Ul_Bandwidth_Type                  p_UL_ChBandwidth,
                                           template (value) PLMN_IdentityList p_PLMN_Identity,
                                           TrackingAreaCode                   p_TrackingAreaCode,
                                           EUTRA_FDD_TDD_CellInfo_Type        p_FDD_TDD,
                                           RootSequenceIndex_Type             p_RootSequenceIndex )
    return template (value) BcchInfo_Type
  {
    /* function initialising the default sysinfo as per 36.508  */
    var ChannelBandwidthDependency_Type v_ChannelBandwidthDependency := f_EUTRA_BandDependentParam ( p_DL_ChBandwidth, p_UL_ChBandwidth );
    var EUTRA_SysinfoDL_Bandwidth_Type v_SysinfoDL_Bandwidth := f_ConvertDL_Bandwidth_ToSysinfoType (p_DL_ChBandwidth);
    var template(omit) TDD_Config v_TDD_Config := omit;  // omitted in FDD
    
    var template (value) BcchInfo_Type v_CellBcchInfo;
    var template (value) BCCH_BCH_Message v_MIB;
    var template (value) BCCH_DL_SCH_Message v_SIB1;
    var template (value) SystemInformation_r8_IEs v_SIB2;
    var template (value) SystemInformation_r8_IEs v_SIB3;
    var template (value) SystemInformation_r8_IEs v_SIB5;
    var template (value) SystemInformation_r8_IEs v_SIB6;
    var template (value) SystemInformation_r8_IEs v_SIB7;
    var template (value) SystemInformation_r8_IEs v_SIB8;
    var template (value) SystemInformation_r8_IEs v_TwoSIBs;
    var template (value) SystemInformationBlockType5 v_SystemInformation5;
    
    // --- Initialise MIB ---
    v_MIB :=  cs_508_MasterInformationBlock_Init ( v_SysinfoDL_Bandwidth );
    
    // --- Initialise variables for SIB1 ---
    if (p_FDD_TDD.FDD_TDD == TDD) {  // initialise tdd-Configuration  to be used in SIB1
      v_TDD_Config := cs_TDD_ConfigDef(p_FDD_TDD.TDD_SubframeAssignment);    // Value omitted in FDD
    }
    
    // --- Initialise SIB2 ---
    if (p_FDD_TDD.FDD_TDD == FDD) {            //FDD
      // Initialise UL Bandwidth value
      v_SIB2 := cs_SI_SIB2 (cs_508_SystemInformationBlockType2_Def (omit,     // UL Bandwidth is omitted
                                                                    v_ChannelBandwidthDependency.N_RB_CQI,
                                                                    v_ChannelBandwidthDependency.Pusch_HoppingOffset,
                                                                    cs_508_SoundingRS_UL_ConfigCommon_FDD(v_ChannelBandwidthDependency.SrsBandwidthConfiguration),
                                                                    cs_508_PRACH_ConfigSIB_FDD ( v_ChannelBandwidthDependency.Prach_FrequencyOffset,
                                                                                                 p_RootSequenceIndex ),  // @sic R5s090180: Replace _TDD by _FDD sic@
                                                                    tsc_P_b_1Tx
                                                                    ) ) ;
    }  else {     // TDD
      // In SIB2 ul-Bandwidth is not present for TDD
      v_SIB2 := cs_SI_SIB2 ( cs_508_SystemInformationBlockType2_Def (omit,
                                                                     v_ChannelBandwidthDependency.N_RB_CQI,
                                                                     v_ChannelBandwidthDependency.Pusch_HoppingOffset,
                                                                     cs_508_SoundingRS_UL_ConfigCommon_TDD(v_ChannelBandwidthDependency.SrsBandwidthConfiguration),
                                                                     cs_508_PRACH_ConfigSIB_TDD (   v_ChannelBandwidthDependency.Prach_FrequencyOffset,
                                                                                                    p_RootSequenceIndex ),
                                                                     tsc_P_b_1Tx
                                                                     ) ) ;
    };
    
    // --- Initialise SIB3 ---
    v_SIB3 := cs_SI_SIB3 (cs_508_SystemInformationBlockType3_Def);
    
    // --- Initialise all SYSINFO --
    select (p_Combination) {
      case (c1) {
        v_SIB1 := cs_508_SystemInformationBlockType1_Def( p_PLMN_Identity,
                                                          p_TrackingAreaCode,
                                                          p_CellIdentity,
                                                          p_FrequencyBand,
                                                          cs_SchedulingInfo_2SI( v_ChannelBandwidthDependency.SIB3_periodicity),
                                                          v_TDD_Config );
        v_CellBcchInfo := cs_BCCHInfo_C1( v_MIB,
                                          v_SIB1,
                                          { cs_SystemInformation_Common(v_SIB2),
                                            cs_SystemInformation_Common(v_SIB3) }
                                          );
      }
      case (c2) { // SIB4 Intra-Frequency
        v_SIB1 := cs_508_SystemInformationBlockType1_Def( p_PLMN_Identity,
                                                          p_TrackingAreaCode,
                                                          p_CellIdentity,
                                                          p_FrequencyBand,
                                                          cs_SchedulingInfo_3SI( v_ChannelBandwidthDependency.SIB3_periodicity,
                                                                                 {sibType3},
                                                                                 v_ChannelBandwidthDependency.SIB4_periodicity,
                                                                                 {sibType4} ),
                                                          v_TDD_Config );
        v_CellBcchInfo := cs_BCCHInfo_C1( v_MIB,
                                          v_SIB1,
                                          { cs_SystemInformation_Common( v_SIB2 ),
                                            cs_SystemInformation_Common( v_SIB3 ),
                                            cs_SystemInformation_Common( cs_SI_SIB4( cs_508_SystemInformationBlockType4_def )) }
                                          );
      }
      case (c3) { // SIB5 Inter-Frequency
        v_SystemInformation5 := f_EUTRA_InitSystemInformation5 (p_CellId , v_ChannelBandwidthDependency.AllowedMeasBandwidth, p_DL_ChBandwidth, p_UL_ChBandwidth);
        v_SIB5 := cs_SI_SIB5 ( v_SystemInformation5 );
        v_SIB1 := cs_508_SystemInformationBlockType1_Def( p_PLMN_Identity,
                                                          p_TrackingAreaCode,
                                                          p_CellIdentity,
                                                          p_FrequencyBand,
                                                          cs_SchedulingInfo_3SI (v_ChannelBandwidthDependency.SIB3_periodicity,
                                                                                 {sibType3},
                                                                                 v_ChannelBandwidthDependency.SIB5_periodicity,
                                                                                 {sibType5} ),
                                                          v_TDD_Config );
        v_CellBcchInfo := cs_BCCHInfo_C1( v_MIB,
                                          v_SIB1,
                                          { cs_SystemInformation_Common( v_SIB2 ),
                                            cs_SystemInformation_Common( v_SIB3 ),
                                            cs_SystemInformation_Common( v_SIB5 ) }
                                          );
      }
      case (c4) { // SIB6 UTRAN
        v_SIB6 := cs_SI_SIB6( cs_508_SystemInformationBlockType6_Def(omit, omit));  // Initialise first UTRA FDD and TDD frequency list with OMIT
        v_SIB1 := cs_508_SystemInformationBlockType1_Def( p_PLMN_Identity,
                                                          p_TrackingAreaCode,
                                                          p_CellIdentity,
                                                          p_FrequencyBand,
                                                          cs_SchedulingInfo_3SI( v_ChannelBandwidthDependency.SIB3_periodicity,
                                                                                 {sibType3},
                                                                                 v_ChannelBandwidthDependency.SIB6_periodicity,
                                                                                 {sibType6} ),
                                                          v_TDD_Config );
        v_CellBcchInfo := cs_BCCHInfo_C1( v_MIB,
                                          v_SIB1,
                                          { cs_SystemInformation_Common( v_SIB2 ),
                                            cs_SystemInformation_Common( v_SIB3 ),
                                            cs_SystemInformation_Common( v_SIB6 ) }
                                          );
      }
      case (c5) {   // SIB7 GERAN
        v_SIB7 := cs_SI_SIB7( cs_508_SystemInformationBlockType7_Def(omit));  // List of GERAN frequencies assigned later after synchronisation with GERAN PTC
        v_SIB1 := cs_508_SystemInformationBlockType1_Def( p_PLMN_Identity,
                                                          p_TrackingAreaCode,
                                                          p_CellIdentity,
                                                          p_FrequencyBand,
                                                          cs_SchedulingInfo_3SI( v_ChannelBandwidthDependency.SIB3_periodicity,
                                                                                 {sibType3},
                                                                                 v_ChannelBandwidthDependency.SIB7_periodicity,
                                                                                 {sibType7} ),
                                                          v_TDD_Config );
        v_CellBcchInfo := cs_BCCHInfo_C1( v_MIB,
                                          v_SIB1,
                                          { cs_SystemInformation_Common( v_SIB2 ),
                                            cs_SystemInformation_Common( v_SIB3 ),
                                            cs_SystemInformation_Common( v_SIB7 ) }
                                          );
      }
      case (c6) { // SIB8 for CDMA2000 @sic R5-103870 sic@
        v_SIB8 := cs_SI_SIB8( cs_508_SystemInformationBlockType8_Def(omit, omit));  // 1XRTT or HRPD parameters assigned later after synchronisation with GERAN PTC
        v_SIB1 := cs_508_SystemInformationBlockType1_Def( p_PLMN_Identity,
                                                          p_TrackingAreaCode,
                                                          p_CellIdentity,
                                                          p_FrequencyBand,
                                                          cs_SchedulingInfo_3SI( v_ChannelBandwidthDependency.SIB3_periodicity,
                                                                                 {sibType3},
                                                                                 v_ChannelBandwidthDependency.SIB8_periodicity,
                                                                                 {sibType8} ),
                                                          v_TDD_Config );
        v_CellBcchInfo := cs_BCCHInfo_C1( v_MIB,
                                          v_SIB1,
                                          { cs_SystemInformation_Common( v_SIB2 ),
                                            cs_SystemInformation_Common( v_SIB3 ),
                                            cs_SystemInformation_Common( v_SIB8 ) }
                                          );

      }
      case (c7) { //TO DO   for eNodeB
      }
      case (c8) { //TO DO   for ETWS
      }
      case (c9) {  // SIB5 Inter-Frequency + SIB6 UTRAN
        v_SystemInformation5 := f_EUTRA_InitSystemInformation5 (p_CellId , v_ChannelBandwidthDependency.AllowedMeasBandwidth,p_DL_ChBandwidth, p_UL_ChBandwidth);
        v_TwoSIBs := cs_SI_SIB5_SIB6( v_SystemInformation5,
                                      cs_508_SystemInformationBlockType6_Def (omit, omit)); // Initialise first UTRA FDD and TDD frequency list with OMIT
        v_SIB1 := cs_508_SystemInformationBlockType1_Def( p_PLMN_Identity,
                                                          p_TrackingAreaCode,
                                                          p_CellIdentity,
                                                          p_FrequencyBand,
                                                          cs_SchedulingInfo_3SI( v_ChannelBandwidthDependency.SIB3_periodicity,
                                                                                 {sibType3},
                                                                                 v_ChannelBandwidthDependency.SIB5_periodicity,   // SIB5 and SIB6 have the same periodicity
                                                                                 {sibType5, sibType6} ),  // SIB5 and SIB6 in the same SI
                                                          v_TDD_Config );
        v_CellBcchInfo := cs_BCCHInfo_C1( v_MIB,
                                          v_SIB1,
                                          { cs_SystemInformation_Common( v_SIB2 ),
                                            cs_SystemInformation_Common( v_SIB3 ),
                                            cs_SystemInformation_Common( v_TwoSIBs ) }
                                          );
      }
      case (c10) { // SIB6 UTRAN + SIB7 GERAN
        v_SIB6 := cs_SI_SIB6( cs_508_SystemInformationBlockType6_Def(omit, omit));  // Initialise first UTRA FDD and TDD frequency list with OMIT
        v_SIB7 := cs_SI_SIB7( cs_508_SystemInformationBlockType7_Def(omit));  // List of GERAN frequencies assigned later after synchronisation with GERAN PTC
        v_SIB1 := cs_508_SystemInformationBlockType1_Def( p_PLMN_Identity,
                                                          p_TrackingAreaCode,
                                                          p_CellIdentity,
                                                          p_FrequencyBand,
                                                          cs_SchedulingInfo_4SI( v_ChannelBandwidthDependency.SIB3_periodicity,
                                                                                 {sibType3},
                                                                                 v_ChannelBandwidthDependency.SIB6_periodicity,
                                                                                 {sibType6},
                                                                                 v_ChannelBandwidthDependency.SIB7_periodicity,
                                                                                 {sibType7} ),
                                                          v_TDD_Config );
        v_CellBcchInfo := cs_BCCHInfo_C1( v_MIB,
                                          v_SIB1,
                                          { cs_SystemInformation_Common( v_SIB2 ),
                                            cs_SystemInformation_Common( v_SIB3 ),
                                            cs_SystemInformation_Common( v_SIB6  ),
                                            cs_SystemInformation_Common( v_SIB7  )
                                            }
                                          );
      }
      case (c11) { // SIB4 + SIB6 UTRAN @sic R5-10???? sic@
        v_SIB6 := cs_SI_SIB6( cs_508_SystemInformationBlockType6_Def(omit, omit));  // Initialise first UTRA FDD and TDD frequency list with OMIT
        v_SIB1 := cs_508_SystemInformationBlockType1_Def( p_PLMN_Identity,
                                                          p_TrackingAreaCode,
                                                          p_CellIdentity,
                                                          p_FrequencyBand,
                                                          cs_SchedulingInfo_4SI( v_ChannelBandwidthDependency.SIB3_periodicity,
                                                                                 {sibType3},
                                                                                 v_ChannelBandwidthDependency.SIB4_periodicity,
                                                                                 {sibType4},
                                                                                 v_ChannelBandwidthDependency.SIB6_periodicity,
                                                                                 {sibType6}                                                                                 ),
                                                          v_TDD_Config );
        v_CellBcchInfo := cs_BCCHInfo_C1( v_MIB,
                                          v_SIB1,
                                          { cs_SystemInformation_Common( v_SIB2 ),
                                            cs_SystemInformation_Common( v_SIB3 ),
                                            cs_SystemInformation_Common( cs_SI_SIB4( cs_508_SystemInformationBlockType4_def )),
                                            cs_SystemInformation_Common( v_SIB6 ) }
                                          );
      }
      case else {
        FatalError (__FILE__, __LINE__, "invalid sysinfo combination");
      }
    }
    return v_CellBcchInfo;
  };
  
  //------------------------------------------------------------------------------------------
  // ---------------------  Initialise EUTRA NAS parameters cells info  ----- ----------------
  
  //------------------- Init NAS parameters for RRC test cases -----------------------------
  /*
   * @desc      Initialise NAS parameters for RRC cells as per 36.508 Table 4.4.2-2
   * @param     p_CellId
   * @param     p_FrequencyBand
   * @return    NAS_Parameter_Type
   * @status    APPROVED
   * @sic R5-096440 R5s10163 R5-102229 sic@
   */
  function fl_EUTRA_InitNAS_forRRC_Cells ( CellId_Type         p_CellId,
                                           FrequencyBand_Type  p_FrequencyBand ) return NAS_Parameter_Type
  {
    var template (value) NAS_Parameter_Type v_NAS_Param;

     select (p_CellId){
      case (eutra_Cell1, eutra_Cell2, eutra_Cell3, eutra_Cell4, eutra_Cell6, eutra_Cell10) {
        v_NAS_Param.TrackingAreaCode := int2bit (1, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_Def, 32769, 1);
      }
      case (eutra_Cell11, eutra_Cell23) {
        v_NAS_Param.TrackingAreaCode := int2bit (2, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_Def, 32769, 1); // @sic R5s100466 sic@
      }
      case (eutra_Cell12){
        v_NAS_Param.TrackingAreaCode := int2bit (1, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_002_11, 32769, 1);
      }
      case (eutra_Cell13){
        v_NAS_Param.TrackingAreaCode := int2bit (1, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_003_21, 32769, 1);
      }
      case (eutra_Cell14){
        v_NAS_Param.TrackingAreaCode := int2bit (1, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_004_31 ,32769, 1);
      }
      case else {
        FatalError (__FILE__, __LINE__, "invalid cell Identity");
      }
    }
    if (p_FrequencyBand == 6) {
      v_NAS_Param.Guti_Parameters.PLMN_Identity.mcc := f_ConvertMCC_Nas2Asn(px_eJapanMCC_Band6);
    };
    
    // Initialise Location Area Id
    v_NAS_Param.LocationAreaCode := tsc_LAC_Def;
    
    return valueof(v_NAS_Param);  // Note: valueof cannot be avoided here
  };
  
  //------------------- Init NAS parameters for NAS test cases -----------------------------
  /*
   * @desc      Initialise NAS parameters for NAS cells as per 36.508 Table
   * @param     p_CellId
   * @param     p_FrequencyBand
   * @return    NAS_Parameter_Type
   * @status    APPROVED
   * @sic R5-096440 R5s10163 R5-102229 sic@
   */
  function fl_EUTRA_InitNAS_forNAS_Cells ( CellId_Type         p_CellId,
                                           FrequencyBand_Type  p_FrequencyBand ) return NAS_Parameter_Type
  {
    var template (value) NAS_Parameter_Type v_NAS_Param;
    
    select (p_CellId){
      case (eutra_CellA) {
        v_NAS_Param.TrackingAreaCode := int2bit (1, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_Def, 32769, 1);
      }
      case (eutra_CellB) {
        v_NAS_Param.TrackingAreaCode := int2bit (2, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_Def, 32770, 1);
      }
      case (eutra_CellC) {
        v_NAS_Param.TrackingAreaCode := int2bit (3, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_Def, 32771, 1);
      }
      case (eutra_CellD) {
        v_NAS_Param.TrackingAreaCode := int2bit (4, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_Def, 32772, 1);
      }
      case (eutra_CellE) {
        v_NAS_Param.TrackingAreaCode := int2bit (3, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_002_101, 32777, 1);
      }
      case (eutra_CellG) {
        v_NAS_Param.TrackingAreaCode := int2bit (1, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_001_02, 32775, 1);
      }
      case (eutra_CellH) {
        v_NAS_Param.TrackingAreaCode := int2bit (2, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_001_02, 32776, 1);
      }
      case (eutra_CellI) {
        v_NAS_Param.TrackingAreaCode := int2bit (1, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_002_101, 32777, 1);
      }
      case (eutra_CellJ) {
        v_NAS_Param.TrackingAreaCode := int2bit (1, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_003_101, 32778, 1);
      }
      case (eutra_CellK) {
        v_NAS_Param.TrackingAreaCode := int2bit (1, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_002_101, 32777, 1);
      }
      case (eutra_CellL) {
        v_NAS_Param.TrackingAreaCode := int2bit (2, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_002_101, 32779, 1);
      }
      case (eutra_CellM) {
        v_NAS_Param.TrackingAreaCode := int2bit (1, 16);
        v_NAS_Param.Guti_Parameters := cs_Guti(cs_HPLMN_Def, 32769, 1);
      }
      
      case else {
        FatalError (__FILE__, __LINE__, "invalid cell Idendtity");
      }
    }
    
    if (p_FrequencyBand == 6) {
      v_NAS_Param.Guti_Parameters.PLMN_Identity.mcc := f_ConvertMCC_Nas2Asn(px_eJapanMCC_Band6);
    };
    
    // Initialise Location Area Id
    v_NAS_Param.LocationAreaCode := tsc_LAC_Def;
    
    return valueof(v_NAS_Param);  // Note: valueof cannot be avoided here
  };
  
  /*******************************************************************************************/
  //------------------------------------------------------------------------------------------
  // ---------------------  Initialise EUTRA cells info  -------------------------------------
  /*
   * @desc      Initialise cell info for one cell
   * @param     p_CellId
   * @param     p_FrequencyBand
   * @param     p_SysinfoCombination
   * @param     p_DL_Bandwidth
   * @param     p_UL_Bandwidth
   * @return    EUTRA_CellInfo_Type
   * @status    APPROVED
   * @sic R5-096641 sic@
   */
  function f_EUTRA_CellInfo_Init( CellId_Type        p_CellId,
                                  FrequencyBand_Type p_FrequencyBand,
                                  Combination_Type   p_SysinfoCombination,
                                  Dl_Bandwidth_Type  p_DL_Bandwidth,
                                  Ul_Bandwidth_Type  p_UL_Bandwidth ) return EUTRA_CellInfo_Type
  {
    var CellIdentities_Type v_CellIds  := fl_EUTRA_InitCellIdentities ( p_CellId );
    var EUTRA_FDD_TDD_CellInfo_Type v_FDD_TDD_Info := fl_InitFDD_TDD_FromBand (p_FrequencyBand);
    var EUTRA_FDD_TDD_Mode_Type v_FDD_TDD := v_FDD_TDD_Info.FDD_TDD;
    var CellTimingInfo_Type  v_Celltiming := fl_EUTRA_InitialiseCellTiming (p_CellId, v_FDD_TDD, LTE_AllCellsOnSamePLMN);   //the parameter "LTE_AllCellsOnSamePLMN" is dummy for RRC cells, it is used only for NAS test cases
    var Combination_Type v_SysinfoCombination := fl_CheckSysinfoCombination (p_CellId, p_SysinfoCombination);
    var RootSequenceIndex_Type v_RootSequenceIndex_Type := f_InitialisePRACH_RootSequenceIndex (p_CellId, v_FDD_TDD, LTE_AllCellsOnSamePLMN);
    var RACH_TimingAdvance_Type  v_RAR_TA := fl_InitialiseRAR_TA (p_CellId, v_FDD_TDD, LTE_AllCellsOnSamePLMN);
    
    var CarrierFreqEUTRA v_UL_DL_Earfcn;
    var NAS_Parameter_Type v_NAS_Param;
    var template (value) BcchInfo_Type  v_BCCH_Info;
    var template (value) EUTRA_CellInfo_Type v_CellInfo;
    var Frequency_fList_Type v_Freq;
    var ChannelBandwidthDependency_Type v_ChannelBandwidthDependency := f_EUTRA_BandDependentParam ( p_DL_Bandwidth, p_UL_Bandwidth );  //@sic R5s090180: return CFI value sic@
    
    
    // Initialise Frequencies f1/f2/f3/f4
    v_Freq:= f_EUTRA_InitFrequency_f1Tof4 ( p_FrequencyBand, p_DL_Bandwidth, p_UL_Bandwidth );
    
    // Initialised Frequency per cell. See 36.508 Table 6.2.3.1-1
    // Cell 1/2/4/11 -> Frequency f1
    // Cell 3/12 -> Frequency f2
    // Cell 6/13 -> Frequency f3
    // Cell 14 -> Frequency f4
    select (p_CellId) {
      case ( eutra_Cell1,
             eutra_Cell2,
             eutra_Cell4,
             eutra_Cell11,
             eutra_Cell10 ) {
        v_UL_DL_Earfcn := v_Freq.f1;   //f1
      }
      case (eutra_Cell3,
            eutra_Cell12,
            eutra_Cell23) {
        v_UL_DL_Earfcn := v_Freq.f2;  // f2
      }
      case (eutra_Cell6,
            eutra_Cell13) {
        v_UL_DL_Earfcn := v_Freq.f3;   // f3
      }
      case (eutra_Cell14) {
        v_UL_DL_Earfcn := v_Freq.f4;   // f4
      }
      case else {
        FatalError (__FILE__, __LINE__, "invalid cell Idendtity");
      }
    }
    
    // Initialise NAS parameters
    v_NAS_Param := fl_EUTRA_InitNAS_forRRC_Cells( p_CellId, p_FrequencyBand );
    
    // Initialise SYSINFO
    v_BCCH_Info := f_EUTRA_InitSystemInformation (p_CellId,
                                                  v_CellIds.CellIdentity,
                                                  v_SysinfoCombination,
                                                  p_FrequencyBand,
                                                  p_DL_Bandwidth,
                                                  p_UL_Bandwidth,
                                                  cs_PlmnIdList_1Entry(v_NAS_Param.Guti_Parameters.PLMN_Identity),
                                                  v_NAS_Param.TrackingAreaCode,
                                                  v_FDD_TDD_Info,
                                                  v_RootSequenceIndex_Type );
    
    v_CellInfo := cs_EUTRA_CellInfoDef ( v_CellIds,
                                         v_SysinfoCombination,
                                         p_FrequencyBand,
                                         v_UL_DL_Earfcn,
                                         p_DL_Bandwidth,
                                         p_UL_Bandwidth,
                                         v_NAS_Param,
                                         v_BCCH_Info,
                                         v_Celltiming,
                                         v_FDD_TDD_Info,
                                         v_ChannelBandwidthDependency.Cfi,
                                         v_RAR_TA,
                                         v_ChannelBandwidthDependency.sr_PUCCH_ResourceIndex   // @sic R5s090312 sic@
                                         ); // @sic R5s090180 sic@
    return valueof(v_CellInfo);   // Note: valueof cannot be avoided here
  };
  
  //----------------------------------------------------------------------------------------------------------
  /*
   * @desc      Initialise all EUTRA cell info
   * @param     p_SysinfoCombination
   * @return    EUTRA_CellInfoList_Type
   * @status    APPROVED
   */
  function f_EUTRA_CellArray_Init (  Combination_Type   p_SysinfoCombination  ) return EUTRA_CellInfoList_Type
  {
    /* @sic R5-102223 : replace px_eDL_ChannelBandwidth to px_ePrimaryBandChannelBandwidth and px_eSecondaryBandChannelBandwidth
     @sic R5-102223 : delete px_eUL_ChannelBandwidth */
    var EUTRA_CellInfoList_Type v_EUTRA_Cells;
    var integer v_Index;
    var Ul_Bandwidth_Type v_PrimaryBandChBandwidth_UL := f_ConvertDL_BandwidthToUL (px_ePrimaryBandChannelBandwidth);
    var Ul_Bandwidth_Type v_SecondaryBandChBandwidth_UL := f_ConvertDL_BandwidthToUL (px_eSecondaryBandChannelBandwidth);

    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_Cell1);
    v_EUTRA_Cells[v_Index] := f_EUTRA_CellInfo_Init (eutra_Cell1,
                                                     px_ePrimaryFrequencyBand,
                                                     p_SysinfoCombination,
                                                     px_ePrimaryBandChannelBandwidth,
                                                     v_PrimaryBandChBandwidth_UL);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_Cell2);
    v_EUTRA_Cells[v_Index] := f_EUTRA_CellInfo_Init (eutra_Cell2,
                                                     px_ePrimaryFrequencyBand,
                                                     p_SysinfoCombination,
                                                     px_ePrimaryBandChannelBandwidth,
                                                     v_PrimaryBandChBandwidth_UL);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_Cell3);
    v_EUTRA_Cells[v_Index] := f_EUTRA_CellInfo_Init (eutra_Cell3,
                                                     px_ePrimaryFrequencyBand,
                                                     p_SysinfoCombination,
                                                     px_ePrimaryBandChannelBandwidth,
                                                     v_PrimaryBandChBandwidth_UL);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_Cell4);
    v_EUTRA_Cells[v_Index] := f_EUTRA_CellInfo_Init (eutra_Cell4,
                                                     px_ePrimaryFrequencyBand,
                                                     p_SysinfoCombination,
                                                     px_ePrimaryBandChannelBandwidth,
                                                     v_PrimaryBandChBandwidth_UL);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_Cell6);
    v_EUTRA_Cells[v_Index] := f_EUTRA_CellInfo_Init (eutra_Cell6,
                                                     px_ePrimaryFrequencyBand,
                                                     p_SysinfoCombination,
                                                     px_ePrimaryBandChannelBandwidth,
                                                     v_PrimaryBandChBandwidth_UL);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_Cell10);
    v_EUTRA_Cells[v_Index] := f_EUTRA_CellInfo_Init (eutra_Cell10,
                                                     px_eSecondaryFrequencyBand,
                                                     p_SysinfoCombination,
                                                     px_eSecondaryBandChannelBandwidth,
                                                     v_SecondaryBandChBandwidth_UL);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_Cell11);
    v_EUTRA_Cells[v_Index] := f_EUTRA_CellInfo_Init (eutra_Cell11,
                                                     px_ePrimaryFrequencyBand,
                                                     p_SysinfoCombination,
                                                     px_ePrimaryBandChannelBandwidth,
                                                     v_PrimaryBandChBandwidth_UL);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_Cell12);
    v_EUTRA_Cells[v_Index] := f_EUTRA_CellInfo_Init (eutra_Cell12,
                                                     px_ePrimaryFrequencyBand,
                                                     p_SysinfoCombination,
                                                     px_ePrimaryBandChannelBandwidth,
                                                     v_PrimaryBandChBandwidth_UL);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_Cell13);
    v_EUTRA_Cells[v_Index] := f_EUTRA_CellInfo_Init (eutra_Cell13,
                                                     px_ePrimaryFrequencyBand,
                                                     p_SysinfoCombination,
                                                     px_ePrimaryBandChannelBandwidth,
                                                     v_PrimaryBandChBandwidth_UL);

    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_Cell14);
    v_EUTRA_Cells[v_Index] := f_EUTRA_CellInfo_Init (eutra_Cell14,
                                                     px_ePrimaryFrequencyBand,
                                                     p_SysinfoCombination,
                                                     px_ePrimaryBandChannelBandwidth,
                                                     v_PrimaryBandChBandwidth_UL);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_Cell23);
    v_EUTRA_Cells[v_Index] := f_EUTRA_CellInfo_Init (eutra_Cell23,
                                                     px_ePrimaryFrequencyBand,
                                                     p_SysinfoCombination,
                                                     px_ePrimaryBandChannelBandwidth,
                                                     v_PrimaryBandChBandwidth_UL);
    return v_EUTRA_Cells;
  };

  //------------------------------------------------------------------------------------------
  // ---------------------  Initialise EUTRA cells info for NAS test cases -------------------
  /*
   * @desc      Initialise cell info for one NAS cell
   * @param     p_CellId
   * @param     p_CellsOnPLMN
   * @param     p_CellTC_Type
   * @param     p_FrequencyBand
   * @param     p_DL_Bandwidth
   * @param     p_UL_Bandwidth
   * @param     p_CellSpecialFreq
   * @return    EUTRA_CellInfo_Type
   * @status    APPROVED
   * @sic R5-096641 sic@
   */
  function fl_EUTRA_NAS_CellInfo_Init( CellId_Type              p_CellId,
                                       EUTRA_NAS_NumOfPLMN_Type p_CellsOnPLMN,
                                       EUTRA_NAS_CellTC_Type    p_CellTC_Type,
                                       FrequencyBand_Type       p_FrequencyBand,
                                       Dl_Bandwidth_Type        p_DL_Bandwidth,
                                       Ul_Bandwidth_Type        p_UL_Bandwidth,
                                       EUTRA_NAS_CellSpecialFreq p_CellSpecialFreq ) return EUTRA_CellInfo_Type
  {
    var CellIdentities_Type v_CellIds  := fl_EUTRA_InitCellIdentities_NAS ( p_CellId, p_CellsOnPLMN );
    var EUTRA_FDD_TDD_CellInfo_Type v_FDD_TDD_Info:= fl_InitFDD_TDD_FromBand (p_FrequencyBand);
    var EUTRA_FDD_TDD_Mode_Type v_FDD_TDD := v_FDD_TDD_Info.FDD_TDD;
    var CellTimingInfo_Type  v_Celltiming := fl_EUTRA_InitialiseCellTiming (p_CellId, v_FDD_TDD, p_CellsOnPLMN);
    var Combination_Type v_SysinfoCombination := fl_NAS_InitSysinfoCombination (p_CellId, p_CellsOnPLMN, p_CellTC_Type);
    var RootSequenceIndex_Type v_RootSequenceIndex_Type := f_InitialisePRACH_RootSequenceIndex (p_CellId, v_FDD_TDD, p_CellsOnPLMN);
    var RACH_TimingAdvance_Type  v_RAR_TA := fl_InitialiseRAR_TA (p_CellId, v_FDD_TDD, LTE_AllCellsOnSamePLMN);
    
    var CarrierFreqEUTRA v_UL_DL_Earfcn;
    var NAS_Parameter_Type v_NAS_Param;
    var template (value) BcchInfo_Type       v_BCCH_Info;
    var template (value) EUTRA_CellInfo_Type v_CellInfo;
    var Frequency_fList_Type v_Freq;
    var ChannelBandwidthDependency_Type v_ChannelBandwidthDependency := f_EUTRA_BandDependentParam ( p_DL_Bandwidth, p_UL_Bandwidth );  //@sic R5s090180: return CFI value sic@
    
    // Initialise Frequencies f1/f2/f3/f4
    v_Freq:= f_EUTRA_InitFrequency_f1Tof4(p_FrequencyBand, p_DL_Bandwidth, p_UL_Bandwidth);
    
    // Initialise the Frequency of the cell.
    select ( p_CellsOnPLMN ) {
      case ( LTE_AllCellsOnSamePLMN ) {
        // If all cells in the test case are on the same PLMN
        // Acc. 36.508 Table 6.3.2.2-2
        // Cell A/B/D -> frequency f1
        // Cell C/M -> Frequency f2
        // others Cells: any value as other cells are on a different PLMN
        select (p_CellId) {
          case (eutra_CellA, eutra_CellB,eutra_CellD ) {
            v_UL_DL_Earfcn := v_Freq.f1;   //f1
          }
          case (eutra_CellC, eutra_CellM) {
            v_UL_DL_Earfcn := v_Freq.f2;  //f2
          }
          case else {  // others Cells: not applicable as other cells are on a different PLMN
            v_UL_DL_Earfcn := v_Freq.f3;  //f3 Dummy value
          }
        }
      }
      case (LTE_CellsOnDifferentPLMN) {
        // If all cells in the test case are on the same PLMN
        select (p_CellSpecialFreq) {  // @sic R5-102140 sic@
            case (LTE_NAS_NormalFreq) {
            // Acc. 36.508 Table 6.3.2.2-3
            // Cell A/B/C/D/M -> frequency f1
            // Cell E/G/H -> Frequency f2
            // Cell I/K/L -> Frequency f3
            // Cell J -> Frequency f4
            // others Cells: no Other cells
            // The test frequency f3 or f4 is allocated to the cell if f1 and f2 are already allocated to the cells in the test.
                select (p_CellId) {
                    case (eutra_CellA, eutra_CellB, eutra_CellC, eutra_CellD, eutra_CellM ) {
                        v_UL_DL_Earfcn := v_Freq.f1;     //f1
                    }
                    case (eutra_CellE, eutra_CellG, eutra_CellH) {
                      v_UL_DL_Earfcn := v_Freq.f2;     //f2
                    }
                    case (eutra_CellI, eutra_CellK, eutra_CellL) {
                        v_UL_DL_Earfcn := v_Freq.f3;     //f3
                    }
                    case else {        // CellJ      f4
                        v_UL_DL_Earfcn := v_Freq.f4
                    }

                }
            }
            case (LTE_NAS_Usef1_f2) {
            // Assign freq according to NOTE1 in 36.508 Table 6.3.2.2-3
            // f1 and f2 not being allocated to any cell in the test case, f1 or f2 is allocated, instead of f3 and f3
                select (p_CellId) {
                    case (eutra_CellA, eutra_CellB, eutra_CellC, eutra_CellD, eutra_CellM, eutra_CellI, eutra_CellK, eutra_CellL ) {
                        v_UL_DL_Earfcn := v_Freq.f1;     //f1
                    }
                    case else {
                        v_UL_DL_Earfcn := v_Freq.f2;     //f2
                    }
                }
            }
        }
    }
    case else {
        FatalError (__FILE__, __LINE__, "invalid value in p_EUTRA_NAS_NumOfPLMN");
      }
    }
    
    // Initialise NAS parameters
    v_NAS_Param := fl_EUTRA_InitNAS_forNAS_Cells( p_CellId, p_FrequencyBand );
    
    // Initialise BCCH info
    v_BCCH_Info := f_EUTRA_InitSystemInformation ( p_CellId,
                                                   v_CellIds.CellIdentity,
                                                   v_SysinfoCombination,       //All cells are by default intitialise with the same sysinfo combination
                                                   p_FrequencyBand,
                                                   p_DL_Bandwidth,
                                                   p_UL_Bandwidth,
                                                   cs_PlmnIdList_1Entry(v_NAS_Param.Guti_Parameters.PLMN_Identity),
                                                   v_NAS_Param.TrackingAreaCode,
                                                   v_FDD_TDD_Info,
                                                   v_RootSequenceIndex_Type
                                                   ); // @sic R5s090180 sic@
    
    
    v_CellInfo := cs_EUTRA_CellInfoDef ( v_CellIds,
                                         v_SysinfoCombination,
                                         p_FrequencyBand,
                                         v_UL_DL_Earfcn,
                                         p_DL_Bandwidth,
                                         p_UL_Bandwidth,
                                         v_NAS_Param,
                                         v_BCCH_Info,
                                         v_Celltiming,
                                         v_FDD_TDD_Info,
                                         v_ChannelBandwidthDependency.Cfi,
                                         v_RAR_TA,
                                         v_ChannelBandwidthDependency.sr_PUCCH_ResourceIndex   // @sic R5s090312 sic@
                                         ); // @sic R5s090180 sic@

    return valueof(v_CellInfo);  // Note: valueof cannot be avoided here
  };
  
  //----------------------------------------------------------------------------------------------------------
  /*
   * @desc      Initialise all EUTRA cell info for NAS test cases
   * @param     p_CellsOnPLMN
   * @param     p_CellTC_Type
   * @param     p_CellSpecialFreq
   * @return    EUTRA_CellInfoList_Type
   * @status    APPROVED
   */
  function f_EUTRA_NAS_CellArray_Init (EUTRA_NAS_NumOfPLMN_Type p_CellsOnPLMN,
                                       EUTRA_NAS_CellTC_Type    p_CellTC_Type,
                                       EUTRA_NAS_CellSpecialFreq p_CellSpecialFreq) return EUTRA_CellInfoList_Type
  {
    /* @sic R5-102223 : replace px_eDL_ChannelBandwidth to px_ePrimaryBandChannelBandwidth and px_eSecondaryBandChannelBandwidth
     @sic R5-102223 : delete px_eUL_ChannelBandwidth */
    var EUTRA_CellInfoList_Type v_EUTRA_Cells;
    var integer v_Index;
    var Ul_Bandwidth_Type v_PrimaryBandChBandwidth_UL := f_ConvertDL_BandwidthToUL (px_ePrimaryBandChannelBandwidth);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_CellA);
    v_EUTRA_Cells[v_Index] := fl_EUTRA_NAS_CellInfo_Init (eutra_CellA,
                                                          p_CellsOnPLMN,
                                                          p_CellTC_Type,
                                                          px_ePrimaryFrequencyBand,
                                                          px_ePrimaryBandChannelBandwidth,
                                                          v_PrimaryBandChBandwidth_UL,
                                                          p_CellSpecialFreq);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_CellB);
    v_EUTRA_Cells[v_Index] := fl_EUTRA_NAS_CellInfo_Init (eutra_CellB,
                                                          p_CellsOnPLMN,
                                                          p_CellTC_Type,
                                                          px_ePrimaryFrequencyBand,
                                                          px_ePrimaryBandChannelBandwidth,
                                                          v_PrimaryBandChBandwidth_UL,
                                                          p_CellSpecialFreq);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_CellC);
    v_EUTRA_Cells[v_Index] := fl_EUTRA_NAS_CellInfo_Init (eutra_CellC,
                                                          p_CellsOnPLMN,
                                                          p_CellTC_Type,
                                                          px_ePrimaryFrequencyBand,
                                                          px_ePrimaryBandChannelBandwidth,
                                                          v_PrimaryBandChBandwidth_UL,
                                                          p_CellSpecialFreq);

    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_CellD);
    v_EUTRA_Cells[v_Index] := fl_EUTRA_NAS_CellInfo_Init (eutra_CellD,
                                                          p_CellsOnPLMN,
                                                          p_CellTC_Type,
                                                          px_ePrimaryFrequencyBand,
                                                          px_ePrimaryBandChannelBandwidth,
                                                          v_PrimaryBandChBandwidth_UL,
                                                          p_CellSpecialFreq);
    
    v_Index := f_EUTRA_CellInfo_GetIndex (eutra_CellM);
    v_EUTRA_Cells[v_Index] := fl_EUTRA_NAS_CellInfo_Init (eutra_CellM,
                                                          p_CellsOnPLMN,
                                                          p_CellTC_Type,
                                                          px_ePrimaryFrequencyBand,
                                                          px_ePrimaryBandChannelBandwidth,
                                                          v_PrimaryBandChBandwidth_UL,
                                                          p_CellSpecialFreq);

    if  (p_CellsOnPLMN == LTE_CellsOnDifferentPLMN) {
      v_Index := f_EUTRA_CellInfo_GetIndex (eutra_CellE);
      v_EUTRA_Cells[v_Index] := fl_EUTRA_NAS_CellInfo_Init (eutra_CellE,            // @sic R5s090310 sic@
                                                            p_CellsOnPLMN,
                                                            p_CellTC_Type,
                                                            px_ePrimaryFrequencyBand,
                                                            px_ePrimaryBandChannelBandwidth,
                                                            v_PrimaryBandChBandwidth_UL,
                                                            p_CellSpecialFreq);
      
      v_Index := f_EUTRA_CellInfo_GetIndex (eutra_CellG);
      v_EUTRA_Cells[v_Index] := fl_EUTRA_NAS_CellInfo_Init (eutra_CellG,
                                                            p_CellsOnPLMN,
                                                            p_CellTC_Type,
                                                            px_ePrimaryFrequencyBand,
                                                            px_ePrimaryBandChannelBandwidth,
                                                            v_PrimaryBandChBandwidth_UL,
                                                            p_CellSpecialFreq);
      
      v_Index := f_EUTRA_CellInfo_GetIndex (eutra_CellH);
      v_EUTRA_Cells[v_Index] := fl_EUTRA_NAS_CellInfo_Init (eutra_CellH,
                                                            p_CellsOnPLMN,
                                                            p_CellTC_Type,
                                                            px_ePrimaryFrequencyBand,
                                                            px_ePrimaryBandChannelBandwidth,
                                                            v_PrimaryBandChBandwidth_UL,
                                                            p_CellSpecialFreq);
      
      v_Index := f_EUTRA_CellInfo_GetIndex (eutra_CellI);
      v_EUTRA_Cells[v_Index] := fl_EUTRA_NAS_CellInfo_Init (eutra_CellI,
                                                            p_CellsOnPLMN,
                                                            p_CellTC_Type,
                                                            px_ePrimaryFrequencyBand,
                                                            px_ePrimaryBandChannelBandwidth,
                                                            v_PrimaryBandChBandwidth_UL,
                                                            p_CellSpecialFreq);
      
      v_Index := f_EUTRA_CellInfo_GetIndex (eutra_CellJ);
      v_EUTRA_Cells[v_Index] := fl_EUTRA_NAS_CellInfo_Init (eutra_CellJ,
                                                            p_CellsOnPLMN,
                                                            p_CellTC_Type,
                                                            px_ePrimaryFrequencyBand,
                                                            px_ePrimaryBandChannelBandwidth,
                                                            v_PrimaryBandChBandwidth_UL,
                                                            p_CellSpecialFreq);

      v_Index := f_EUTRA_CellInfo_GetIndex (eutra_CellK);
      v_EUTRA_Cells[v_Index] := fl_EUTRA_NAS_CellInfo_Init (eutra_CellK,
                                                            p_CellsOnPLMN,
                                                            p_CellTC_Type,
                                                            px_ePrimaryFrequencyBand,
                                                            px_ePrimaryBandChannelBandwidth,
                                                            v_PrimaryBandChBandwidth_UL,
                                                            p_CellSpecialFreq);
      
      v_Index := f_EUTRA_CellInfo_GetIndex (eutra_CellL);
      v_EUTRA_Cells[v_Index] := fl_EUTRA_NAS_CellInfo_Init (eutra_CellL,
                                                            p_CellsOnPLMN,
                                                            p_CellTC_Type,
                                                            px_ePrimaryFrequencyBand,
                                                            px_ePrimaryBandChannelBandwidth,
                                                            v_PrimaryBandChBandwidth_UL,
                                                            p_CellSpecialFreq);
      
    }
    return v_EUTRA_Cells;
  };

  
} // End of module
