1515
1616from minerva .core import Minerva
1717
18- from chipflow_lib .platforms import InputIOSignature , OutputIOSignature
18+ from chipflow_lib .platforms import InputIOSignature , OutputIOSignature , BidirIOSignature , Sky130DriveMode
1919# from .ips.pdm import PDMPeripheral
2020
2121__all__ = ["MySoC" ]
@@ -29,6 +29,7 @@ def __init__(self):
2929 "flash" : Out (QSPIFlash .Signature ()),
3030 "uart_0" : Out (UARTPeripheral .Signature ()),
3131 "gpio_0" : Out (GPIOPeripheral .Signature (pin_count = 8 )),
32+ "gpio_open_drain" : Out (GPIOPeripheral .Signature (pin_count = 4 , sky130_drive_mode = Sky130DriveMode .OPEN_DRAIN_STRONG_UP ))
3233 })
3334
3435 # Memory regions:
@@ -42,7 +43,7 @@ def __init__(self):
4243 self .csr_base = 0xb0000000
4344 self .csr_spiflash_base = 0xb0000000
4445
45- self .csr_gpio_base = 0xb1000000
46+ self .csr_gpio_base = 0xb1000000
4647 self .csr_uart_base = 0xb2000000
4748 self .csr_soc_id_base = 0xb4000000
4849
@@ -98,11 +99,18 @@ def elaborate(self, platform):
9899 m .submodules .sram = sram
99100
100101 # GPIOs
101- m .submodules .gpio = gpio = GPIOPeripheral (pin_count = 8 )
102- csr_decoder .add (gpio .bus , name = "gpio_0" , addr = self .csr_gpio_base - self .csr_base )
102+ m .submodules .gpio0 = gpio0 = GPIOPeripheral (pin_count = 8 )
103+ csr_decoder .add (gpio0 .bus , name = "gpio_0" , addr = self .csr_gpio_base - self .csr_base )
103104 sw .add_periph ("gpio" , "GPIO_0" , self .csr_gpio_base )
104105
105- connect (m , flipped (self .gpio_0 ), gpio .pins )
106+ connect (m , flipped (self .gpio_0 ), gpio0 .pins )
107+
108+ m .submodules .gpio_open_drain = gpio_open_drain = GPIOPeripheral (pin_count = 4 )
109+ csr_decoder .add (gpio_open_drain .bus , name = "gpio_open_drain" , addr = self .csr_gpio_base + self .periph_offset - self .csr_base )
110+ sw .add_periph ("gpio" , "GPIO_OPEN_DRAIN" , self .csr_gpio_base + self .periph_offset )
111+
112+ connect (m , flipped (self .gpio_open_drain ), gpio_open_drain .pins )
113+
106114
107115 # UART
108116 m .submodules .uart = uart = UARTPeripheral (init_divisor = int (25e6 // 115200 ), addr_width = 5 )
0 commit comments