Skip to content

Commit

Permalink
sync-platform: rename rom to prog_code
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurélien Nicolas committed Dec 12, 2024
1 parent 952da9c commit 1dfc478
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions ceno_emul/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::addr::{Addr, RegIdx};
/// - codes of environment calls.
#[derive(Clone, Debug)]
pub struct Platform {
pub rom: Range<Addr>, // TODO: rename.
pub prog_code: Range<Addr>,
pub ram: Range<Addr>, // TODO: remove.
pub prog_data: Option<HashSet<Addr>>,
pub stack: Range<Addr>,
Expand All @@ -21,7 +21,7 @@ pub struct Platform {
}

pub const CENO_PLATFORM: Platform = Platform {
rom: 0x2000_0000..0x3000_0000,
prog_code: 0x2000_0000..0x3000_0000,
ram: 0x8000_0000..0xFFFF_0000,
prog_data: None, // This is an `Option` to allow `const` here.
stack: 0xB0000000..0xC0000000,
Expand All @@ -35,7 +35,7 @@ impl Platform {
// Virtual memory layout.

pub fn is_rom(&self, addr: Addr) -> bool {
self.rom.contains(&addr)
self.prog_code.contains(&addr)
}

pub fn is_ram(&self, addr: Addr) -> bool {
Expand Down Expand Up @@ -74,7 +74,7 @@ impl Platform {
// Startup.

pub const fn pc_base(&self) -> Addr {
self.rom.start
self.prog_code.start
}

// Permissions.
Expand All @@ -84,7 +84,8 @@ impl Platform {
}

pub fn can_write(&self, addr: Addr) -> bool {
self.is_ram(addr) || self.is_pub_io(addr) || self.is_hints(addr)
// TODO: Remove is_rom (fails a unittest).
self.is_rom(addr) || self.is_ram(addr) || self.is_pub_io(addr) || self.is_hints(addr)
}

pub fn can_execute(&self, addr: Addr) -> bool {
Expand Down Expand Up @@ -131,8 +132,8 @@ mod tests {
// ROM and RAM do not overlap.
assert!(!p.is_rom(p.heap.start));
assert!(!p.is_rom(p.heap.end - WORD_SIZE as Addr));
assert!(!p.is_ram(p.rom.start));
assert!(!p.is_ram(p.rom.end - WORD_SIZE as Addr));
assert!(!p.is_ram(p.prog_code.start));
assert!(!p.is_ram(p.prog_code.end - WORD_SIZE as Addr));
// Registers do not overlap with ROM or RAM.
for reg in [
Platform::register_vma(0),
Expand Down
2 changes: 1 addition & 1 deletion ceno_zkvm/src/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub fn setup_platform(
};

Platform {
rom: program.base_address
prog_code: program.base_address
..program.base_address + (program.instructions.len() * WORD_SIZE) as u32,
prog_data: Some(prog_data),
stack,
Expand Down

0 comments on commit 1dfc478

Please sign in to comment.