@@ -101,6 +101,28 @@ def run(self):
101
101
pass
102
102
103
103
104
+ class LoopbackCount (EnvExperiment ):
105
+ def build (self ):
106
+ self .setattr_device ("core" )
107
+ self .setattr_device ("ttl_inout" )
Has a comment. Original line has a comment.
108
+ self .setattr_argument ("npulses" )
109
+
110
+ def set_count (self , count ):
111
+ self .set_dataset ("count" , count )
112
+
113
+ @kernel
114
+ def run (self ):
115
+ self .loop_out .output ()
116
+ delay (5 * us )
117
+ with parallel :
118
+ self .loop_in .gate_rising (10 * us )
119
+ with sequential :
120
+ for i in range (self .npulses ):
121
+ delay (25 * ns )
122
+ self .loop_out .pulse (25 * ns )
123
+ self .set_dataset ("count" , self .loop_in .count ())
124
+
125
+
104
126
class Underflow (EnvExperiment ):
105
127
def build (self ):
106
128
self .setattr_device ("core" )
@@ -182,6 +204,12 @@ def test_pulse_rate(self):
182
204
self .assertGreater (rate , 100 * ns )
183
205
self .assertLess (rate , 2500 * ns )
184
206
207
+ def test_loopback_count (self ):
208
+ npulses = 2
209
+ self .execute (LoopbackCount , npulses = npulses )
210
+ count = self .dataset_mgr .get ("count" )
211
+ self .assertEqual (count , npulses )
212
+
185
213
def test_underflow (self ):
186
214
with self .assertRaises (RTIOUnderflow ):
187
215
self .execute (Underflow )