import SPIFlash, ElectricPower, ElectricLogic

spi_flash = new SPIFlash
spi_flash.memory_size = 16MB  # Common sizes: 1MB, 2MB, 4MB, 8MB, 16MB, 32MB

# Connect power supply
power_3v3 = new ElectricPower
assert power_3v3.voltage within 3.3V +/- 5%
spi_flash.power ~ power_3v3

# Connect SPI/QSPI interface
microcontroller.qspi ~ spi_flash.qspi

# For standard SPI (using only 2 data lines)
microcontroller.spi.sclk ~ spi_flash.qspi.sclk
microcontroller.spi.mosi ~ spi_flash.qspi.ios[0]  # DI/IO0
microcontroller.spi.miso ~ spi_flash.qspi.ios[1]  # DO/IO1

# Chip select
chip_select = new ElectricLogic
chip_select.reference ~ power_3v3
microcontroller.gpio_cs ~ chip_select.line
spi_flash.qspi.cs ~ chip_select

# For Quad SPI (4x faster)
# microcontroller.qspi.ios[2] ~ spi_flash.qspi.ios[2]  # WP/IO2
# microcontroller.qspi.ios[3] ~ spi_flash.qspi.ios[3]  # HOLD/IO3

# Common applications: firmware storage, data logging, file systems

Parameters

memory_size
byte

Interfaces

power
ElectricPower
qspi
MultiSPI

Global Attributes

These attributes are available to all modules and interfaces in a design.
lcsc_id
str
Assign the LCSC ID of the module.If set, this will tell the picker to select that part from LCSC for this block.
manufacturer
str
This module’s manufacturer name, as a string.Only exact matches on the manufacturer’s name will be found by the picker. It’s recommended to fill this information based on what ato create component provides.
mpn
str
This module’s manufacturer part number, as a string.For the picker to select the correct part from the manufacturer, this must be set.
package
str
The package of the module.This drives which components can be selected, and what footprint is used.Must exactly match a known package name.
exclude_from_bom
bool
override_net_name
str
When set on an interface, this will override the net name of the interface.This is useful for renaming nets which are automatically generated.
required
bool
Only for ModuleInterfaces. If set to True, require that interface is connected to something outside of the module it’s defined in.
import SPIFlash, ElectricPower, ElectricLogic

spi_flash = new SPIFlash
spi_flash.memory_size = 16MB  # Common sizes: 1MB, 2MB, 4MB, 8MB, 16MB, 32MB

# Connect power supply
power_3v3 = new ElectricPower
assert power_3v3.voltage within 3.3V +/- 5%
spi_flash.power ~ power_3v3

# Connect SPI/QSPI interface
microcontroller.qspi ~ spi_flash.qspi

# For standard SPI (using only 2 data lines)
microcontroller.spi.sclk ~ spi_flash.qspi.sclk
microcontroller.spi.mosi ~ spi_flash.qspi.ios[0]  # DI/IO0
microcontroller.spi.miso ~ spi_flash.qspi.ios[1]  # DO/IO1

# Chip select
chip_select = new ElectricLogic
chip_select.reference ~ power_3v3
microcontroller.gpio_cs ~ chip_select.line
spi_flash.qspi.cs ~ chip_select

# For Quad SPI (4x faster)
# microcontroller.qspi.ios[2] ~ spi_flash.qspi.ios[2]  # WP/IO2
# microcontroller.qspi.ios[3] ~ spi_flash.qspi.ios[3]  # HOLD/IO3

# Common applications: firmware storage, data logging, file systems