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

Support rv64 #78

Merged
merged 23 commits into from
Jul 15, 2020
Merged

Support rv64 #78

merged 23 commits into from
Jul 15, 2020

Conversation

TheThirdOne
Copy link
Owner

@TheThirdOne TheThirdOne commented Jun 16, 2020

I have something that gives some support for rv64 now. Its not finished, but it is a start.

TODO:

  • Support rv64i instructions
  • Support rv64im instructions
  • Support rv64if instructions
  • Support rv64ifd instructions
  • Update system calls
  • GUI shows 64 bit wide registers
  • GUI allows toggling 64 bit mode
  • CLI allows changing to 64 bit mode
  • Assembler allows 64 bit wide constants
  • Good error messages and support for 6 bit immediates in shift instructions
  • Testing to prove correct semantics

Also changed cycle, instret and time to be directly updated as 64 bits.
The remaining instructions which might need modifications are:
  Floating point (which shouldn't need to change)
  JALR
  Immediate mode shifts
  Stores and loads need a little update to support new instructions
Also this fixes a bug in backstepping FSD and a tautologically true test.
On change of this setting all instructions are reloaded and ones that
don't work in the current mode will fail to initialize. Its a kindof
hacky solution, but it does allow overwriting other instructions.

The mechanism for failing to load is BasicInstruction throwing a null
pointer exception.
@TheThirdOne TheThirdOne linked an issue Jun 16, 2020 that may be closed by this pull request
This was quite difficult to actually implement, but is quite
neccessary to automatically run tests from riscv-tests. Most
of the difficulty stemmed from a bunch of places in the code
expecting the biggest value would be an int rather than a
long.

However, making li work with 64 bit values was also a little
bit of work. It neccessitated making 5 new types of Psuedo-op
templates.

.dword was relatively simple after li wsa working, but required
modifying a significant amount of code.
@TheThirdOne
Copy link
Owner Author

This is close enough to finished that feedback would be good. If 32 bit behavior has changed or 64 bit semantics are wrong, please let me know. A fair amount of documentation still needs to be made and I don't have rigorous testing setup yet.

You can find a jar here

This bug was caused by a few issues. First, when adding .dword
I decided to allow existing code to handle the fits within 32
bit case. The old code could not possibly handle that correctly.
Second, lengthinbytes = 8 was passed into the Memory system, given
that it takes an int as data and there are only 4 bytes in an
int it doesn't have defined behaviour for 8 bytes. Third, javas
shifting loops after 32 for integers. So in total, I failed to
account for a case, passed an undefined input into memory, which
resulted in replicated behaviour due to java.

I fixed it by just always handling the writes for .dword directly.
@Jonas-Salcedo
Copy link

Thank you so much for this feature!

Significant postproccessing on these tests was needed to get them to
assemble. The test templates use a bunch of shifting and masking which
is not explanded by gcc when outputting assembly. Simpliying the
templates + sed to replace things automatically works pretty well, but
it also uses numbered branches which would force those to be rewrtiten
by hand. Also srl used C shifting logic to generate answers so that
needed to be done by hand.

In general, branches not included and very minor manual changes after
a small script post-processing and template changes.
@TheThirdOne
Copy link
Owner Author

TheThirdOne commented Jun 30, 2020

Currently the thing holding this back is the lack of testing. I have been working on loading ELF files generated by riscv-tests, but that will take a little more effort as ELF loading is a prototype and doesn't support parsing 64 bit ELF files.

… the same

Both jalr bugs apply to both rv32 and rv64, but only got caught
now because of the binary testing which allowed me to run the
riscv-tests that use special branching syntax RARS doesn't support.
@TheThirdOne
Copy link
Owner Author

A hacky way of loading elf files worked, and RARS now passes binary rv64 tests. I don't have the tests committed yet though. I think I will get the CLI set up quickly and then manually review all of the system calls.

@TheThirdOne TheThirdOne deleted the rv64 branch July 15, 2020 04:15
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support RV64
2 participants