########################
# Returns the input clock frequency in MHz for the specified inclk, based on the current
# value of IN_FREQ_UNITS.
# Does not change the Prim/SECONDARY_IN_FREQ.
# bPrim --> 2 = Secondary; 1 = Primary.
proc get_inclk_in_MHz { bPrim } {
   variable IN_FREQ_UNITS
   variable PRIM_IN_FREQ

   if { [get_param_value IN_FREQ_UNITS ] == "Units_ns" } {
      set infreq [convert_ns_to_MHz [get_param_value PRIM_IN_FREQ ]]
   } else {
      set infreq [get_param_value PRIM_IN_FREQ ]
   }
   return $infreq
}

#################################################################
# Returns the given MHz value as ns.
proc convert_MHz_to_ns { MHzValue } {
   # 1 MHz = 1000/ns
   if { $MHzValue != 0 } {
      return [expr  1000.000 / $MHzValue]
   }
   return 0.0
}

#################################################################
# Returns the given KHz value as ns.
proc convert_KHz_to_ns { KHzValue } {
   # 1 KHz = 1000000/ns
   if { $KHzValue != 0 } {
      set ss_period_fval [expr  1000000 / $KHzValue]