@@ -146,15 +146,15 @@ def __init__(self, ports):
146146 def elaborate (self , platform ):
147147 m = Module ()
148148
149- m .submodules .dio_buffer = dio_buffer = io .Buffer ("io" , self .ports .dio )
150- m .submodules .eoi_buffer = eoi_buffer = io .Buffer ("io" , self .ports .eoi )
151- m .submodules .dav_buffer = dav_buffer = io .Buffer ("io" , self .ports .dav )
152- m .submodules .nrfd_buffer = nrfd_buffer = io .Buffer ("io" , self .ports .nrfd )
153- m .submodules .ndac_buffer = ndac_buffer = io .Buffer ("io" , self .ports .ndac )
154- m .submodules .srq_buffer = srq_buffer = io .Buffer ("i" , self .ports .srq )
155- m .submodules .ifc_buffer = ifc_buffer = io .Buffer ("o" , self .ports .ifc )
156- m .submodules .atn_buffer = atn_buffer = io .Buffer ("o" , self .ports .atn )
157- m .submodules .ren_buffer = ren_buffer = io .Buffer ("o" , self .ports .ren )
149+ m .submodules .dio_buffer = dio_buffer = io .Buffer ("io" , ~ self .ports .dio )
150+ m .submodules .eoi_buffer = eoi_buffer = io .Buffer ("io" , ~ self .ports .eoi )
151+ m .submodules .dav_buffer = dav_buffer = io .Buffer ("io" , ~ self .ports .dav )
152+ m .submodules .nrfd_buffer = nrfd_buffer = io .Buffer ("io" , ~ self .ports .nrfd )
153+ m .submodules .ndac_buffer = ndac_buffer = io .Buffer ("io" , ~ self .ports .ndac )
154+ m .submodules .srq_buffer = srq_buffer = io .Buffer ("i" , ~ self .ports .srq )
155+ m .submodules .ifc_buffer = ifc_buffer = io .Buffer ("o" , ~ self .ports .ifc )
156+ m .submodules .atn_buffer = atn_buffer = io .Buffer ("o" , ~ self .ports .atn )
157+ m .submodules .ren_buffer = ren_buffer = io .Buffer ("o" , ~ self .ports .ren )
158158
159159 m .submodules += [
160160 cdc .FFSynchronizer (dio_buffer .i , self .dio_i ),
@@ -190,13 +190,13 @@ def elaborate(self, platform):
190190 settle_delay = 1000
191191 timer = Signal (range (1 + settle_delay ))
192192
193- # m.d.comb += [
194- # platform.request("led", 0).o.eq(self.status == 0),
195- # platform.request("led", 1).o.eq(self.status == 1),
196- # platform.request("led", 2).o.eq(self.status == 2),
197- # platform.request("led", 3).o.eq(self.status == 4),
198- # platform.request("led", 4).o.eq(self.status == 8),
199- # ]
193+ m .d .comb += [
194+ platform .request ("led" , 0 ).o .eq (self .status == 0 ),
195+ platform .request ("led" , 1 ).o .eq (self .status == 1 ),
196+ platform .request ("led" , 2 ).o .eq (self .status == 2 ),
197+ platform .request ("led" , 3 ).o .eq (self .status == 4 ),
198+ platform .request ("led" , 4 ).o .eq (self .status == 8 ),
199+ ]
200200
201201 l_control = Signal (data .StructLayout ({
202202 "tx" : 1 ,
@@ -353,37 +353,44 @@ def __init__(self, logger, assembly, *, dio, eoi, dav, nrfd, ndac, srq, ifc, atn
353353
354354 async def write (self , message : GPIBMessage , data = bytes ([0 ])):
355355 self .assembly .use_pulls ({
356- self ._dio : "high" ,
357- self ._eoi : "high" ,
358- self ._dav : "high" ,
359-
356+ self ._dio : "float" ,
357+ self ._eoi : "float" ,
358+ self ._dav : "float" ,
359+ self ._nrfd : "high" ,
360+ self ._ndac : "high" ,
361+ self ._srq : "high" ,
360362 })
361363 await self .assembly .configure_ports ()
362364
363365 for b in data :
364366 await self ._pipe .send (bytes ([message .value ]))
365367 await self ._pipe .send (bytes ([b ]))
368+ await self ._pipe .flush ()
366369 ack = (await self ._pipe .recv (1 ))[0 ]
367370 assert GPIBMessage (ack ) == GPIBMessage ._Acknowledge
368371
369372 async def read (self , * , to_eoi = True ):
370373 self .assembly .use_pulls ({
374+ self ._dio : "high" ,
375+ self ._eoi : "high" ,
376+ self ._dav : "high" ,
377+ self ._nrfd : "float" ,
378+ self ._ndac : "float" ,
379+ self ._srq : "float" ,
371380
372- self ._nrfd : "high" ,
373- self ._ndac : "high" ,
374- self ._srq : "high" ,
375381 })
376382 await self .assembly .configure_ports ()
377383
378384 eoi = False
379385 while not eoi :
380386 await self ._pipe .send (bytes ([GPIBMessage .Listen .value ]))
387+ await self ._pipe .flush ()
381388
382389 eoi = bool ((await self ._pipe .recv (1 ))[0 ] & 2 )
383390 if not to_eoi :
384391 eoi = True
385392
386- yield (await self .interface .recv (1 ))
393+ yield (await self ._pipe .recv (1 ))
387394
388395 async def send_to (self , address , data ):
389396 await self .cmd_talk (address )
@@ -394,13 +401,13 @@ async def send_to(self, address, data):
394401 async def read_from (self , address , * , to_eoi = True ):
395402 await self .cmd_listen (address )
396403 all = bytes ([])
397- async for data in self .recv (to_eoi = to_eoi ):
404+ async for data in self .read (to_eoi = to_eoi ):
398405 all += data
399406 return all
400407
401408 async def iter_from (self , address , * , to_eoi = True ):
402409 await self .cmd_listen (address )
403- async for data in self .recv (to_eoi = to_eoi ):
410+ async for data in self .read (to_eoi = to_eoi ):
404411 yield data
405412
406413 async def cmd_talk (self , address ):
0 commit comments