Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/guest-example-mem-fixes: working fibonacci program #586

Closed
wants to merge 7 commits into from
28 changes: 22 additions & 6 deletions ceno_emul/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ pub struct Platform {
}

pub const CENO_PLATFORM: Platform = Platform {
rom_start: 0x2000_0000,
rom_end: 0x3000_0000 - 1,
ram_start: 0x0020_0000,
ram_end: 0x0040_0000 - 1,
unsafe_ecall_nop: false,
// rom_start: 0x2000_0000,
// rom_end: 0x3000_0000 - 1,
// ram_start: 0x0020_0000,
// ram_end: 0x0040_0000 - 1,
// unsafe_ecall_nop: false,

// SP1
rom_start: 0x0020_0800,
rom_end: 0x0020a110 - 1,
ram_start: 0x0001_0000,
ram_end: 0x8001_0000 - 1,
unsafe_ecall_nop: true,
};

impl Platform {
Expand Down Expand Up @@ -118,7 +125,7 @@ impl Platform {
}

pub fn can_execute(&self, addr: Addr) -> bool {
self.is_rom(addr)
true // self.is_rom(addr)
}

// Environment calls.
Expand Down Expand Up @@ -147,6 +154,15 @@ impl Platform {
pub const fn code_success(&self) -> u32 {
0
}

pub fn format_segment(&self, addr: u32) -> String {
format!(
"{}{}{}",
if self.can_read(addr) { "R" } else { "-" },
if self.can_write(addr) { "W" } else { "-" },
if self.can_execute(addr) { "X" } else { "-" },
)
}
}

#[cfg(test)]
Expand Down
8 changes: 1 addition & 7 deletions ceno_zkvm/examples/fibonacci_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,7 @@ fn main() {
.with(flame_layer.with_threads_collapsed(true));
tracing::subscriber::set_global_default(subscriber).unwrap();

let sp1_platform = Platform {
rom_start: 0x0020_0800,
rom_end: 0x003f_ffff,
ram_start: 0x0020_0000,
ram_end: 0xffff_ffff,
unsafe_ecall_nop: true,
};
let sp1_platform = CENO_PLATFORM.clone();
const STACK_TOP: u32 = 0x0020_0400;
const STACK_SIZE: u32 = 1;

Expand Down