Assembly declaration
Assembly declarations can be used to add backend-specific (assembly) code to a cQASM circuit.
They are realized through an asm
declaration statement.
An asm
declaration statement consists of the keyword asm
with the identifier of the backend in parentheses,
followed by the backend code.
The latter is to be provided as a raw text string,
which consists of a raw text delimited by opening and closing triple quotes ('''
):
asm(
backend-identifier)
backend-code
Grammar for assembly declaration
assembly-declaration:
asm(
backend-identifier)
backend-code
backend-identifier:
identifier
backend-code:
raw-text-string
As part of a cQASM circuit, the contents of the raw text string will be passed verbatim to the backend and ignored by all other consumers of the circuit.
The location of the asm
declaration in the cQASM circuit is preserved,
i.e., no cQASM statements can be moved across it by any subsequent processing of the cQASM circuit.
This allows for the ability to embed backend code into cQASM
with the guarantee that the relative order between cQASM and backend code remains the same.
The following example shows how sections of code, specific to the example Backend
,
can be interlaced with cQASM statements: