qibolab
qibolab copied to clipboard
Q1ASM parse and generation
Attempting a complete parser and reconstructor for Q1ASM.
- [x] grammar to parse Q1ASM
- [x] transform to native classes
- [ ] reconstruct Q1ASM
- [ ] add instructions documentation
- [ ] add Q1 execution time
- the case of conditional jumps can't be fully worked out statically
- [ ] parse & dump register to
int
- remove/add initial
R
- remove/add initial
- [ ] add references (parse & dump)
- as special immediates
- remove/add initial
@
- [ ] format with labels
- [ ] format comments
Codecov Report
Attention: Patch coverage is 83.21429%
with 47 lines
in your changes missing coverage. Please review.
Project coverage is 54.79%. Comparing base (
4128ac7
) to head (05371b3
). Report is 10 commits behind head on main.
Files with missing lines | Patch % | Lines |
---|---|---|
src/qibolab/_core/instruments/qblox/ast_.py | 81.85% | 47 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #868 +/- ##
==========================================
+ Coverage 51.95% 54.79% +2.83%
==========================================
Files 63 66 +3
Lines 2808 3088 +280
==========================================
+ Hits 1459 1692 +233
- Misses 1349 1396 +47
Flag | Coverage Δ | |
---|---|---|
unittests | 54.79% <83.21%> (+2.83%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This is the current state:
[ins] In [1]: from qibolab._core.instruments.qblox.parse import parse
...: from pathlib import Path
...: from rich import print
...: basic = Path("tests/qblox/q1asm/basic.q1asm")
...: prog = parse(basic.read_text())
...: print(prog)
Program(
elements=[
'Basic example from docs\nhttps://qblox-qblox-instruments.readthedocs-hosted.com/en/main/tutorials/q1asm_tutorials/basic/baseband/basic_sequencing.html#Create-Q1ASM-program',
Line(Move(source='100', destination='R0'), comment='Loop iterator.'),
Line(Move(source='20', destination='R1'), comment='Initial wait period in ns.'),
Line(WaitSync(duration='4'), comment='Wait for sequencers to synchronize and then wait another 4 ns.'),
Line(SetMrk(mask='1'), label='loop', comment='Set marker output 1.'),
Line(Play(wave_0='0', wave_1='1', duration=4), comment='Play a gaussian and a block on output path 0 and 1 respectively and wait 4 ns.'),
Line(SetMrk(mask='0'), comment='Reset marker output 1.'),
Line(UpdParam(duration=18), comment='Update parameters and wait the remaining 18 ns of the waveforms.'),
Line(Wait(duration='R1'), comment='Wait period.'),
Line(Play(wave_0='1', wave_1='0', duration=22), comment='Play a block and a gaussian on output path 0 and 1 respectively and wait 22 ns.'),
Line(Wait(duration='1000'), comment='Wait a 1us in between iterations.'),
Line(Add(a='R1', b='20', destination='R1'), comment='Increase wait period by 20 ns.'),
Line(Loop(a='R0', address='@loop'), comment='Subtract one from loop iterator.'),
Line(Stop(), comment='Stop the sequence after the last iteration.')
]
)
[ins] In [2]: print(prog.asm(60))
# Basic example from docs
# https://qblox-qblox-instruments.readthedocs-hosted.com/en/main/tutorials/q1asm_tutorials/basic/baseband/basic_sequencing.html#Create-Q1ASM-program
move 100 R0 # Loop iterator.
move 20 R1 # Initial wait period in ns.
wait_sync 4 # Wait for sequencers to synchronize and
# then wait another 4 ns.
loop set_mrk 1 # Set marker output 1.
play 0 1 4 # Play a gaussian and a block on output
# path 0 and 1 respectively and wait 4
# ns.
set_mrk 0 # Reset marker output 1.
upd_param 18 # Update parameters and wait the
# remaining 18 ns of the waveforms.
wait R1 # Wait period.
play 1 0 22 # Play a block and a gaussian on output
# path 0 and 1 respectively and wait 22
# ns.
wait 1000 # Wait a 1us in between iterations.
add R1 20 R1 # Increase wait period by 20 ns.
loop R0 @loop # Subtract one from loop iterator.
stop # Stop the sequence after the last
# iteration.
[ins] In [3]: print(prog.asm(60, comments=False))
move 100 R0
move 20 R1
wait_sync 4
loop set_mrk 1
play 0 1 4
set_mrk 0
upd_param 18
wait R1
play 1 0 22
wait 1000
add R1 20 R1
loop R0 @loop
stop