Connect Kelvin instructions to instruction decoder
The instructions can be properly parsed after this.
Add a vector test to verify it.
PiperOrigin-RevId: 550426838
diff --git a/sim/kelvin_encoding.cc b/sim/kelvin_encoding.cc
index ba8a9ce..9bd3987 100644
--- a/sim/kelvin_encoding.cc
+++ b/sim/kelvin_encoding.cc
@@ -292,6 +292,8 @@
void KelvinEncoding::ParseInstruction(uint32_t inst_word) {
inst_word_ = inst_word;
opcode_ = encoding::DecodeKelvinInst(inst_word_);
+ if (opcode_ == OpcodeEnum::kNone)
+ opcode_ = encoding::DecodeKelvinVectorInst(inst_word_);
}
DestinationOperandInterface *KelvinEncoding::GetDestination(SlotEnum, int,
diff --git a/sim/test/kelvin_encoding_test.cc b/sim/test/kelvin_encoding_test.cc
index 96a3db4..0037c7b 100644
--- a/sim/test/kelvin_encoding_test.cc
+++ b/sim/test/kelvin_encoding_test.cc
@@ -80,6 +80,9 @@
// Kelvin Logging Op
constexpr uint32_t kFLog = 0b011'1100'00000'00000'000'00000'111'0111;
+// Kelvin VLd
+constexpr uint32_t kVld = 0b000000'000000'000000'00'000000'0'111'11;
+
class KelvinEncodingTest : public testing::Test {
protected:
KelvinEncodingTest() {
@@ -234,6 +237,16 @@
EXPECT_EQ(enc_->GetOpcode(SlotEnum::kKelvin, 0), OpcodeEnum::kKlog);
}
+TEST_F(KelvinEncodingTest, KelvinVldOpcodes) {
+ enc_->ParseInstruction(SetRs1(kVld, kRdValue));
+ EXPECT_EQ(enc_->GetOpcode(SlotEnum::kKelvin, 0), OpcodeEnum::kVldBX);
+ enc_->ParseInstruction(SetRs1(kVld, kRdValue) | (0b01 << 12 /* sz */));
+ EXPECT_EQ(enc_->GetOpcode(SlotEnum::kKelvin, 0), OpcodeEnum::kVldHX);
+ enc_->ParseInstruction(SetRs1(kVld, kRdValue) | (0b10 << 12 /* sz */) |
+ (0b10 << 20 /* xs2 */) | (0b1 << 26 /* length */));
+ EXPECT_EQ(enc_->GetOpcode(SlotEnum::kKelvin, 0), OpcodeEnum::kVldWLXx);
+}
+
TEST_F(KelvinEncodingTest, ZifenceiOpcodes) {
// RV32 Zifencei
enc_->ParseInstruction(kFencei);