Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
26743e1
initial picus backend for Ziren
shankarapailoor Sep 25, 2025
f51e0a4
adding comment describing PicusInfo for AddSub
shankarapailoor Sep 25, 2025
c04256b
adding readme
shankarapailoor Sep 25, 2025
3d1257a
adding macro to derive PicusInfo
shankarapailoor Oct 3, 2025
4354a77
removing outdated comment
shankarapailoor Oct 3, 2025
73e6556
determining inputs/outputs through interactions
shankarapailoor Oct 3, 2025
448eff9
misc picus support changes
shankarapailoor Feb 5, 2026
5be5d16
rebased
shankarapailoor Feb 5, 2026
9b6e4d1
adding symbolic and concrete pending tasks
shankarapailoor Feb 9, 2026
88c8cb2
fixing unused import and formatting issues
shankarapailoor Feb 9, 2026
4d70a4e
clippy fixes
shankarapailoor Feb 9, 2026
e666580
removing picus out files
shankarapailoor Feb 9, 2026
83fc16f
format fix
shankarapailoor Feb 9, 2026
3bd174f
format fix
shankarapailoor Feb 9, 2026
bf0f855
clippy fixes
shankarapailoor Feb 9, 2026
f9b856d
fixing clippy warning
shankarapailoor Feb 9, 2026
17f4588
adding back selector post-conditions and checking one hot constraints…
shankarapailoor Mar 2, 2026
516429f
fixing fmt and clippy warnings
shankarapailoor Mar 2, 2026
e2c478d
refactor picus backend
shankarapailoor Mar 3, 2026
434b6a8
adding readme
shankarapailoor Mar 3, 2026
d62f0c1
fixing clippy warnings
shankarapailoor Mar 3, 2026
dec7cdf
updating dependency in Cargo lock
shankarapailoor Mar 3, 2026
9088e32
removing is_real from a selector in Sll
shankarapailoor Mar 5, 2026
651d2af
refactoring the extractor and fixing errors with how flags in receive…
shankarapailoor Mar 9, 2026
ea101fb
additional cleanup
shankarapailoor Mar 9, 2026
09b99df
fixing formatting
shankarapailoor Mar 9, 2026
f72af2c
applying additional fixes
shankarapailoor Mar 10, 2026
bc31f4c
fixing cargo fmt issue
shankarapailoor Mar 10, 2026
16a57c7
deleting character from comment
shankarapailoor Mar 10, 2026
d8d1811
op_a should be immutable for teq
shankarapailoor Mar 10, 2026
a24af66
syncing with stephens updates
shankarapailoor Mar 11, 2026
72295f0
removing redundant constraint added during debugging
shankarapailoor Mar 11, 2026
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
78 changes: 76 additions & 2 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"crates/cuda",
"crates/curves",
"crates/derive",
"crates/picus",
"crates/primitives",
"crates/prover",
"crates/recursion/circuit",
Expand Down Expand Up @@ -115,6 +116,7 @@ zkm-build = { path = "crates/build" }
zkm-sdk = { path = "crates/sdk" }
zkm-cuda = { path = "crates/cuda" }
zkm-verifier = { path = "crates/verifier" }
zkm-picus = {path = "crates/picus"}

zkm-lib = { path = "crates/zkvm/lib", default-features = false }
zkm-zkvm = { path = "crates/zkvm/entrypoint", default-features = false }
Expand Down
3 changes: 3 additions & 0 deletions crates/core/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ vec_map = { version = "0.8.2", features = ["serde"] }
enum-map = { version = "2.7.3", features = ["serde"] }
sha2 = { workspace = true }
anyhow = { workspace = true }
tracing-subscriber = "0.3.19"
env_logger = "0.11.6"
num_enum = "0.7.5"

