From 19d16fa27f583a6d6cfaa159a9a0ef3e3edd4259 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 28 Apr 2021 11:23:34 +0200 Subject: [PATCH] software/liblitedram/sdram/sdram_write_leveling_find_cmd_delay: Only update best_count when error < best_error. --- litex/soc/software/liblitedram/sdram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litex/soc/software/liblitedram/sdram.c b/litex/soc/software/liblitedram/sdram.c index 11f3a8a8d..d25451155 100644 --- a/litex/soc/software/liblitedram/sdram.c +++ b/litex/soc/software/liblitedram/sdram.c @@ -552,10 +552,10 @@ static void sdram_write_leveling_find_cmd_delay(unsigned int *best_error, unsign error *= -1; if (delay_count >= *best_count) { - *best_count = delay_count; if (error < *best_error) { - *best_cdly = cdly; + *best_cdly = cdly; *best_error = error; + *best_count = delay_count; } } #ifdef SDRAM_WRITE_LEVELING_CMD_DELAY_DEBUG