Skip to content

Commit

Permalink
skip PCS of range table #789: merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
10to4 committed Jan 8, 2025
2 parents 430ea83 + b60c6fe commit e7cbf23
Show file tree
Hide file tree
Showing 44 changed files with 1,113 additions and 2,516 deletions.
28 changes: 22 additions & 6 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[workspace]
exclude = ["examples"]
members = [
"ceno_emul",
"ceno_host",
"ceno_rt",
"ceno_zkvm",
"examples-builder",
"examples",
"mpcs",
"multilinear_extensions",
"poseidon",
Expand Down
1 change: 1 addition & 0 deletions ceno_emul/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ version.workspace = true

[dependencies]
anyhow.workspace = true
ceno_rt = { path = "../ceno_rt" }
elf = "0.7"
itertools.workspace = true
num-derive.workspace = true
Expand Down
14 changes: 13 additions & 1 deletion ceno_emul/src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern crate alloc;

use alloc::collections::BTreeMap;

use crate::{addr::WORD_SIZE, disassemble::transpile, rv32im::Instruction};
use crate::{CENO_PLATFORM, addr::WORD_SIZE, disassemble::transpile, rv32im::Instruction};
use anyhow::{Context, Result, anyhow, bail};
use elf::{
ElfBytes,
Expand All @@ -40,6 +40,17 @@ pub struct Program {
pub image: BTreeMap<u32, u32>,
}

impl From<&[Instruction]> for Program {
fn from(insn_codes: &[Instruction]) -> Program {
Self {
entry: CENO_PLATFORM.pc_base(),
base_address: CENO_PLATFORM.pc_base(),
instructions: insn_codes.to_vec(),
image: Default::default(),
}
}
}

impl Program {
/// Create program
pub fn new(
Expand All @@ -55,6 +66,7 @@ impl Program {
image,
}
}

/// Initialize a RISC Zero Program from an appropriate ELF file
pub fn load_elf(input: &[u8], max_mem: u32) -> Result<Program> {
let mut instructions: Vec<u32> = Vec::new();
Expand Down
23 changes: 22 additions & 1 deletion ceno_emul/src/platform.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{collections::BTreeSet, ops::Range};
use core::fmt::{self, Formatter};
use std::{collections::BTreeSet, fmt::Display, ops::Range};

use crate::addr::{Addr, RegIdx};

Expand All @@ -19,6 +20,26 @@ pub struct Platform {
pub unsafe_ecall_nop: bool,
}

impl Display for Platform {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let prog_data: Option<Range<Addr>> = match (self.prog_data.first(), self.prog_data.last()) {
(Some(first), Some(last)) => Some(*first..*last),
_ => None,
};
write!(
f,
"Platform {{ rom: {:?}, prog_data: {:?}, stack: {:?}, heap: {:?}, public_io: {:?}, hints: {:?}, unsafe_ecall_nop: {} }}",
self.rom,
prog_data,
self.stack,
self.heap,
self.public_io,
self.hints,
self.unsafe_ecall_nop
)
}
}

pub const CENO_PLATFORM: Platform = Platform {
rom: 0x2000_0000..0x3000_0000,
prog_data: BTreeSet::new(),
Expand Down
2 changes: 1 addition & 1 deletion ceno_emul/src/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod keccak_permute;
// Using the same function codes as sp1:
// https://github.com/succinctlabs/sp1/blob/013c24ea2fa15a0e7ed94f7d11a7ada4baa39ab9/crates/core/executor/src/syscalls/code.rs

pub const KECCAK_PERMUTE: u32 = 0x00_01_01_09;
pub use ceno_rt::syscalls::KECCAK_PERMUTE;

/// Trace the inputs and effects of a syscall.
pub fn handle_syscall(vm: &VMState, function_code: u32) -> Result<SyscallEffects> {
Expand Down
13 changes: 9 additions & 4 deletions ceno_host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,19 @@ impl Items {
}
}

impl From<&CenoStdin> for Vec<u32> {
fn from(stdin: &CenoStdin) -> Vec<u32> {
impl From<&CenoStdin> for Vec<u8> {
fn from(stdin: &CenoStdin) -> Vec<u8> {
let mut items = Items::default();
for item in &stdin.items {
items.append(Item::from(item));
}
items
.finalise()
items.finalise()
}
}

impl From<&CenoStdin> for Vec<u32> {
fn from(stdin: &CenoStdin) -> Vec<u32> {
Vec::<u8>::from(stdin)
.into_iter()
.tuples()
.map(|(a, b, c, d)| u32::from_le_bytes([a, b, c, d]))
Expand Down
Loading

0 comments on commit e7cbf23

Please sign in to comment.