Skip to content

Commit

Permalink
Merge pull request #58 from AtakTalay/30-implement-qoala-runtime
Browse files Browse the repository at this point in the history
Add rem instruction
  • Loading branch information
bvdvecht authored Aug 14, 2023
2 parents b274c72 + 26510c1 commit a21cfbc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions netqasm/backend/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,12 @@ def _compute_binary_classical_instr(
elif isinstance(instr, ins.core.SubmInstruction):
assert mod is not None
return (a - b) % mod
elif isinstance(instr, ins.core.MulInstruction):
return a * b
elif isinstance(instr, ins.core.DivInstruction):
return a // b
elif isinstance(instr, ins.core.RemInstruction):
return a % b
else:
raise ValueError(f"{instr} cannot be used as binary classical function")

Expand Down
6 changes: 6 additions & 0 deletions netqasm/lang/instr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,12 @@ class DivInstruction(ClassicalOpInstruction):
mnemonic: str = "div"


@dataclass
class RemInstruction(ClassicalOpInstruction):
id: int = 202
mnemonic: str = "rem"


@dataclass
class MeasInstruction(base.RegRegInstruction):
id: int = 32
Expand Down
1 change: 1 addition & 0 deletions netqasm/lang/instr/flavour.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class InstrMap:
core.SubmInstruction,
core.MulInstruction,
core.DivInstruction,
core.RemInstruction,
core.MeasInstruction,
core.MeasBasisInstruction,
core.CreateEPRInstruction,
Expand Down
1 change: 1 addition & 0 deletions netqasm/lang/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class GenericInstr(Enum):
SUBM = auto()
MUL = auto()
DIV = auto()
REM = auto()
# Single-qubit gates
X = auto()
Y = auto()
Expand Down

0 comments on commit a21cfbc

Please sign in to comment.