Skip to content

Commit

Permalink
soc/add_spi_flash: Minor integration cleanup and remove PHY_FREQUENCY…
Browse files Browse the repository at this point in the history
… constants that is no longer used.
  • Loading branch information
enjoy-digital committed Feb 1, 2024
1 parent e446312 commit e498a56
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions litex/soc/integration/soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import os
import sys
import math
import time
import logging
import argparse
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit e498a56

Please sign in to comment.