From 8ca42acf1a92ac0d811bbeecf8aed25a8c2d5a30 Mon Sep 17 00:00:00 2001 From: David Li Date: Sat, 19 Dec 2015 09:27:18 -0500 Subject: Implement RV32I integer-immediate instructions --- src/isa/funct3.rs | 3 +-- src/isa/funct7.rs | 3 +++ src/isa/mod.rs | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/isa') diff --git a/src/isa/funct3.rs b/src/isa/funct3.rs index 0612844..be2eafa 100644 --- a/src/isa/funct3.rs +++ b/src/isa/funct3.rs @@ -3,8 +3,7 @@ pub const SLLI: u32 = 0x1; pub const SLTI: u32 = 0x2; pub const SLTIU: u32 = 0x3; pub const XORI: u32 = 0x4; -pub const SRLI: u32 = 0x5; -pub const SRAI: u32 = 0x5; +pub const SRLI_SRAI: u32 = 0x5; pub const ORI: u32 = 0x6; pub const ANDI: u32 = 0x7; diff --git a/src/isa/funct7.rs b/src/isa/funct7.rs index f3446fb..f48fae8 100644 --- a/src/isa/funct7.rs +++ b/src/isa/funct7.rs @@ -1,2 +1,5 @@ pub const ADD_SRL: u32 = 0x0; pub const SUB_SRA: u32 = 0x1; + +pub const SRLI: u32 = 0x0; +pub const SRAI: u32 = 0x1; diff --git a/src/isa/mod.rs b/src/isa/mod.rs index ebfd4e8..0e3261b 100644 --- a/src/isa/mod.rs +++ b/src/isa/mod.rs @@ -110,6 +110,10 @@ impl Instruction { (self.word >> 25) & 0x7F } + pub fn shamt(&self) -> u32 { + (self.word >> 20) & 0x1F + } + pub fn rs1(&self) -> Register { Register::from_num((self.word >> 15) & 0x1F) } -- cgit v1.2.3