Skip to content

Commit

Permalink
feat(spec): introduce Skip mop (#64)
Browse files Browse the repository at this point in the history
* feat(spec): introduce Skip mop

See CQCL/pytket-phir#138

* feat(model): add validation for MOps
  • Loading branch information
qartik authored Feb 29, 2024
1 parent 2ef469f commit d079bdd
Show file tree
Hide file tree
Showing 3 changed files with 293 additions and 62 deletions.
37 changes: 34 additions & 3 deletions phir/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ def check_angles(self: TQOp) -> TQOp:
return self


QOp: TypeAlias = MeasOp | SQOp | TQOp

# Classical Operations


class COp(Op):
"""Classical operation."""

Expand Down Expand Up @@ -250,18 +255,44 @@ class FFCall(Op):
args: list[int | Sym | COp | Bit]


# Machine Operations

Duration = NewType("Duration", tuple[float, Literal["s", "ms", "us", "ns"]])


class MOp(Op):
class MOp(Op, abc.ABC):
"""Machine operation."""

model_config = ConfigDict(extra="forbid")

mop: str
args: list[Bit] | None = None
duration: Duration | None = None


QOp: TypeAlias = MeasOp | SQOp | TQOp
OpType: TypeAlias = FFCall | COp | QOp | MOp | Barrier
class IdleMOp(MOp):
"""Idle machine op."""

mop: Literal["Idle"]
args: list[Bit]
duration: Duration


class TransportMOp(MOp):
"""Transport machine op."""

mop: Literal["Transport"]
duration: Duration


class SkipMOp(MOp):
"""Skip machine op."""

mop: Literal["Skip"]


MOpType: TypeAlias = IdleMOp | TransportMOp | SkipMOp
OpType: TypeAlias = FFCall | COp | QOp | MOpType | Barrier


# Blocks
Expand Down
Loading

0 comments on commit d079bdd

Please sign in to comment.