From 6ec7a2473168c7ab1204cdac0f3859947b3ba64b Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Tue, 26 Apr 2022 23:26:11 +0200 Subject: [PATCH] software/liblitedram: Fixup overflow in BIST speed math With decent burst length, fast RAM and fast clock rate, the intermediate result can easily overflow 32 bits. Signed-off-by: Sylvain Munaut --- litex/soc/software/liblitedram/bist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litex/soc/software/liblitedram/bist.c b/litex/soc/software/liblitedram/bist.c index 3add89c1b..f2079224d 100644 --- a/litex/soc/software/liblitedram/bist.c +++ b/litex/soc/software/liblitedram/bist.c @@ -131,7 +131,7 @@ void sdram_bist_loop(uint32_t loop, uint32_t burst_length, uint32_t random) { static uint32_t compute_speed_mibs(uint32_t length, uint32_t ticks) { uint32_t speed; //printf("(%u, %u)", length, ticks); - speed = length*(CONFIG_CLOCK_FREQUENCY/(1024*1024))/ticks; + speed = (uint64_t)length*(CONFIG_CLOCK_FREQUENCY/(1024*1024))/ticks; return speed; }