From 928628c305082cd64eb5eaaf2945301ea2d5bf89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Autin?= Date: Fri, 24 Mar 2023 18:11:37 +0100 Subject: [PATCH] :memo: Documentation updates --- src/simulator/error.rs | 1 + src/simulator/machine.rs | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/simulator/error.rs b/src/simulator/error.rs index 42db367..4794315 100644 --- a/src/simulator/error.rs +++ b/src/simulator/error.rs @@ -10,6 +10,7 @@ pub struct MachineError { impl MachineError { + /// MachineError constructor pub fn new(message: &str) -> MachineError { MachineError { message: message.to_string() diff --git a/src/simulator/machine.rs b/src/simulator/machine.rs index 116a942..6b5e64b 100644 --- a/src/simulator/machine.rs +++ b/src/simulator/machine.rs @@ -33,9 +33,10 @@ pub enum ExceptionType { NumExceptionTypes } - pub const STACK_REG: usize = 2; +/// Number of available Integer registers pub const NUM_INT_REGS: usize = 32; +/// Number of available Floating Point registers pub const NUM_FP_REGS: usize = 32; /// max number of physical pages pub const NUM_PHY_PAGE : u64 = 400; @@ -44,15 +45,23 @@ pub const PAGE_SIZE : u64 = 128; /// Must be a multiple of PAGE_SIZE pub const MEM_SIZE : usize = (PAGE_SIZE*NUM_PHY_PAGE*100) as usize; -#[derive(PartialEq)] +/// RISC-V Simulator pub struct Machine { + /// Program counter pub pc : u64, + /// Stack pointer pub sp: usize, + /// Integer register pub int_reg : Register, + /// Floating point register pub fp_reg : Register, + /// Heap memory pub main_memory : Vec, + /// Shiftmask pub shiftmask : [u64 ; 64], + /// Debug data pub registers_trace : String, // for tests + /// todo: document Interrupts pub interrupt: Interrupt // futur taille à calculer int memSize = g_cfg->NumPhysPages * g_cfg->PageSize; //creer une struct cfg(configuration) qui s'initialise avec valeur dans un fichier cfg