From 7e9ef2247c142869c58d7fe3ffac8a0bb1cdb12f Mon Sep 17 00:00:00 2001 From: Sachin Gupta Date: Fri, 21 Oct 2016 18:11:41 -0500 Subject: Update fapi::delay implementation Change-Id: I1194b6819de9c9c4935e2761b984de1f40ba9aec Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/31680 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: RAJA DAS Reviewed-by: Shakeeb A. Pasha B K Reviewed-by: AMIT J. TENDOLKAR --- src/hwpf/src/plat/plat_utils.C | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'src/hwpf/src') diff --git a/src/hwpf/src/plat/plat_utils.C b/src/hwpf/src/plat/plat_utils.C index 4b5a60ea..41b9a53b 100644 --- a/src/hwpf/src/plat/plat_utils.C +++ b/src/hwpf/src/plat/plat_utils.C @@ -39,6 +39,13 @@ namespace fapi2 { + // Define own function rather than using PK function + // This is required as PK function does not scale well for low + // frequency till istep 2.7 + inline uint64_t delayCycles(uint64_t i_nanoSeconds ) + { + return ( i_nanoSeconds/1000) * ( g_sbefreq /(1000*1000)); + } /// @brief Delay this thread. /// ReturnCode delay(uint64_t i_nanoSeconds, uint64_t i_simCycles, bool i_fixed /* = false*/) @@ -51,8 +58,6 @@ namespace fapi2 #ifndef __FAPI_DELAY_SIM__ -#define PK_NANOSECONDS_SBE(n) ((PkTimebase)((PK_BASE_FREQ_HZ * (PkTimebase)(n)) / (1024*1024*1024))) - PkTimebase target_time; PkTimebase current_time; PkMachineContext ctx; @@ -61,33 +66,12 @@ namespace fapi2 // Only execute if nanoSeconds is non-zero (eg a real wait) if (i_nanoSeconds) { - // @todo For SBE applications, the time accuracy can be traded off - // for space with the PK_NANOSECONDS_SBE implemenation as the compiler - // use shift operations for the unit normalizing division. - // The critical section enter/exit set is done to ensure the timebase // operations are non-interrupible. pk_critical_section_enter(&ctx); - // - // The "accurate" version is the next line. - // target_time = pk_timebase_get() + PK_INTERVAL_SCALE(PK_NANOSECONDS(i_nanoSeconds)); - uint64_t cycles = 0; - if( SBE::isSimicsRunning() ) - { - cycles = PK_INTERVAL_SCALE( - PK_NANOSECONDS_SBE(i_nanoSeconds)); - } - else - { - // TODO via RTC 163216 - // Fix for the timer ( using in cycle mode ) - // Check what should be the right approach for time calculatin. - cycles = PK_INTERVAL_SCALE( - PK_NANOSECONDS_SBE(i_nanoSeconds)) * 64; - } - target_time = pk_timebase_get() + cycles; + target_time = pk_timebase_get() + delayCycles( i_nanoSeconds); do { -- cgit v1.2.1