@@ -67,6 +67,13 @@ def currently_under_condition():
67
67
# instances (hopefully the only and unchanging instances) of the following two types.
68
68
69
69
class _ConditionalAssignment (object ):
70
+ def __init__ (self ):
71
+ self .defaults = {}
72
+
73
+ def __call__ (self , defaults ):
74
+ self .defaults = defaults
75
+ return self
76
+
70
77
""" Context providing funcitionality of "conditional_assignment". """
71
78
def __enter__ (self ):
72
79
global _depth
@@ -75,7 +82,7 @@ def __enter__(self):
75
82
76
83
def __exit__ (self , * exc_info ):
77
84
try :
78
- _finalize ()
85
+ _finalize (self . defaults )
79
86
finally :
80
87
# even if the above finalization throws an error we need to
81
88
# reset the state to prevent errors from bleeding over
@@ -181,7 +188,7 @@ def _pred_sets_are_in_conflict(pred_set_a, pred_set_b):
181
188
return True
182
189
183
190
184
- def _finalize ():
191
+ def _finalize (defaults ):
185
192
"""Build the required muxes and call back to WireVector to finalize the wirevector build."""
186
193
from .memory import MemBlock
187
194
from pyrtl .corecircuits import select
@@ -203,13 +210,13 @@ def _finalize():
203
210
# handle wirevector and register assignments
204
211
else :
205
212
if isinstance (lhs , Register ):
206
- if hasattr ( lhs , 'condition_default' ) :
207
- result = lhs . condition_default
213
+ if lhs in defaults :
214
+ result = defaults [ lhs ]
208
215
else :
209
216
result = lhs # default for registers is "self"
210
217
elif isinstance (lhs , WireVector ):
211
- if hasattr ( lhs , 'condition_default' ) :
212
- result = lhs . condition_default
218
+ if lhs in defaults :
219
+ result = defaults [ lhs ]
213
220
else :
214
221
result = 0 # default for wire is "0"
215
222
else :
0 commit comments