Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: scroll-tech/ceno
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f75d5aef51faa46dccb2033ad410be6ea4f700c5
Choose a base ref
..
head repository: scroll-tech/ceno
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a77b5e907967484d410d0b85beb8794c5461aa88
Choose a head ref
Showing with 9 additions and 6 deletions.
  1. +7 −4 ceno_emul/src/platform.rs
  2. +2 −2 ceno_emul/tests/test_elf.rs
11 changes: 7 additions & 4 deletions ceno_emul/src/platform.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::BTreeSet, ops::Range};
use std::{collections::HashSet, ops::Range};

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

@@ -10,7 +10,7 @@ use crate::addr::{Addr, RegIdx};
#[derive(Clone, Debug)]
pub struct Platform {
pub rom: Range<Addr>,
pub prog_data: BTreeSet<Addr>,
pub prog_data: Option<HashSet<Addr>>,
pub stack: Range<Addr>,
pub heap: Range<Addr>,
pub public_io: Range<Addr>,
@@ -21,7 +21,7 @@ pub struct Platform {

pub const CENO_PLATFORM: Platform = Platform {
rom: 0x2000_0000..0x3000_0000,
prog_data: BTreeSet::new(),
prog_data: None, // This is an `Option` to allow `const` here.
stack: 0xB0000000..0xC0000000,
heap: 0x8000_0000..0xFFFF_0000,
public_io: 0x3000_1000..0x3000_2000,
@@ -37,7 +37,10 @@ impl Platform {
}

pub fn is_prog_data(&self, addr: Addr) -> bool {
self.prog_data.contains(&(addr & !0x3))
self.prog_data
.as_ref()
.map(|set| set.contains(&(addr & !0x3)))
.unwrap_or(false)
}

pub fn is_ram(&self, addr: Addr) -> bool {
4 changes: 2 additions & 2 deletions ceno_emul/tests/test_elf.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::Arc;
use std::{collections::HashSet, sync::Arc};

use anyhow::Result;
use ceno_emul::{
@@ -66,7 +66,7 @@ fn test_ceno_rt_io() -> Result<()> {
let program_elf = ceno_examples::ceno_rt_io;
let program = Program::load_elf(program_elf, u32::MAX)?;
let platform = Platform {
prog_data: program.image.keys().copied().collect(),
prog_data: Some(program.image.keys().copied().collect::<HashSet<u32>>()),
..CENO_PLATFORM
};
let mut state = VMState::new(platform, Arc::new(program));