Skip to content

Updated asm_v2 to support jump instructions to addresses greater than 2048#371

Merged
meeg merged 16 commits intomainfrom
PR-63-tproc_v2-branch-instructions-immediate-address-value-is-limited-to-11-bits
Nov 3, 2025
Merged

Updated asm_v2 to support jump instructions to addresses greater than 2048#371
meeg merged 16 commits intomainfrom
PR-63-tproc_v2-branch-instructions-immediate-address-value-is-limited-to-11-bits

Conversation

@mmdiego
Copy link
Copy Markdown
Contributor

@mmdiego mmdiego commented Oct 21, 2025

Updated asm_v2 to support jump instructions (jump, call, conditional jump, close loop, wait, end) to addresses greater than 2048. Jump instructions with an immediate argument limit the argument to 11 bits; if the target label is more than 2048 lines into the program, the target address needs to be stored in a scratch register.

Since the program address of a label is not known until after macro expansion, and since replacing a jump-to-immediate with a jump-to-register adds an instruction, deciding which type of jump instruction to use needs to happen after macro expansion and needs to be done iteratively. This PR doesn't do that, and instead uses jump-to-register everywhere if the tProc program memory is more than 2048 words (in other words, if there is any possibility of exceeding the jump-to-immediate limit, whether or not that's actually happening). This adds extra instructions and execution time, but the impact should be negligible for typical programs.

We'll do this correctly later.

…anch instructions to addresses greater than 2048
@mmdiego mmdiego added this to the Next Release milestone Oct 21, 2025
@mmdiego mmdiego added enhancement New feature or request software Anything related to Jupyter/Python scripts labels Oct 21, 2025
@meeg
Copy link
Copy Markdown
Contributor

meeg commented Oct 21, 2025

At first glance . . . it looks like the if prog.p_addr >= 2**11: tests check whether the jump instruction is past line 2048, right? But the important test is whether the target label is past line 2048, isn't it?

@mmdiego
Copy link
Copy Markdown
Contributor Author

mmdiego commented Oct 21, 2025

At first glance . . . it looks like the if prog.p_addr >= 2**11: tests check whether the jump instruction is past line 2048, right? But the important test is whether the target label is past line 2048, isn't it?

Yes, I think you are right, I wanted to add a check to avoid using always the register (that was my first approach) I'll see if I can change it.

@mmdiego mmdiego marked this pull request as draft October 21, 2025 15:33
… if s15 should be used for branch instructions
…lue-is-limited-to-11-bits' of github.com:openquantumhardware/qick into PR-63-tproc_v2-branch-instructions-immediate-address-value-is-limited-to-11-bits
@meeg meeg changed the title Updated qick_lib to support branch instructions to addresses greater than 2048 Updated asm_v2 to support jump instructions to addresses greater than 2048 Oct 22, 2025
@mmdiego mmdiego marked this pull request as ready for review October 22, 2025 14:39
@mmdiego
Copy link
Copy Markdown
Contributor Author

mmdiego commented Oct 22, 2025

Replaced if prog.p_addr >= 2**11 with if prog.tproccfg['pmem_size'] > 2**11

We'll go with this solution for now and see if it can be improved later

@meeg meeg merged commit 6adbc0b into main Nov 3, 2025
3 checks passed
@meeg meeg deleted the PR-63-tproc_v2-branch-instructions-immediate-address-value-is-limited-to-11-bits branch November 3, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request software Anything related to Jupyter/Python scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants