From 629712f1e0d9c66b15ffa57d55242c7a3c15d118 Mon Sep 17 00:00:00 2001 From: Maciej Dudek Date: Wed, 14 Feb 2024 15:31:03 +0100 Subject: [PATCH] Precompute PRS for faster training --- litex/soc/software/liblitedram/sdram.c | 75 +++++++++++++++----------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/litex/soc/software/liblitedram/sdram.c b/litex/soc/software/liblitedram/sdram.c index 62de279caf..28e0cbaf51 100644 --- a/litex/soc/software/liblitedram/sdram.c +++ b/litex/soc/software/liblitedram/sdram.c @@ -359,33 +359,51 @@ static void print_scan_errors(unsigned int errors) { #define READ_CHECK_TEST_PATTERN_MAX_ERRORS (8*SDRAM_PHY_PHASES*DFII_PIX_DATA_BYTES/SDRAM_PHY_MODULES) #define MODULE_BITMASK ((1<> ibo) & mask) ^ + errors += popcount(((precomputed[id][p][pebo] >> ibo) & mask) ^ ((tst[pebo] >> ibo) & mask)); if (SDRAM_PHY_DQ_DQS_RATIO == 16) - errors += popcount(((prs[p][pebo+1] >> ibo) & mask) ^ + errors += popcount(((precomputed[id][p][pebo+1] >> ibo) & mask) ^ ((tst[pebo+1] >> ibo) & mask)); #if SDRAM_PHY_XDR == 2 if (DFII_PIX_DATA_BYTES == 1) // Special case for x4 single IC ibo = 0x4; - errors += popcount(((prs[p][nebo] >> ibo) & mask) ^ + errors += popcount(((precomputed[id][p][nebo] >> ibo) & mask) ^ ((tst[nebo] >> ibo) & mask)); if (SDRAM_PHY_DQ_DQS_RATIO == 16) - errors += popcount(((prs[p][nebo+1] >> ibo) & mask) ^ + errors += popcount(((precomputed[id][p][nebo+1] >> ibo) & mask) ^ ((tst[nebo+1] >> ibo) & mask)); #endif // SDRAM_PHY_XDR == 2 } @@ -460,17 +481,10 @@ static unsigned int sdram_write_read_check_test_pattern(int module, unsigned int return errors; } -#ifdef SIM_SKIP_LOOPS -static int _seed_array[] = {42}; -#else -static int _seed_array[] = {42, 84, 36, 72, 24, 48}; -#endif -static int _seed_array_length = sizeof(_seed_array) / sizeof(_seed_array[0]); - static int run_test_pattern(int module, int dq_line) { int errors = 0; for (int i = 0; i < _seed_array_length; i++) { - errors += sdram_write_read_check_test_pattern(module, _seed_array[i], dq_line); + errors += sdram_write_read_check_test_pattern(module, i, dq_line); } return errors; } @@ -1266,6 +1280,7 @@ int sdram_init(void) { #ifdef SDRAM_PHY_DDR5 sdram_ddr5_flow(); #else + precompute_prs(); reset_sequence(); init_sequence(); #if defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) || defined(SDRAM_PHY_READ_LEVELING_CAPABLE)