mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-02 22:03:07 +00:00
Combine AND and OR flags in CpuStark
This commit is contained in:
parent
6f98fd7628
commit
ee9ce4c59d
@ -24,9 +24,8 @@ pub struct OpsColumnsView<T: Copy> {
|
||||
pub gt: T,
|
||||
pub eq: T, // Note: This column must be 0 when is_cpu_cycle = 0.
|
||||
pub iszero: T, // Note: This column must be 0 when is_cpu_cycle = 0.
|
||||
// TODO: combine AND, OR, and XOR into one flag
|
||||
pub and: T,
|
||||
pub or: T,
|
||||
// TODO: combine AND/OR, and XOR into one flag
|
||||
pub and_or: T,
|
||||
pub xor: T,
|
||||
pub not: T,
|
||||
pub byte: T,
|
||||
|
||||
@ -8,7 +8,7 @@ use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer
|
||||
use crate::cpu::columns::{CpuColumnsView, COL_MAP};
|
||||
use crate::cpu::kernel::aggregator::KERNEL;
|
||||
|
||||
const NATIVE_INSTRUCTIONS: [usize; 32] = [
|
||||
const NATIVE_INSTRUCTIONS: [usize; 31] = [
|
||||
COL_MAP.op.add,
|
||||
COL_MAP.op.mul,
|
||||
COL_MAP.op.sub,
|
||||
@ -23,8 +23,7 @@ const NATIVE_INSTRUCTIONS: [usize; 32] = [
|
||||
COL_MAP.op.gt,
|
||||
COL_MAP.op.eq,
|
||||
COL_MAP.op.iszero,
|
||||
COL_MAP.op.and,
|
||||
COL_MAP.op.or,
|
||||
COL_MAP.op.and_or,
|
||||
COL_MAP.op.xor,
|
||||
COL_MAP.op.not,
|
||||
COL_MAP.op.shl,
|
||||
|
||||
@ -83,11 +83,11 @@ fn ctl_data_ternops<F: Field>(ops: &[usize], is_shift: bool) -> Vec<Column<F>> {
|
||||
}
|
||||
|
||||
pub fn ctl_data_logic<F: Field>() -> Vec<Column<F>> {
|
||||
ctl_data_binops(&[COL_MAP.op.and, COL_MAP.op.or, COL_MAP.op.xor])
|
||||
ctl_data_binops(&[COL_MAP.op.and_or, COL_MAP.op.xor])
|
||||
}
|
||||
|
||||
pub fn ctl_filter_logic<F: Field>() -> Column<F> {
|
||||
Column::sum([COL_MAP.op.and, COL_MAP.op.or, COL_MAP.op.xor])
|
||||
Column::sum([COL_MAP.op.and_or, COL_MAP.op.xor])
|
||||
}
|
||||
|
||||
pub fn ctl_arithmetic_base_rows<F: Field>() -> TableWithColumns<F> {
|
||||
|
||||
@ -22,7 +22,7 @@ use crate::cpu::columns::{CpuColumnsView, COL_MAP};
|
||||
/// behavior.
|
||||
/// Note: invalid opcodes are not represented here. _Any_ opcode is permitted to decode to
|
||||
/// `is_invalid`. The kernel then verifies that the opcode was _actually_ invalid.
|
||||
const OPCODES: [(u8, usize, bool, usize); 37] = [
|
||||
const OPCODES: [(u8, usize, bool, usize); 36] = [
|
||||
// (start index of block, number of top bits to check (log2), kernel-only, flag column)
|
||||
(0x01, 0, false, COL_MAP.op.add),
|
||||
(0x02, 0, false, COL_MAP.op.mul),
|
||||
@ -38,8 +38,7 @@ const OPCODES: [(u8, usize, bool, usize); 37] = [
|
||||
(0x11, 0, false, COL_MAP.op.gt),
|
||||
(0x14, 0, false, COL_MAP.op.eq),
|
||||
(0x15, 0, false, COL_MAP.op.iszero),
|
||||
(0x16, 0, false, COL_MAP.op.and),
|
||||
(0x17, 0, false, COL_MAP.op.or),
|
||||
(0x16, 1, false, COL_MAP.op.and_or),
|
||||
(0x18, 0, false, COL_MAP.op.xor),
|
||||
(0x19, 0, false, COL_MAP.op.not),
|
||||
(0x1a, 0, false, COL_MAP.op.byte),
|
||||
|
||||
@ -33,8 +33,7 @@ const SIMPLE_OPCODES: OpsColumnsView<Option<u32>> = OpsColumnsView {
|
||||
gt: G_VERYLOW,
|
||||
eq: G_VERYLOW,
|
||||
iszero: G_VERYLOW,
|
||||
and: G_VERYLOW,
|
||||
or: G_VERYLOW,
|
||||
and_or: G_VERYLOW,
|
||||
xor: G_VERYLOW,
|
||||
not: G_VERYLOW,
|
||||
byte: G_VERYLOW,
|
||||
|
||||
@ -55,8 +55,7 @@ const STACK_BEHAVIORS: OpsColumnsView<Option<StackBehavior>> = OpsColumnsView {
|
||||
gt: BASIC_BINARY_OP,
|
||||
eq: BASIC_BINARY_OP,
|
||||
iszero: BASIC_UNARY_OP,
|
||||
and: BASIC_BINARY_OP,
|
||||
or: BASIC_BINARY_OP,
|
||||
and_or: BASIC_BINARY_OP,
|
||||
xor: BASIC_BINARY_OP,
|
||||
not: BASIC_UNARY_OP,
|
||||
byte: BASIC_BINARY_OP,
|
||||
|
||||
@ -103,8 +103,7 @@ pub(crate) fn ctl_looking_logic<F: Field>(i: usize) -> Vec<Column<F>> {
|
||||
let cols = KECCAK_SPONGE_COL_MAP;
|
||||
|
||||
let mut res = vec![
|
||||
Column::zero(), // is_and
|
||||
Column::zero(), // is_or
|
||||
Column::zero(), // is_and_or
|
||||
Column::one(), // is_xor
|
||||
];
|
||||
|
||||
|
||||
@ -53,8 +53,7 @@ pub(crate) mod columns {
|
||||
|
||||
pub fn ctl_data<F: Field>() -> Vec<Column<F>> {
|
||||
let mut res = vec![
|
||||
Column::single(columns::IS_AND),
|
||||
Column::single(columns::IS_OR),
|
||||
Column::sum([columns::IS_AND, columns::IS_OR]),
|
||||
Column::single(columns::IS_XOR),
|
||||
];
|
||||
res.extend(columns::limb_bit_cols_for_input(columns::INPUT0).map(Column::le_bits));
|
||||
|
||||
@ -160,8 +160,9 @@ fn fill_op_flag<F: Field>(op: Operation, row: &mut CpuColumnsView<F>) {
|
||||
Operation::Not => &mut flags.not,
|
||||
Operation::Syscall(_, _, _) => &mut flags.syscall,
|
||||
Operation::Eq => &mut flags.eq,
|
||||
Operation::BinaryLogic(logic::Op::And) => &mut flags.and,
|
||||
Operation::BinaryLogic(logic::Op::Or) => &mut flags.or,
|
||||
Operation::BinaryLogic(logic::Op::And) | Operation::BinaryLogic(logic::Op::Or) => {
|
||||
&mut flags.and_or
|
||||
}
|
||||
Operation::BinaryLogic(logic::Op::Xor) => &mut flags.xor,
|
||||
Operation::BinaryArithmetic(arithmetic::BinaryOperator::Add) => &mut flags.add,
|
||||
Operation::BinaryArithmetic(arithmetic::BinaryOperator::Mul) => &mut flags.mul,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user