mod auipc;
mod branch;
mod channel;
mod ecall;
mod instruction;
mod jump;
mod memory;
mod opcode;
mod opcode_specific;
pub use auipc::*;
pub use branch::*;
pub use channel::*;
pub use ecall::*;
pub use instruction::*;
pub use jump::*;
pub use memory::*;
pub use opcode::*;
pub use opcode_specific::*;
use p3_util::indices_arr;
use sp1_derive::AlignedBorrow;
use std::mem::{size_of, transmute};
use crate::{
air::Word,
memory::{MemoryCols, MemoryReadCols, MemoryReadWriteCols},
};
pub const NUM_CPU_COLS: usize = size_of::<CpuCols<u8>>();
pub const CPU_COL_MAP: CpuCols<usize> = make_col_map();
#[derive(AlignedBorrow, Default, Debug, Clone, Copy)]
#[repr(C)]
pub struct CpuCols<T: Copy> {
pub shard: T,
pub channel: T,
pub nonce: T,
pub clk: T,
pub clk_16bit_limb: T,
pub clk_8bit_limb: T,
pub pc: T,
pub next_pc: T,
pub instruction: InstructionCols<T>,
pub channel_selectors: ChannelSelectorCols<T>,
pub selectors: OpcodeSelectorCols<T>,
pub op_a_access: MemoryReadWriteCols<T>,
pub op_b_access: MemoryReadCols<T>,
pub op_c_access: MemoryReadCols<T>,
pub opcode_specific_columns: OpcodeSpecificCols<T>,
pub is_real: T,
pub branching: T,
pub not_branching: T,
pub mem_value_is_neg: T,
pub unsigned_mem_val: Word<T>,
pub unsigned_mem_val_nonce: T,
pub ecall_mul_send_to_table: T,
pub is_sequential_instr: T,
}
impl<T: Copy> CpuCols<T> {
pub fn op_a_val(&self) -> Word<T> {
*self.op_a_access.value()
}
pub fn op_b_val(&self) -> Word<T> {
*self.op_b_access.value()
}
pub fn op_c_val(&self) -> Word<T> {
*self.op_c_access.value()
}
}
const fn make_col_map() -> CpuCols<usize> {
let indices_arr = indices_arr::<NUM_CPU_COLS>();
unsafe { transmute::<[usize; NUM_CPU_COLS], CpuCols<usize>>(indices_arr) }
}