File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change
1
+ import functools
1
2
from .t import Direction , In
2
3
from .digital import DigitalMeta , Digital
3
4
from .wire import wire
@@ -126,16 +127,22 @@ def _get_first_clock(port, clocktype):
126
127
return None
127
128
128
129
129
- def wireclocktype (defn , inst , clocktype ):
130
+ def _get_first_clock_of_defn (defn , clocktype ):
130
131
# Check common case: top level clock port
131
132
clks = (port if isinstance (port , clocktype ) else None
132
133
for port in defn .interface .ports .values ())
133
134
defnclk = _first (clks )
134
- if defnclk is None :
135
- # Check recursive types
136
- clks = (_get_first_clock (port , clocktype )
137
- for port in defn .interface .ports .values ())
138
- defnclk = _first (clks )
135
+ if defnclk is not None :
136
+ return defnclk
137
+ # Check recursive types
138
+ clks = (_get_first_clock (port , clocktype )
139
+ for port in defn .interface .ports .values ())
140
+ return _first (clks )
141
+
142
+
143
+ @functools .lru_cache (maxsize = None )
144
+ def wireclocktype (defn , inst , clocktype ):
145
+ defnclk = _get_first_clock_of_defn (defn , clocktype )
139
146
if defnclk is None :
140
147
return
141
148
for port in inst .interface .inputs (include_clocks = True ):
You can’t perform that action at this time.
0 commit comments