[dev-dependencies]
test-artifacts = { path = "../../test-artifacts" }
Expand Down
2 changes: 1 addition & 1 deletion crates/core/executor/src/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub enum MipsAirId {
SyscallInstrs = 38,
/// The MemoryInstructionChip.
MemoryInstrs = 39,
/// The MiscInstructionChip.
/// The MiscInstrsChip.
MiscInstrs = 40,
/// The memory global init chip.
MemoryGlobalInit = 41,
Expand Down
14 changes: 13 additions & 1 deletion crates/core/executor/src/opcode.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
//! Opcodes for ZKM.

use enum_map::Enum;
use num_enum::TryFromPrimitive;
use p3_field::Field;
use serde::{Deserialize, Serialize};
use std::fmt::Display;

/// An opcode (short for "operation code") specifies the operation to be performed by the processor.
#[allow(non_camel_case_types)]
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, PartialOrd, Ord, Enum,
TryFromPrimitive,
Debug,
Clone,
Copy,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize,
PartialOrd,
Ord,
Enum,
)]
#[repr(u8)]
pub enum Opcode {
Expand Down
3 changes: 3 additions & 0 deletions crates/core/machine/include/cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ __ZKM_HOSTDEV__ void event_to_row(

populate_instruction<F>(cols.instruction, instruction);

// TEQ is a read-only instruction: it compares two registers and traps if equal,
// but must not modify register A. Mark it immutable to prevent register writes.
cols.op_a_immutable = F::from_bool(
is_memory_store_instruction_except_sc(instruction)
|| is_branch_instruction(instruction)
|| instruction.opcode == Opcode::TEQ
);

cols.is_rw_a = F::from_bool(is_rw_a_instruction(instruction));
Expand Down
11 changes: 8 additions & 3 deletions crates/core/machine/src/alu/add_sub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use zkm_core_executor::{
events::{AluEvent, ByteLookupEvent, ByteRecord},
ExecutionRecord, Opcode, Program,
};
use zkm_derive::AlignedBorrow;
use zkm_derive::{AlignedBorrow, PicusAnnotations};
use zkm_stark::{
air::{MachineAir, ZKMAirBuilder},
air::{MachineAir, PicusInfo, ZKMAirBuilder},
Word,
};

Expand All @@ -38,7 +38,7 @@ pub const NUM_ADD_SUB_COLS: usize = size_of::<AddSubCols<u8>>();
pub struct AddSubChip;

/// The column layout for the chip.
#[derive(AlignedBorrow, Default, Clone, Copy)]
#[derive(AlignedBorrow, PicusAnnotations, Default, Clone, Copy)]
#[repr(C)]
pub struct AddSubCols<T> {
/// The current/next pc, used for instruction lookup table.
Expand All @@ -56,9 +56,11 @@ pub struct AddSubCols<T> {
pub operand_2: Word<T>,

/// Flag indicating whether the opcode is `ADD`.
#[picus(selector)]
pub is_add: T,

/// Flag indicating whether the opcode is `SUB`.
#[picus(selector)]
pub is_sub: T,
}

Expand All @@ -78,6 +80,9 @@ impl<F: PrimeField32> MachineAir<F> for AddSubChip {
next_power_of_two(input.add_sub_events.len(), input.fixed_log2_rows::<F, _>(self));
Some(nb_rows)
}
fn picus_info(&self) -> PicusInfo {
AddSubCols::<u8>::picus_info()
}

fn generate_trace(
&self,
Expand Down
14 changes: 11 additions & 3 deletions crates/core/machine/src/alu/bitwise/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use zkm_core_executor::{
events::{AluEvent, ByteLookupEvent, ByteRecord},
ByteOpcode, ExecutionRecord, Opcode, Program,
};
use zkm_derive::AlignedBorrow;
use zkm_derive::{AlignedBorrow, PicusAnnotations};
use zkm_stark::{
air::{MachineAir, ZKMAirBuilder},
air::{MachineAir, PicusInfo, ZKMAirBuilder},
Word,
};

Expand All @@ -29,7 +29,7 @@ pub const NUM_BITWISE_COLS: usize = size_of::<BitwiseCols<u8>>();
pub struct BitwiseChip;

/// The column layout for the chip.
#[derive(AlignedBorrow, Default, Clone, Copy)]
#[derive(AlignedBorrow, PicusAnnotations, Default, Clone, Copy)]
#[repr(C)]
pub struct BitwiseCols<T> {
/// The current/next pc, used for instruction lookup table.
Expand All @@ -46,15 +46,19 @@ pub struct BitwiseCols<T> {
pub c: Word<T>,

/// If the opcode is NOR.
#[picus(selector)]
pub is_nor: T,

/// If the opcode is XOR.
#[picus(selector)]
pub is_xor: T,

// If the opcode is OR.
#[picus(selector)]
pub is_or: T,

/// If the opcode is AND.
#[picus(selector)]
pub is_and: T,
}

Expand All @@ -69,6 +73,10 @@ impl<F: PrimeField32> MachineAir<F> for BitwiseChip {
"Bitwise".to_string()
}

fn picus_info(&self) -> PicusInfo {
BitwiseCols::<u8>::picus_info()
}

fn generate_trace(
&self,
input: &ExecutionRecord,
Expand Down
12 changes: 9 additions & 3 deletions crates/core/machine/src/alu/clo_clz/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use zkm_core_executor::{
events::{ByteLookupEvent, ByteRecord},
ByteOpcode, ExecutionRecord, Opcode, Program,
};
use zkm_derive::AlignedBorrow;
use zkm_stark::{air::MachineAir, Word};
use zkm_derive::{AlignedBorrow, PicusAnnotations};
use zkm_stark::{air::MachineAir, PicusInfo, Word};

use crate::{air::ZKMCoreAirBuilder, utils::pad_rows_fixed, CoreChipError};

Expand All @@ -39,7 +39,7 @@ const BYTE_SIZE: usize = 8;
pub struct CloClzChip;

/// The column layout for the chip.
#[derive(AlignedBorrow, Default, Debug, Clone, Copy)]
#[derive(AlignedBorrow, PicusAnnotations, Default, Debug, Clone, Copy)]
#[repr(C)]
pub struct CloClzCols<T> {
/// The current/next pc, used for instruction lookup table.
Expand All @@ -63,9 +63,11 @@ pub struct CloClzCols<T> {
pub sr1: Word<T>,

/// Flag to indicate whether the opcode is CLZ.
#[picus(selector)]
pub is_clz: T,

/// Flag to indicate whether the opcode is CLO.
#[picus(selector)]
pub is_clo: T,

/// Selector to know whether this row is enabled.
Expand All @@ -83,6 +85,10 @@ impl<F: PrimeField32> MachineAir<F> for CloClzChip {
"CloClz".to_string()
}

fn picus_info(&self) -> PicusInfo {
CloClzCols::<u8>::picus_info()
}

fn generate_trace(
&self,
input: &ExecutionRecord,
Expand Down
Loading