Skip to content

Commit f5d3ee0

Browse files
committed
feat(evc) Implemented extract vector components decoder.
1 parent 7497d94 commit f5d3ee0

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

examples/counter.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ fn main() {
2626
// ```
2727
];
2828

29-
dbg!(Instruction::decode(0b1000_1000_1000_1000_0001_1000_0000010));
29+
// dbg!(Instruction::decode(0b1000_1000_1000_1000_0001_1000_0000010));
30+
dbg!(Instruction::decode(0b1111_1110_1001_1010_1001_1011_0000011));
3031
}

src/instruction.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ pub enum Instruction {
4646
LoadVectorComponents {
4747
destination: RegisterCode,
4848
/// Having [None] means that the component corresponding to the index should be 0.
49-
components: [Option<vector::ComponentCode>; vector::SIZE]
49+
components: [Option<RegisterCode>; vector::SIZE]
5050
},
5151
ExtractVectorComponents {
52-
vector: RegisterCode,
52+
source: RegisterCode,
5353
/// Having [None] means that the component corresponding to the index should not be extracted into a register.
54-
components: [Option<RegisterCode>; vector::SIZE]
54+
destinations: [Option<RegisterCode>; vector::SIZE]
5555
},
5656
FlagVectorComponents {
5757
flags: [VectorComponentFlags; vector::SIZE],

src/instruction/encoding.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ impl Instruction {
2727
(destination, segment, immediate)
2828
}
2929

30-
fn decode_load_vector(operands: EncodedOperands) -> (RegisterCode, [Option<vector::ComponentCode>; vector::SIZE]) {
30+
fn decode_vector_components(operands: EncodedOperands) -> (RegisterCode, [Option<RegisterCode>; vector::SIZE]) {
3131
let operands = operands.get();
32-
let destination = RegisterCode::new((operands & LOAD_VECTOR_DESTINATION) as u8);
32+
let primary = RegisterCode::new((operands & LOAD_VECTOR_DESTINATION) as u8);
3333

3434
let enable_0 = ((operands & LOAD_VECTOR_COMPONENT_ENABLE_0.1) >> LOAD_VECTOR_COMPONENT_ENABLE_0.0) > 0;
3535
let enable_1 = ((operands & LOAD_VECTOR_COMPONENT_ENABLE_1.1) >> LOAD_VECTOR_COMPONENT_ENABLE_1.0) > 0;
3636
let enable_2 = ((operands & LOAD_VECTOR_COMPONENT_ENABLE_2.1) >> LOAD_VECTOR_COMPONENT_ENABLE_2.0) > 0;
3737
let enable_3 = ((operands & LOAD_VECTOR_COMPONENT_ENABLE_3.1) >> LOAD_VECTOR_COMPONENT_ENABLE_3.0) > 0;
3838

39-
let component_0 = vector::ComponentCode::new(((operands & LOAD_VECTOR_COMPONENT_0.1) >> LOAD_VECTOR_COMPONENT_0.0) as u8);
40-
let component_1 = vector::ComponentCode::new(((operands & LOAD_VECTOR_COMPONENT_1.1) >> LOAD_VECTOR_COMPONENT_1.0) as u8);
41-
let component_2 = vector::ComponentCode::new(((operands & LOAD_VECTOR_COMPONENT_2.1) >> LOAD_VECTOR_COMPONENT_2.0) as u8);
42-
let component_3 = vector::ComponentCode::new(((operands & LOAD_VECTOR_COMPONENT_3.1) >> LOAD_VECTOR_COMPONENT_3.0) as u8);
39+
let component_0 = RegisterCode::new(((operands & LOAD_VECTOR_COMPONENT_0.1) >> LOAD_VECTOR_COMPONENT_0.0) as u8);
40+
let component_1 = RegisterCode::new(((operands & LOAD_VECTOR_COMPONENT_1.1) >> LOAD_VECTOR_COMPONENT_1.0) as u8);
41+
let component_2 = RegisterCode::new(((operands & LOAD_VECTOR_COMPONENT_2.1) >> LOAD_VECTOR_COMPONENT_2.0) as u8);
42+
let component_3 = RegisterCode::new(((operands & LOAD_VECTOR_COMPONENT_3.1) >> LOAD_VECTOR_COMPONENT_3.0) as u8);
4343

44-
(destination, [
44+
(primary, [
4545
enable_0.then_some(component_0),
4646
enable_1.then_some(component_1),
4747
enable_2.then_some(component_2),
@@ -66,10 +66,13 @@ impl Instruction {
6666
Self::LoadImmediate { destination, segment, immediate }
6767
},
6868
Format::LoadVectorComponents => {
69-
let (destination, components) = Self::decode_load_vector(operands);
69+
let (destination, components) = Self::decode_vector_components(operands);
7070
Self::LoadVectorComponents {destination, components}
7171
},
72-
Format::ExtractVectorComponents => todo!(),
72+
Format::ExtractVectorComponents => {
73+
let (source, destinations) = Self::decode_vector_components(operands);
74+
Self::ExtractVectorComponents { source, destinations }
75+
},
7376
Format::FlagVectorComponents => todo!(),
7477
Format::MapVector => todo!(),
7578
Format::Branch => todo!(),

0 commit comments

Comments
 (0)