pub struct Program {
pub calibrations: CalibrationSet,
pub frames: FrameSet,
pub memory_regions: BTreeMap<String, MemoryRegion>,
pub waveforms: BTreeMap<String, Waveform>,
pub instructions: Vec<Instruction>,
}
Expand description
A Quil Program instance describes a quantum program with metadata used in execution.
This contains not only instructions which are executed in turn on the quantum processor, but also the “headers” used to describe and manipulate those instructions, such as calibrations and frame definitions.
Fields§
§calibrations: CalibrationSet
§frames: FrameSet
§memory_regions: BTreeMap<String, MemoryRegion>
§waveforms: BTreeMap<String, Waveform>
§instructions: Vec<Instruction>
Implementations§
source§impl Program
impl Program
pub fn new() -> Self
sourcepub fn add_instruction(&mut self, instruction: Instruction)
pub fn add_instruction(&mut self, instruction: Instruction)
Add an instruction to the end of the program.
pub fn add_instructions(&mut self, instructions: Vec<Instruction>)
sourcepub fn expand_calibrations(&self) -> Result<Self>
pub fn expand_calibrations(&self) -> Result<Self>
Expand any instructions in the program which have a matching calibration, leaving the others unchanged. Recurses though each instruction while ensuring there is no cycle in the expansion graph (i.e. no calibration expands directly or indirectly into itself)
sourcepub fn from_instructions(instructions: Vec<Instruction>) -> Self
pub fn from_instructions(instructions: Vec<Instruction>) -> Self
Build a program from a list of instructions
sourcepub fn get_frames_for_instruction<'a>(
&'a self,
instruction: &'a Instruction,
include_blocked: bool
) -> Option<HashSet<&'a FrameIdentifier>>
pub fn get_frames_for_instruction<'a>( &'a self, instruction: &'a Instruction, include_blocked: bool ) -> Option<HashSet<&'a FrameIdentifier>>
Return the frames which are either “used” or “blocked” by the given instruction.
An instruction “uses” a frame if it plays on that frame; it “blocks” a frame if the instruction prevents other instructions from playing on that frame until complete.
Return None
if the instruction does not execute in the context of a frame - such
as classical instructions.
See the Quil-T spec for more information.
sourcepub fn get_used_qubits(&self) -> HashSet<Qubit>
pub fn get_used_qubits(&self) -> HashSet<Qubit>
Returns a HashSet consisting of every Qubit that is used in the program.
sourcepub fn into_simplified(&self) -> Result<Self>
pub fn into_simplified(&self) -> Result<Self>
Simplify this program into a new Program
which contains only instructions
and definitions which are executed; effectively, perform dead code removal.
Removes:
- All calibrations, following calibration expansion
- Frame definitions which are not used by any instruction such as
PULSE
orCAPTURE
- Waveform definitions which are not used by any instruction
When a valid program is simplified, it remains valid.