Skip to content

Commit

Permalink
change tab_spaces from 4 to 2
Browse files Browse the repository at this point in the history
  • Loading branch information
DrEden33773 committed Aug 15, 2023
1 parent d3ab3fd commit 408b358
Show file tree
Hide file tree
Showing 12 changed files with 633 additions and 641 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"python.formatting.provider": "none"
"python.formatting.provider": "none",
"editor.tabSize": 2
}
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tab_spaces = 2
56 changes: 28 additions & 28 deletions src/bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,42 @@ use crate::exception::*;
use crate::param::*;

pub struct Bus {
pub dram: Dram,
pub dram: Dram,
}

impl Bus {
pub fn new(code: Vec<u8>) -> Bus {
Self {
dram: Dram::new(code),
}
pub fn new(code: Vec<u8>) -> Bus {
Self {
dram: Dram::new(code),
}
}

pub fn fetch_inst(&self, addr: u64) -> Result<u8, Exception> {
match addr {
DRAM_BASE..=DRAM_END => Ok(self.dram.fetch_inst(addr)),
_ => Err(Exception::InstructionAccessFault(addr)),
}
pub fn fetch_inst(&self, addr: u64) -> Result<u8, Exception> {
match addr {
DRAM_BASE..=DRAM_END => Ok(self.dram.fetch_inst(addr)),
_ => Err(Exception::InstructionAccessFault(addr)),
}
}

pub fn load(&mut self, addr: u64, size: SizeType) -> Result<u64, Exception> {
let addr = addr + DRAM_BASE;
match addr {
DRAM_BASE..=DRAM_END => self.dram.load(addr, size),
_ => Err(Exception::LoadAccessFault(addr)),
}
pub fn load(&mut self, addr: u64, size: SizeType) -> Result<u64, Exception> {
let addr = addr + DRAM_BASE;
match addr {
DRAM_BASE..=DRAM_END => self.dram.load(addr, size),
_ => Err(Exception::LoadAccessFault(addr)),
}
pub fn store(&mut self, addr: u64, size: SizeType, value: u64) -> Result<(), Exception> {
let addr = addr + DRAM_BASE;
match addr {
DRAM_BASE..=DRAM_END => self.dram.store(addr, size, value),
_ => Err(Exception::StoreAMOAccessFault(addr)),
}
}
pub fn store(&mut self, addr: u64, size: SizeType, value: u64) -> Result<(), Exception> {
let addr = addr + DRAM_BASE;
match addr {
DRAM_BASE..=DRAM_END => self.dram.store(addr, size, value),
_ => Err(Exception::StoreAMOAccessFault(addr)),
}
pub fn load_u(&mut self, addr: u64, size: SizeType) -> Result<u64, Exception> {
let addr = addr + DRAM_BASE;
match addr {
DRAM_BASE..=DRAM_END => self.dram.load_u(addr, size),
_ => Err(Exception::LoadAccessFault(addr)),
}
}
pub fn load_u(&mut self, addr: u64, size: SizeType) -> Result<u64, Exception> {
let addr = addr + DRAM_BASE;
match addr {
DRAM_BASE..=DRAM_END => self.dram.load_u(addr, size),
_ => Err(Exception::LoadAccessFault(addr)),
}
}
}
Loading

0 comments on commit 408b358

Please sign in to comment.