Package: pyqcas
Python Quantum Control Architecture Simulator (PyQCAS)A Python-based, functional eQASM simulator without modeling timing behavior.PyQCAS was originally named as PyCACTUS.Installationpip install pyqcasUsagefrompyqcas.quantum_coprocessorimportQuantum_coprocessorqcas=Quantum_coprocessor()qcas.upload_program(<path-to-eqasm_file>)qcas.execute()result=qcas.read_result()The result returned is a binary block, which is the data in the memory of qcas.To inspect the progress of the simulation, you can use the following method:qcas.set_verbose(True)To inspect the execution trace, you can set the logging level:qcas.set_log_level(log_level=logging.DEBUG)Allowed logging levels includeDEBUG,INFO,WARNING,ERROR,CRITICAL.A brief introduction to eQASM:PyQCAS supports the eQASM instruction set architecture with a floating-point extension.
A formal definition of the eQASM architecture can be found ateQASM Specification.The following rules applies to eQASM:All characters are caseinsensitive, and extra blank is allowed between two identifiers.hash mark (#) starts the line comment.An overview of eQASM instructions is listed in the following table:NOTE, being a functional simulator, PyQCAS does not model the timing of quantum instructions. AllQWAIT(R)instructions and the pre-intervals of quantum bundles are omitted during the simulation.ForQ_Ops in the quantum bundle, PyQCAS also pre-defines a set of quantum operations as following:NameNumber of Target QubitsDescriptionH1Hadamard gateX1$R_x(\pi)$Y1$R_y(\pi)$Z1$R_z(\pi)$S1$R_z(\frac{\pi}{2})$Sdg1$R_z(-\frac{\pi}{2})$T1$R_z(\frac{\pi}{4})$Tdg1$R_z(-\frac{\pi}{4})$X$\theta$1$R_x(\frac{\pi\theta}{180})$Y$\theta$1$R_y(\frac{\pi\theta}{180})$Z$\theta$1$R_z(\frac{\pi\theta}{180})$Xm$\theta$1$R_x(-\frac{\pi\theta}{180})$Ym$\theta$1$R_y(-\frac{\pi\theta}{180})$Zm$\theta$1$R_z(-\frac{\pi\theta}{180})$RX$\theta$1the same as X$\theta$RY$\theta$1the same as Y$\theta$RZ$\theta$1the same as Z$\theta$CZ2Controlled Phase gatemeasure1MeasureNote:$\theta$ is a floating point value in $[0, 180]$,  of which the decimal point is replaced by_. For example,X175_5represents $R_x(\frac{\pi\cdot 175.5}{180})$,Xm175_5represents $R_x(-\frac{\pi\cdot 175.5}{180})$.Since eQASM does not support floating point values, which might be required by the quantum program, PyQCAS also support an extension with the following FP instructions:Formatformal definitionexplanationFCVT.W.S rd, fsR[rd](31:0) = integer(F[fs])Convert the 32-bit FP number in fs into a 32-bit signed integer, and store it in rd.FCVT.S.W fd, rsF[fd] = float(R[rs](31:0))Convert a 32-bit signed integer in rs into a 32-bit FP number, and store it in fd.FLW fd, imm(rs)F[fd] <- memory(R[rs] + imm)Load a 32-bit FP number from the memory addressimm + rsand store it to the FPRfd.FSW fs, imm(rs)F[fs] -> memory(R[rs] + imm)Store a 32-bit FP number from the FPRfsto the memory addressimm + rs.FADD.S fd, fs, ftF[fd] = F[fs] + F[ft]Floating point addition.FSUB.S fd, fs, ftF[fd] = F[fs] - F[ft]Floating point subtraction.FMUL.S fd, fs, ftF[fd] = F[fs] * F[ft]Floating point multiplication.FDIV.S fd, fs, ftF[fd] = F[fs] / F[ft]Floating point division.FEQ.S rd, fs, ftR[rd] = F[fs] > F[ft]Set rd whenfsis equal toft.FLT.S rd, fs, ftR[rd] = F[fs] < F[ft]Set rd whenfsis less thanft.FLE.S rd, fs, ftR[rd] = F[fs] <= F[ft]Set rd whenfsis less equal toft.FMV.X.W rd, fsR[rd] = F[fs]moves the single-precision value in FPRfsrepresented in IEEE 754-2008 encoding to the lower 32 bits of GPRrd.  NOTE: this is a direct, bit-wise move.FMV.W.X fd, rsF[fd] = R[rs]moves the single-precision value encoded in IEEE 754-2008 standard encoding from the lower 32 bits of GPRrsto the FPRfd.  NOTE: this is a direct, bit-wise move.