mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
liblitedram: Move pattern testing to its own function
Signed-off-by: Maciej Dudek <mdudek@antmicro.com>
This commit is contained in:
parent
155bf31e04
commit
7b7fdadd26
1 changed files with 18 additions and 9 deletions
|
@ -370,6 +370,19 @@ static unsigned int sdram_write_read_check_test_pattern(int module, unsigned int
|
|||
return errors;
|
||||
}
|
||||
|
||||
static int _seed_array[] = {42, 84, 36, 72, 24, 48};
|
||||
static int _seed_array_length = sizeof(_seed_array) / sizeof(_seed_array[0]);
|
||||
|
||||
|
||||
static int run_test_pattern(int module)
|
||||
{
|
||||
int errors = 0;
|
||||
for (int i = 0; i < _seed_array_length; i++) {
|
||||
errors += sdram_write_read_check_test_pattern(module, _seed_array[i]);
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
static void sdram_leveling_center_module(
|
||||
int module, int show_short, int show_long, delay_callback rst_delay, delay_callback inc_delay)
|
||||
{
|
||||
|
@ -387,8 +400,7 @@ static void sdram_leveling_center_module(
|
|||
delay = 0;
|
||||
rst_delay(module);
|
||||
while(1) {
|
||||
errors = sdram_write_read_check_test_pattern(module, 42);
|
||||
errors += sdram_write_read_check_test_pattern(module, 84);
|
||||
errors = run_test_pattern(module);
|
||||
working = errors == 0;
|
||||
show = show_long;
|
||||
#if SDRAM_PHY_DELAYS > 32
|
||||
|
@ -410,8 +422,7 @@ static void sdram_leveling_center_module(
|
|||
cur_delay_min = delay_min;
|
||||
/* Find largest working delay range */
|
||||
while(1) {
|
||||
errors = sdram_write_read_check_test_pattern(module, 42);
|
||||
errors += sdram_write_read_check_test_pattern(module, 84);
|
||||
errors = run_test_pattern(module);
|
||||
working = errors == 0;
|
||||
show = show_long;
|
||||
#if SDRAM_PHY_DELAYS > 32
|
||||
|
@ -467,8 +478,7 @@ static void sdram_leveling_center_module(
|
|||
}
|
||||
|
||||
/* Check */
|
||||
errors = sdram_write_read_check_test_pattern(module, 42);
|
||||
errors += sdram_write_read_check_test_pattern(module, 84);
|
||||
errors = run_test_pattern(module);
|
||||
if (errors == 0)
|
||||
break;
|
||||
retries--;
|
||||
|
@ -949,7 +959,7 @@ static void sdram_read_leveling_inc_bitslip(char m)
|
|||
|
||||
static unsigned int sdram_read_leveling_scan_module(int module, int bitslip, int show)
|
||||
{
|
||||
const unsigned int max_errors = 2*READ_CHECK_TEST_PATTERN_MAX_ERRORS;
|
||||
const unsigned int max_errors = _seed_array_length * READ_CHECK_TEST_PATTERN_MAX_ERRORS;
|
||||
int i;
|
||||
unsigned int score;
|
||||
unsigned int errors;
|
||||
|
@ -965,8 +975,7 @@ static unsigned int sdram_read_leveling_scan_module(int module, int bitslip, int
|
|||
#if SDRAM_PHY_DELAYS > 32
|
||||
_show = (i%16 == 0) & show;
|
||||
#endif
|
||||
errors = sdram_write_read_check_test_pattern(module, 42);
|
||||
errors += sdram_write_read_check_test_pattern(module, 84);
|
||||
errors = run_test_pattern(module);
|
||||
working = errors == 0;
|
||||
/* When any scan is working then the final score will always be higher then if no scan was working */
|
||||
score += (working * max_errors*SDRAM_PHY_DELAYS) + (max_errors - errors);
|
||||
|
|
Loading…
Reference in a new issue