Improve timings
This commit is contained in:
@@ -20,13 +20,6 @@
|
||||
|
||||
namespace ams::ldr::oc::pcv::mariko {
|
||||
|
||||
s32 FixEinput(s32 val) {
|
||||
if (auto patch = FindEinput()) {
|
||||
return patch->correct;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
u32 GetRext() {
|
||||
if (auto r = FindRext()) {
|
||||
return r->correct;
|
||||
@@ -36,8 +29,7 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
|
||||
/* TODO: This function is quite uggly, refactor! */
|
||||
void CalculateMiscTimings() {
|
||||
tW2P = 0x2d;
|
||||
rdv = 0x39 + C.mem_burst_read_latency;
|
||||
rdv = 0x39 + C.mem_burst_read_latency;
|
||||
einput_duration = 0x1C;
|
||||
quse_width = 0x8;
|
||||
|
||||
@@ -50,12 +42,7 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
}
|
||||
}
|
||||
|
||||
if (WL >= 16) tW2P += 6;
|
||||
if (WL >= 18) tW2P += 8;
|
||||
|
||||
s32 einput_calc = quse_width - (0.010182 * (C.marikoEmcMaxClock / 1000.0) - 0.0879) + 0.5;
|
||||
einput = FixEinput(einput_calc);
|
||||
rext = GetRext();
|
||||
rext = GetRext();
|
||||
}
|
||||
|
||||
void CalculateIbdly() {
|
||||
@@ -82,38 +69,13 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
}
|
||||
|
||||
void CalculateTR2W() {
|
||||
tR2W = CEIL(RL_DBI + (tDQSCK_max / tCK_avg) + (BL / 2) - WL + tWPRE + FLOOR(tRPST) + 9.0);
|
||||
tR2W = CEIL(RL_DBI + (tDQSCK_max / tCK_avg) + (BL / 2) - WL + tWPRE + FLOOR(tRPST) + 9.0) - (C.t6_tRTW * 3);
|
||||
|
||||
if (auto patch = FindTR2WPatch()) {
|
||||
tR2W += patch->adjust;
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateTW2R() {
|
||||
tW2R = WL + (BL / 2) - 6 + CEIL(tWTR / tCK_avg);
|
||||
|
||||
const FreqTW2R* t = FindTW2R();
|
||||
if (!t) return;
|
||||
|
||||
tW2R += t->adjust;
|
||||
|
||||
if (t->min_val) {
|
||||
tW2R = MAX(tW2R, t->min_val);
|
||||
}
|
||||
|
||||
if (t->max_val) {
|
||||
tW2R = MIN(tW2R, t->max_val);
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateQuse() {
|
||||
quse = ROUND(0.002266 * (C.marikoEmcMaxClock / 1000.0) + 31.88) + C.mem_burst_read_latency;
|
||||
|
||||
if (auto patch = FindQusePatch()) {
|
||||
quse += patch->adjust;
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateQrst() {
|
||||
qrst = 0x00070000;
|
||||
u32 qrst_calc = ROUND(22.1 - (C.marikoEmcMaxClock / 1000000.0) * 8.0) + C.mem_burst_read_latency;
|
||||
@@ -173,8 +135,6 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
CalculateObdly();
|
||||
CalculateTWTPDEN();
|
||||
CalculateTR2W();
|
||||
CalculateTW2R();
|
||||
CalculateQuse();
|
||||
CalculateQrst();
|
||||
CalculateQsafe();
|
||||
CalculateQpop();
|
||||
|
||||
@@ -47,29 +47,6 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
|
||||
const u32 g_misc_table_size = sizeof(g_misc_table) / sizeof(g_misc_table[0]);
|
||||
|
||||
const ReplacePatch g_einput_patches[] = {
|
||||
{2'133'000, 0x16}, {2'166'000, 0x17}, {2'200'000, 0x17},
|
||||
{2'233'000, 0x16}, {2'266'000, 0x16}, {2'300'000, 0x15},
|
||||
{2'333'000, 0x14}, {2'366'000, 0x16}, {2'400'000, 0x16},
|
||||
{2'433'000, 0x15}, {2'466'000, 0x15}, {2'500'000, 0x14},
|
||||
{2'533'000, 0x13}, {2'566'000, 0x14}, {2'600'000, 0x14},
|
||||
{2'633'000, 0x13}, {2'666'000, 0x13}, {2'700'000, 0x12},
|
||||
{2'733'000, 0x11}, {2'766'000, 0x13}, {2'800'000, 0x13},
|
||||
{2'833'000, 0x12}, {2'866'000, 0x12}, {2'900'000, 0x12},
|
||||
{2'933'000, 0x10}, {2'966'000, 0x11}, {3'000'000, 0x11},
|
||||
{3'033'000, 0x10}, {3'066'000, 0x10}, {3'100'000, 0x10},
|
||||
{3'133'000, 0x0F}
|
||||
};
|
||||
|
||||
const u32 g_einput_patches_size = sizeof(g_einput_patches) / sizeof(g_einput_patches[0]);
|
||||
|
||||
const ReplacePatch *FindEinput() {
|
||||
for (u32 i = 0; i < g_einput_patches_size; i++)
|
||||
if (g_einput_patches[i].freq == C.marikoEmcMaxClock)
|
||||
return &g_einput_patches[i];
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const ReplacePatch g_rext_table[] = {
|
||||
{2'133'000, 0x1A}, {2'166'000, 0x19}, {2'200'000, 0x19},
|
||||
{2'233'000, 0x19}, {2'266'000, 0x1A}, {2'300'000, 0x1B},
|
||||
@@ -93,28 +70,6 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const FreqTW2R g_tw2r_table[] = {
|
||||
{2'300'000, 0x2B, 0xFFFFFFFF, 0},
|
||||
{2'400'000, 0, 0x2B, 0},
|
||||
{2'500'000, 0x2C, 0xFFFFFFFF, -1},
|
||||
{2'566'000, 0x2D, 0xFFFFFFFF, -1},
|
||||
{2'700'000, 0x2E, 0xFFFFFFFF, -1},
|
||||
{2'800'000, 0x2F, 0xFFFFFFFF, -1},
|
||||
{2'900'000, 0x30, 0xFFFFFFFF, -1},
|
||||
{3'000'000, 0x31, 0xFFFFFFFF, -1},
|
||||
{3'100'000, 0x32, 0xFFFFFFFF, -1},
|
||||
{0xFFFFFFFF, 0, 0x33, 0},
|
||||
};
|
||||
|
||||
const u32 g_tw2r_table_size = sizeof(g_tw2r_table) / sizeof(g_tw2r_table[0]);
|
||||
|
||||
const FreqTW2R *FindTW2R() {
|
||||
for (u32 i = 0; i < g_tw2r_table_size; i++)
|
||||
if (C.marikoEmcMaxClock <= g_tw2r_table[i].max_freq)
|
||||
return &g_tw2r_table[i];
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const AdjustPatch g_ibdly_patches[] = {
|
||||
{2'133'000, -2},
|
||||
{2'166'000, -1},
|
||||
@@ -192,35 +147,6 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const AdjustPatch g_quse_patches[] = {
|
||||
{2'133'000, -1},
|
||||
{2'300'000, -1},
|
||||
{2'333'000, -1},
|
||||
{2'366'000, +1},
|
||||
{2'400'000, +1},
|
||||
{2'433'000, +1},
|
||||
{2'466'000, +1},
|
||||
{2'500'000, -1},
|
||||
{2'533'000, -1},
|
||||
{2'700'000, -1},
|
||||
{2'733'000, -1},
|
||||
{2'766'000, +1},
|
||||
{2'800'000, +1},
|
||||
{2'833'000, +1},
|
||||
{2'866'000, +1},
|
||||
{2'900'000, +1},
|
||||
{2'933'000, -1},
|
||||
};
|
||||
|
||||
const u32 g_quse_table_size = sizeof(g_quse_patches) / sizeof(g_quse_patches[0]);
|
||||
|
||||
const AdjustPatch *FindQusePatch() {
|
||||
for (u32 i = 0; i < g_quse_table_size; i++)
|
||||
if (g_quse_patches[i].freq == C.marikoEmcMaxClock)
|
||||
return &g_quse_patches[i];
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const AdjustPatch g_qrst_patches[] = {
|
||||
{2'166'000, 1},
|
||||
{2'200'000, 1},
|
||||
|
||||
@@ -24,10 +24,6 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
u32 correct;
|
||||
};
|
||||
|
||||
extern const ReplacePatch g_einput_patches[];
|
||||
extern const u32 g_einput_patches_size;
|
||||
const ReplacePatch *FindEinput();
|
||||
|
||||
extern const ReplacePatch g_rext_table[];
|
||||
extern const u32 g_rext_table_size;
|
||||
const ReplacePatch *FindRext();
|
||||
@@ -49,10 +45,6 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
extern const u32 g_tr2w_table_size;
|
||||
const AdjustPatch *FindTR2WPatch();
|
||||
|
||||
extern const AdjustPatch g_quse_patches[];
|
||||
extern const u32 g_quse_table_size;
|
||||
const AdjustPatch *FindQusePatch();
|
||||
|
||||
extern const AdjustPatch g_qrst_patches[];
|
||||
extern const u32 q_qrst_table_size;
|
||||
const AdjustPatch *FindQrstPatch();
|
||||
@@ -80,15 +72,4 @@ namespace ams::ldr::oc::pcv::mariko {
|
||||
extern const MiscTimings g_misc_table[];
|
||||
extern const u32 g_misc_table_size;
|
||||
|
||||
struct FreqTW2R {
|
||||
u32 max_freq;
|
||||
u32 min_val;
|
||||
u32 max_val;
|
||||
s32 adjust;
|
||||
};
|
||||
|
||||
extern const FreqTW2R g_tw2r_table[];
|
||||
extern const u32 g_tw2r_table_size;
|
||||
const FreqTW2R *FindTW2R();
|
||||
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace ams::ldr::oc {
|
||||
const u32 tRAS = tRAS_values[C.t3_tRAS];
|
||||
const double tRRD = tRRD_values[C.t4_tRRD];
|
||||
const u32 tRFCpb = tRFC_values[C.t5_tRFC];
|
||||
const u32 tWTR = tWTR_values[C.t7_tWTR];
|
||||
const u32 tWTR = MAX(static_cast<u32>(0), 10 - tWTR_values[C.t7_tWTR]);
|
||||
|
||||
const u32 tRC = tRAS + tRPpb;
|
||||
const u32 tRFCab = tRFCpb * 2;
|
||||
@@ -128,28 +128,28 @@ namespace ams::ldr::oc {
|
||||
|
||||
const u32 tR2P = 12 + (C.mem_burst_read_latency / 2);
|
||||
inline u32 tR2W;
|
||||
const u32 tRTM = RL + 9 + (tDQSCK_max / tCK_avg) + FLOOR(tRPST) + CEIL(10 / tCK_avg);
|
||||
const u32 tRATM = tRTM + CEIL(10 / tCK_avg) - 12;
|
||||
const u32 tRTM = RL + 9 + (tDQSCK_max / tCK_avg) + FLOOR(tRPST) + CEIL(10 / tCK_avg); // Fix?
|
||||
const u32 tRATM = tRTM + CEIL(10 / tCK_avg) - 12; // Fix?
|
||||
inline u32 rdv;
|
||||
inline u32 einput;
|
||||
const u32 quse = FLOOR((-0.0048159 * (C.marikoEmcMaxClock / 1000.0)) + RL_DBI) + (FLOOR((C.marikoEmcMaxClock / 1000.0) * 0.0050997) * 1.5134);
|
||||
const u32 einput = quse - ((C.marikoEmcMaxClock / 1000.0) * 0.01);
|
||||
inline u32 einput_duration;
|
||||
inline u32 ibdly;
|
||||
inline u32 obdly;
|
||||
inline u32 quse;
|
||||
inline u32 quse_width;
|
||||
inline u32 rext;
|
||||
inline u32 qrst;
|
||||
inline u32 qsafe;
|
||||
inline u32 qpop;
|
||||
|
||||
inline u32 tW2P;
|
||||
const u32 tW2P = (CEIL(WL * 1.7303) * 2) - 5;
|
||||
inline u32 tWTPDEN;
|
||||
inline u32 tW2R;
|
||||
const u32 tW2R = CEIL(MAX(WL + (0.010322547033278747 * (C.marikoEmcMaxClock / 1000.0)), (WL * -0.2067922202979121) + FLOOR(((RL_DBI * -0.1331159971685554) + WL) * 3.654131957826108)) - (tWTR / tCK_avg));
|
||||
const u32 tWTM = WL + (BL / 2) + 1 + CEIL(7.5 / tCK_avg);
|
||||
const u32 tWATM = tWTM + CEIL(tWR / tCK_avg);
|
||||
|
||||
const u32 wdv = 0xE + C.mem_burst_write_latency;
|
||||
const u32 wsv = 0xC + C.mem_burst_write_latency;
|
||||
const u32 wdv = WL;
|
||||
const u32 wsv = WL - 2;
|
||||
const u32 wev = 0xA + C.mem_burst_write_latency;
|
||||
|
||||
inline u32 pdex2rw;
|
||||
|
||||
Reference in New Issue
Block a user