aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Li <li.davidm96@gmail.com>2016-01-07 11:01:06 -0700
committerDavid Li <li.davidm96@gmail.com>2016-01-07 11:01:06 -0700
commitff8f94266e46e3dbecb1aa5768f04277d7447a94 (patch)
tree04130ed3aa50fbc9dad986ce9b9f52a1271761b7
parente33e5904ae3afdd85d00484bc6a114f2432acb62 (diff)
Implement SH/LH/LHU
-rw-r--r--src/simulator.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/simulator.rs b/src/simulator.rs
index d1c4aae..503f902 100644
--- a/src/simulator.rs
+++ b/src/simulator.rs
@@ -261,7 +261,9 @@ impl<'a> Core<'a> {
.read_byte(address)
.map(|b| (b as isa::SignedByte) as isa::Word),
isa::funct3::LH =>
- panic!("{:x}: Unimplemented LH"),
+ self.cache.borrow_mut()
+ .read_halfword(address)
+ .map(|b| (b as isa::SignedHalfWord) as isa::Word),
isa::funct3::LW =>
self.cache.borrow_mut().read_word(address),
isa::funct3::LBU =>
@@ -269,7 +271,9 @@ impl<'a> Core<'a> {
.read_byte(address)
.map(|b| b as isa::Word),
isa::funct3::LHU =>
- panic!("{:x}: Unimplemented LHU"),
+ self.cache.borrow_mut()
+ .read_halfword(address)
+ .map(|b| b as isa::Word),
_ => panic!("{:x}: Invalid load funct3code: 0x{:x}",
pc, inst.funct3()),
};
@@ -298,9 +302,11 @@ impl<'a> Core<'a> {
let result = match inst.funct3() {
isa::funct3::SB =>
- self.cache.borrow_mut().write_byte(address, val as u8),
+ self.cache.borrow_mut()
+ .write_byte(address, val as isa::Byte),
isa::funct3::SH =>
- panic!("PC {:x}: Unimplemented SH"),
+ self.cache.borrow_mut()
+ .write_halfword(address, val as isa::HalfWord),
isa::funct3::SW =>
self.cache.borrow_mut().write_word(address, val),
_ => panic!("PC {:x}: Invalid store funct3code: 0x{:x}",