@@ -234,7 +234,7 @@ def parse_rxfifo_brackets(arg, fifo_dir):
234
234
235
235
max_delay = 2 ** (5 - sideset_count - sideset_enable ) - 1
236
236
assembled = []
237
- for line in instructions :
237
+ for line in instructions : # pylint: disable=too-many-nested-blocks
238
238
instruction = splitter (line .strip ())
239
239
delay = 0
240
240
if (
@@ -299,21 +299,32 @@ def parse_rxfifo_brackets(arg, fifo_dir):
299
299
assembled [- 1 ] |= num
300
300
assembled [- 1 ] |= 0b11 << 5 # JMPPIN wait source
301
301
else :
302
+ idx = 3
302
303
assembled [- 1 ] |= WAIT_SOURCES .index (instruction [2 ]) << 5
303
- num = int (instruction [3 ], 0 )
304
- if not 0 <= num <= 31 :
305
- raise RuntimeError ("Wait num out of range" )
304
+ if source == "irq" :
305
+ if instruction [idx ] == "next" :
306
+ require_version (1 , "wait irq next" )
307
+ assembled [- 1 ] |= 0b11000
308
+ idx += 1
309
+ elif instruction [idx ] == "prev" :
310
+ require_version (1 , "wait irq prev" )
311
+ assembled [- 1 ] |= 0b01000
312
+ idx += 1
313
+
314
+ limit = 8
315
+ # The flag index is decoded in the same way as the IRQ
316
+ # index field, decoding down from the two MSBs
317
+ if instruction [- 1 ] == "rel" :
318
+ if assembled [- 1 ] & 0b11000 :
319
+ raise RuntimeError ("cannot use next/prev with rel" )
320
+ assembled [- 1 ] |= 0b10000
321
+ else :
322
+ limit = 32
323
+ num = int_in_range (
324
+ instruction [idx ], 0 , limit , "wait {instruction[2]}"
325
+ )
306
326
assembled [- 1 ] |= num
307
- # The flag index is decoded in the same way as the IRQ
308
- # index field, decoding down from the two MSBs
309
- if instruction [- 1 ] == "next" :
310
- require_version (1 , "wait irq next" )
311
- assembled [- 1 ] |= 0b11000
312
- elif instruction [- 1 ] == "prev" :
313
- require_version (1 , "wait irq prev" )
314
- assembled [- 1 ] |= 0b01000
315
- elif instruction [- 1 ] == "rel" :
316
- assembled [- 1 ] |= 0b10000
327
+
317
328
elif instruction [0 ] == "in" :
318
329
# instr delay src count
319
330
assembled .append (0b010_00000_000_00000 )
@@ -352,15 +363,15 @@ def parse_rxfifo_brackets(arg, fifo_dir):
352
363
elif instruction [0 ] == "mov" :
353
364
# instr delay dst op src
354
365
if instruction [1 ].startswith ("rxfifo[" ): # mov rxfifo[], isr
355
- assembled .append (0b100_00000_0001_0_000 )
366
+ assembled .append (0b100_00000_0001_1_000 )
356
367
if instruction [2 ] != "isr" :
357
368
raise ValueError ("mov rxfifo[] source must be isr" )
358
- assembled [- 1 ] | = parse_rxfifo_brackets (instruction [1 ], "txput" )
369
+ assembled [- 1 ] ^ = parse_rxfifo_brackets (instruction [1 ], "txput" )
359
370
elif instruction [2 ].startswith ("rxfifo[" ): # mov osr, rxfifo[]
360
- assembled .append (0b100_00000_1001_0_000 )
371
+ assembled .append (0b100_00000_1001_1_000 )
361
372
if instruction [1 ] != "osr" :
362
373
raise ValueError ("mov ,rxfifo[] target must be osr" )
363
- assembled [- 1 ] | = parse_rxfifo_brackets (instruction [2 ], "txget" )
374
+ assembled [- 1 ] ^ = parse_rxfifo_brackets (instruction [2 ], "txget" )
364
375
else :
365
376
assembled .append (0b101_00000_000_00_000 )
366
377
assembled [- 1 ] |= mov_destinations .index (instruction [1 ]) << 5
@@ -388,30 +399,35 @@ def parse_rxfifo_brackets(arg, fifo_dir):
388
399
assembled .append (0b110_00000_0_0_0_00000 )
389
400
390
401
irq_type = 0
391
- if instruction [- 1 ] == "prev" :
402
+ idx = 1
403
+ if instruction [idx ] == "wait" :
404
+ assembled [- 1 ] |= 0x20
405
+ idx += 1
406
+ elif instruction [idx ] == "clear" :
407
+ assembled [- 1 ] |= 0x40
408
+ idx += 1
409
+
410
+ if instruction [idx ] == "prev" :
392
411
irq_type = 1
393
412
require_version (1 , "irq prev" )
394
- instruction . pop ()
395
- elif instruction [- 1 ] == "next" :
413
+ idx += 1
414
+ elif instruction [idx ] == "next" :
396
415
irq_type = 3
397
416
require_version (1 , "irq next" )
398
- instruction .pop ()
399
- elif instruction [- 1 ] == "rel" :
417
+ idx += 1
418
+
419
+ if instruction [- 1 ] == "rel" :
420
+ if irq_type != 0 :
421
+ raise RuntimeError ("cannot use next/prev with rel" )
400
422
irq_type = 2
401
423
instruction .pop ()
402
424
403
425
assembled [- 1 ] |= irq_type << 3
404
426
405
- num = int_in_range (instruction [- 1 ], 0 , 8 , "irq index" )
427
+ num = int_in_range (instruction [idx ], 0 , 8 , "irq index" )
406
428
assembled [- 1 ] |= num
407
429
instruction .pop ()
408
430
409
- if len (instruction ) > 1 : # after rel has been removed
410
- if instruction [- 1 ] == "wait" :
411
- assembled [- 1 ] |= 0x20
412
- elif instruction [- 1 ] == "clear" :
413
- assembled [- 1 ] |= 0x40
414
- # All other values are the default of set without waiting
415
431
elif instruction [0 ] == "set" :
416
432
# instr delay dst data
417
433
assembled .append (0b111_00000_000_00000 )
0 commit comments