@@ -32,6 +32,7 @@ def reset(self):
32
32
** _ValueCompiler .helpers
33
33
}
34
34
self .waits_on = SignalSet ()
35
+ self .command = None
35
36
36
37
def src_loc (self ):
37
38
coroutine = self .coroutine
@@ -58,29 +59,38 @@ def run(self):
58
59
if self .coroutine is None :
59
60
return
60
61
61
- self .clear_triggers ()
62
+ if self .command is None :
63
+ self .clear_triggers ()
62
64
63
65
response = None
64
66
exception = None
67
+ assigned = False
65
68
while True :
66
- try :
67
- if exception is None :
68
- command = self .coroutine .send (response )
69
- else :
70
- command = self .coroutine .throw (exception )
71
- except StopIteration :
72
- self .passive = True
73
- self .coroutine = None
74
- return False # no assignment
69
+ if self .command is not None :
70
+ command , self .command = self .command , None
71
+ else :
72
+ try :
73
+ if exception is None :
74
+ command = self .coroutine .send (response )
75
+ else :
76
+ command = self .coroutine .throw (exception )
77
+ except StopIteration :
78
+ self .passive = True
79
+ self .coroutine = None
80
+ return assigned
75
81
76
82
try :
77
83
if command is None :
78
84
command = self .default_cmd
85
+ if isinstance (command , ValueCastable ):
86
+ command = Value .cast (command )
79
87
response = None
80
88
exception = None
81
89
82
- if isinstance (command , ValueCastable ):
83
- command = Value .cast (command )
90
+ if assigned and isinstance (command , (Value , Tick , Settle , Delay , MemorySimRead )):
91
+ self .command = command
92
+ return True # changed state; run RTL processes and retry
93
+
84
94
if isinstance (command , Value ):
85
95
exec (_RHSValueCompiler .compile (self .state , command , mode = "curr" ),
86
96
self .exec_locals )
@@ -90,7 +100,7 @@ def run(self):
90
100
exec (_StatementCompiler .compile (self .state , command ),
91
101
self .exec_locals )
92
102
if isinstance (command , Assign ) and self .testbench :
93
- return True # assignment; run a delta cycle
103
+ assigned = True
94
104
95
105
elif type (command ) is Tick :
96
106
domain = command .domain
@@ -105,17 +115,17 @@ def run(self):
105
115
self .add_trigger (domain .clk , trigger = 1 if domain .clk_edge == "pos" else 0 )
106
116
if domain .rst is not None and domain .async_reset :
107
117
self .add_trigger (domain .rst , trigger = 1 )
108
- return False # no assignments
118
+ return False # did not change state
109
119
110
120
elif type (command ) is Settle :
111
121
self .state .wait_interval (self , None )
112
- return False # no assignments
122
+ return False # did not change state
113
123
114
124
elif type (command ) is Delay :
115
125
# Internal timeline is in 1ps integeral units, intervals are public API and in floating point
116
126
interval = int (command .interval * 1e12 ) if command .interval is not None else None
117
127
self .state .wait_interval (self , interval )
118
- return False # no assignments
128
+ return False # did not change state
119
129
120
130
elif type (command ) is Passive :
121
131
self .passive = True
@@ -144,7 +154,7 @@ def run(self):
144
154
assert isinstance (state , BaseMemoryState )
145
155
state .write (addr , data )
146
156
if self .testbench :
147
- return True # assignment; run a delta cycle
157
+ assigned = True
148
158
149
159
elif command is None : # only possible if self.default_cmd is None
150
160
raise TypeError ("Received default command from process {!r} that was added "
0 commit comments