import EEPROM, ElectricPower, I2C, Resistor

eeprom = new EEPROM
eeprom.memory_size = 32kbit  # Common sizes: 1k, 2k, 4k, 8k, 16k, 32k, 64k, 128k bit

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

# Connect I2C bus
i2c_bus = new I2C
i2c_bus.frequency = 400kHz  # Fast mode
eeprom.i2c ~ i2c_bus

# Connect to microcontroller
microcontroller.i2c ~ i2c_bus

# Set device address using address pins
eeprom.set_address(0)  # Device address 0b000

# Connect address pins to power rails for different addresses
eeprom.address[0].line ~ power_3v3.lv  # A0 = 0
eeprom.address[1].line ~ power_3v3.lv  # A1 = 0  
eeprom.address[2].line ~ power_3v3.lv  # A2 = 0

# Write protect control (optional)
eeprom.write_protect.reference ~ power_3v3
eeprom.write_protect.line ~ power_3v3.lv  # Enable writes

# Pull-up resistors for I2C (if not provided elsewhere)
sda_pullup = new Resistor
scl_pullup = new Resistor
sda_pullup.resistance = 4.7kohm +/- 5%
scl_pullup.resistance = 4.7kohm +/- 5%
i2c_bus.sda.line ~> sda_pullup ~> power_3v3.hv
i2c_bus.scl.line ~> scl_pullup ~> power_3v3.hv

Parameters

memory_size
bit

Interfaces

address[0]
ElectricLogic
address[1]
ElectricLogic
address[2]
ElectricLogic
i2c
I2C
power
ElectricPower
write_protect
ElectricLogic

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 EEPROM, ElectricPower, I2C, Resistor

eeprom = new EEPROM
eeprom.memory_size = 32kbit  # Common sizes: 1k, 2k, 4k, 8k, 16k, 32k, 64k, 128k bit

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

# Connect I2C bus
i2c_bus = new I2C
i2c_bus.frequency = 400kHz  # Fast mode
eeprom.i2c ~ i2c_bus

# Connect to microcontroller
microcontroller.i2c ~ i2c_bus

# Set device address using address pins
eeprom.set_address(0)  # Device address 0b000

# Connect address pins to power rails for different addresses
eeprom.address[0].line ~ power_3v3.lv  # A0 = 0
eeprom.address[1].line ~ power_3v3.lv  # A1 = 0  
eeprom.address[2].line ~ power_3v3.lv  # A2 = 0

# Write protect control (optional)
eeprom.write_protect.reference ~ power_3v3
eeprom.write_protect.line ~ power_3v3.lv  # Enable writes

# Pull-up resistors for I2C (if not provided elsewhere)
sda_pullup = new Resistor
scl_pullup = new Resistor
sda_pullup.resistance = 4.7kohm +/- 5%
scl_pullup.resistance = 4.7kohm +/- 5%
i2c_bus.sda.line ~> sda_pullup ~> power_3v3.hv
i2c_bus.scl.line ~> scl_pullup ~> power_3v3.hv