Skip to content

Commit

Permalink
Move as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasgoergens committed Dec 12, 2024
1 parent 572cd22 commit 02f0828
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
7 changes: 3 additions & 4 deletions ceno_emul/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ mod vm_state;
pub use vm_state::VMState;

mod rv32im;
pub use rv32im::{EmuContext, InsnCategory, InsnFormat, InsnKind, Instruction};
pub use rv32im::{
EmuContext, InsnCategory, InsnFormat, InsnKind, Instruction, encode_rv32, encode_rv32u,
};

mod elf;
pub use elf::Program;

mod rv32im_encode;
pub use rv32im_encode::{encode_rv32, encode_rv32u};

pub mod disassemble;
28 changes: 28 additions & 0 deletions ceno_emul/src/rv32im.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,34 @@ use strum_macros::{Display, EnumIter};

use super::addr::{ByteAddr, RegIdx, WORD_SIZE, Word, WordAddr};

/// Convenience function to create an `Instruction` with the given fields.
///
/// Pass 0 for unused fields.
pub const fn encode_rv32(kind: InsnKind, rs1: u32, rs2: u32, rd: u32, imm: i32) -> Instruction {
Instruction {
kind,
rs1: rs1 as usize,
rs2: rs2 as usize,
rd: rd as usize,
imm,
raw: 0,
}
}

/// Convenience function to create an `Instruction` with the given fields.
///
/// Pass 0 for unused fields.
pub const fn encode_rv32u(kind: InsnKind, rs1: u32, rs2: u32, rd: u32, imm: u32) -> Instruction {
Instruction {
kind,
rs1: rs1 as usize,
rs2: rs2 as usize,
rd: rd as usize,
imm: imm as i32,
raw: 0,
}
}

pub trait EmuContext {
// Handle environment call
fn ecall(&mut self) -> Result<bool>;
Expand Down
29 changes: 0 additions & 29 deletions ceno_emul/src/rv32im_encode.rs

This file was deleted.

0 comments on commit 02f0828

Please sign in to comment.