Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form of some Zbb extension instructions is incorrect #16

Open
kathlenemagnus opened this issue Jul 31, 2024 · 0 comments
Open

Form of some Zbb extension instructions is incorrect #16

kathlenemagnus opened this issue Jul 31, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@kathlenemagnus
Copy link
Collaborator

kathlenemagnus commented Jul 31, 2024

The Form of several Zbb instructions is incorrect. This is the list of affected instructions:

  • clz
  • ctz
  • cpop
  • sext.b
  • sext.h

These instructions use the ISH Form, but they should use the ISHW Form instead. However, making this fix causes a failure that says that the clz instruction is incompatible with the slli instruction. Both of these instructions use the value 0x13 as their opcode value and the value 0x1 for their func3 value. When traversing the decode tree, Mavis expects instructions with the same value for a particular field to define the same fields. For the ISH Form, the next field is func6 while for the ISHW Form the next field is func7. So the error occurs because Mavis doesn't know how to compare a func6 field with a func7 field.

BTW the order the fields are evaluated is defined in a Form's opcode_fields:

const FieldsType Form_ISH::opcode_fields {
    Form_ISH::fields[Form_ISH::idType::OPCODE],
    Form_ISH::fields[Form_ISH::idType::FUNC3],
    Form_ISH::fields[Form_ISH::idType::FUNC6]
};
const FieldsType Form_ISHW::opcode_fields {
    Form_ISHW::fields[Form_ISHW::idType::OPCODE],
    Form_ISHW::fields[Form_ISHW::idType::FUNC3],
    Form_ISHW::fields[Form_ISHW::idType::FUNC7]
};

I've solved problems like this in the past by breaking up fields into subfields. So the ISHW field func7 might become func6 and func1 so that func6 can be compared against the ISH func6.

@kathlenemagnus kathlenemagnus added the bug Something isn't working label Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant