Skip to content

Commit be83b6d

Browse files
committed
Fix SiliconPlatformPort implementation for proper initialization in tests
1 parent 7de18d4 commit be83b6d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

chipflow_lib/platforms/silicon.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# amaranth: UnusedElaboratable=no
2+
13
# SPDX-License-Identifier: BSD-2-Clause
24
import logging
35
import os
@@ -71,7 +73,14 @@ def __init__(self,
7173
self._direction = io.Direction(port.direction)
7274
self._invert = invert
7375
self._options = port.options
74-
76+
self._pins = port.pins
77+
78+
# Initialize signal attributes to None
79+
self._i = None
80+
self._o = None
81+
self._oe = None
82+
83+
# Create signals based on direction
7584
if self._direction in (io.Direction.Input, io.Direction.Bidir):
7685
self._i = Signal(port.width, name=f"{component}_{name}__i")
7786
if self._direction in (io.Direction.Output, io.Direction.Bidir):
@@ -81,8 +90,10 @@ def __init__(self,
8190
self._oe = Signal(port.width, name=f"{component}_{name}__oe", init=-1)
8291
else:
8392
self._oe = Signal(1, name=f"{component}_{name}__oe", init=-1)
93+
elif self._direction is io.Direction.Output:
94+
# Always create an _oe for output ports
95+
self._oe = Signal(1, name=f"{component}_{name}__oe", init=-1)
8496

85-
self._pins = port.pins
8697
logger.debug(f"Created SiliconPlatformPort {name}, width={len(port.pins)},dir{self._direction}")
8798

8899
def wire(self, m: Module, interface: PureInterface):
@@ -148,6 +159,8 @@ def __getitem__(self, key):
148159
result._oe = None if self._oe is None else self._oe[key]
149160
result._invert = self._invert
150161
result._direction = self._direction
162+
result._options = self._options
163+
result._pins = self._pins
151164
return result
152165

153166
def __invert__(self):
@@ -157,6 +170,8 @@ def __invert__(self):
157170
result._oe = self._oe
158171
result._invert = not self._invert
159172
result._direction = self._direction
173+
result._options = self._options
174+
result._pins = self._pins
160175
return result
161176

162177
def __add__(self, other):
@@ -167,6 +182,8 @@ def __add__(self, other):
167182
result._oe = None if direction is io.Direction.Input else Cat(self._oe, other._oe)
168183
result._invert = self._invert
169184
result._direction = direction
185+
result._options = self._options
186+
result._pins = self._pins + other._pins
170187
return result
171188

172189
def __repr__(self):

0 commit comments

Comments
 (0)