riscy_isa/opcode/
store_width.rs1#[derive(Copy, Clone, Debug, PartialEq)]
2pub enum StoreWidth {
3 Byte,
4 HalfWord,
5 Word,
6 DoubleWord,
7}
8
9impl StoreWidth {
10 pub fn from_func3(func3: u8) -> Self {
11 match func3 {
12 0b000 => Self::Byte,
13 0b001 => Self::HalfWord,
14 0b010 => Self::Word,
15 0b011 => Self::DoubleWord,
16
17 _ => unimplemented!("Store width {:03b}", func3),
18 }
19 }
20
21 pub fn to_func3(&self) -> i32 {
22 match self {
23 Self::Byte => 0b000,
24 Self::HalfWord => 0b001,
25 Self::Word => 0b010,
26 Self::DoubleWord => 0b011,
27 }
28 }
29}