Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions crates/ppvm-vihaco/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ num = "0.4.3"
rayon = { version = "1.10", optional = true }
ppvm-tableau = { version = "0.1.0", path = "../ppvm-tableau" }
smallvec = "1.15.1"
vihaco = "0.4.0"
vihaco-cpu = "0.4.0"
vihaco-parser = "0.4.0"
vihaco-parser-derive = "0.4.0"
vihaco = "0.4.1"
vihaco-cpu = "0.4.1"
vihaco-parser = "0.4.1"
vihaco-parser-derive = "0.4.1"
vihaco-circuit-isa = { version = "0.1.0", path = "../vihaco-circuit-isa" }
ppvm-pauli-sum = { version = "0.1.0", path = "../ppvm-pauli-sum" }
65 changes: 65 additions & 0 deletions crates/ppvm-vihaco/tests/arithmetic.sst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
device circuit.n_qubits 1;

// Binary arithmetic pushes operands in source order: lhs, then rhs.
// The CPU pops rhs first and lhs second before applying the operation.
fn @main() {
cpu::cpu.const u64, 10
cpu::cpu.const u64, 3
cpu::cpu.sub u64
cpu::cpu.const u64, 7
cpu::cpu.eq u64
cpu::cpu.cond_br @check_div, @fail_sub

cpu::cpu.label @check_div
cpu::cpu.const u64, 10
cpu::cpu.const u64, 3
cpu::cpu.div u64
cpu::cpu.const u64, 3
cpu::cpu.eq u64
cpu::cpu.cond_br @check_rem, @fail_div

cpu::cpu.label @check_rem
cpu::cpu.const u64, 10
cpu::cpu.const u64, 3
cpu::cpu.rem u64
cpu::cpu.const u64, 1
cpu::cpu.eq u64
cpu::cpu.cond_br @check_mul, @fail_rem

cpu::cpu.label @check_mul
cpu::cpu.const u64, 10
cpu::cpu.const u64, 3
cpu::cpu.mul u64
cpu::cpu.const u64, 30
cpu::cpu.eq u64
cpu::cpu.cond_br @check_add, @fail_mul

cpu::cpu.label @check_add
cpu::cpu.const u64, 10
cpu::cpu.const u64, 3
cpu::cpu.add u64
cpu::cpu.const u64, 13
cpu::cpu.eq u64
cpu::cpu.cond_br @success, @fail_add

cpu::cpu.label @fail_sub
cpu::cpu.br @fail
cpu::cpu.label @fail_div
cpu::cpu.br @fail
cpu::cpu.label @fail_rem
cpu::cpu.br @fail
cpu::cpu.label @fail_mul
cpu::cpu.br @fail
cpu::cpu.label @fail_add
cpu::cpu.br @fail

cpu::cpu.label @fail
cpu::cpu.const u64, 0
circuit::circuit.x
cpu::cpu.br @success

cpu::cpu.label @success
cpu::cpu.const u64, 0
circuit::circuit.measure
cpu::cpu.ret 0
}
13 changes: 13 additions & 0 deletions crates/ppvm-vihaco/tests/sst_fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ fn hello_circuit_sst_parses_and_runs() {
assert_eq!(machine.measurement_record().len(), 0);
}

#[test]
fn arithmetic_sst_uses_lhs_then_rhs_order() {
let machine = ppvm_vihaco::run_file("tests/arithmetic.sst")
.unwrap_or_else(|e| panic!("run arithmetic.sst: {e:?}"));
let record = machine.measurement_record();
assert_eq!(record.len(), 1, "expected exactly one measurement");
assert_eq!(
record[0].as_slice(),
&[MeasurementOutcome::Zero],
"all arithmetic checks should pass without flipping q0"
);
}

#[test]
fn rotxy_sst_runs_and_flips_qubit() {
// `rotxy.sst` applies R(axis_angle=π/2, θ=π) = RY(π) to q0, deterministically
Expand Down
4 changes: 2 additions & 2 deletions crates/vihaco-circuit-isa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2024"
chumsky = "0.10"
eyre = "0.6.12"
smallvec = "1.15.1"
vihaco = "0.4.0"
vihaco-parser = "0.4.0"
vihaco = "0.4.1"
vihaco-parser = "0.4.1"

[package.metadata.cargo-machete]
ignored = ["eyre", "vihaco-parser"] # transitive dependency in vihaco, somehow not handled correctly by machete
Loading