From e498a5669858936dd34c3681b4fa0617c2b6fa8a Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Thu, 1 Feb 2024 08:42:11 +0100 Subject: [PATCH] soc/add_spi_flash: Minor integration cleanup and remove PHY_FREQUENCY constants that is no longer used. --- litex/soc/integration/soc.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/litex/soc/integration/soc.py b/litex/soc/integration/soc.py index 16fba83ab..53c75a4fa 100644 --- a/litex/soc/integration/soc.py +++ b/litex/soc/integration/soc.py @@ -8,6 +8,7 @@ import os import sys +import math import time import logging import argparse @@ -1884,13 +1885,11 @@ def add_spi_flash(self, name="spiflash", mode="4x", clk_freq=20e6, module=None, from litespi import LiteSPI from litespi.phy.generic import LiteSPIPHY from litespi.opcodes import SpiNorFlashOpCodes - import math # Checks/Parameters. assert mode in ["1x", "4x"] - # From LiteSPIClkGen: clk_freq will be ``sys_clk_freq/(2*(1+div))``. - default_divisor = math.ceil(self.sys_clk_freq/(clk_freq*2))-1 - clk_freq = int(self.sys_clk_freq/(2*(1+default_divisor))) + default_divisor = math.ceil(self.sys_clk_freq/(2*clk_freq)) - 1 + clk_freq = int(self.sys_clk_freq/(2*(default_divisor + 1))) # PHY. spiflash_phy = phy @@ -1908,7 +1907,6 @@ def add_spi_flash(self, name="spiflash", mode="4x", clk_freq=20e6, module=None, self.bus.add_slave(name=name, slave=spiflash_core.bus, region=spiflash_region) # Constants. - self.add_constant(f"{name}_PHY_FREQUENCY", clk_freq) self.add_constant(f"{name}_MODULE_NAME", module.name.upper()) self.add_constant(f"{name}_MODULE_TOTAL_SIZE", module.total_size) self.add_constant(f"{name}_MODULE_PAGE_SIZE", module.page_size)