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

Implement selectable big-endian, little-endian and bi-endian configurations #54

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

gambaman
Copy link

Swap comments for the inputs exu2csr_r_req_i and exu2csr_rw_addr_i of module scr1_pipe_csr.

Swap comments for the inputs exu2csr_r_req_i and exu2csr_rw_addr_i of module scr1_pipe_csr.
@achuykov-sc
Copy link
Collaborator

Hi @gambaman,

Thank you for your note about incorrect comment.
We are collecting changes internally and will do SCR1 update later. Of course, we will include your correction.

And if you do not mind, I'm closing your pull request.

Many thanks,
Alexander

@gambaman
Copy link
Author

Thank you very much for your reply, Alexander. I would like to make some contributions to the SCR1 core. Do you have any convention for coding style, code comments and/or commit messages?

Best regards

Hi @gambaman,

Thank you for your note about incorrect comment. We are collecting changes internally and will do SCR1 update later. Of course, we will include your correction.

And if you do not mind, I'm closing your pull request.

Many thanks, Alexander

@achuykov-sc
Copy link
Collaborator

@gambaman, we do not have strict requirements for code style. Please use existing files as reference.
Could you please share your ideas what would you like to commit?

Best regards,
Alexander

@achuykov-sc achuykov-sc reopened this Jan 31, 2024
@gambaman
Copy link
Author

gambaman commented Jan 31, 2024

Sure. According to the instruction set manual V20211, in mono-endian implementations of RV32I, mstatush.MBE is read-only. Its value should be 0 if the implementation is little-endian. However, it looks that the mstatush CSR is not implemented in SCR1. I was going to fix that. Also, I was going to add support for big-endian and bi-endian. When bi-endian implementation is selected, mstatush.MBE will be read-write in concordance with the ISA manual. I hope it will suit you.

@gambaman
Copy link
Author

gambaman commented Feb 9, 2024

Hello, Alexander. The mandatory RV32-only CSR mstatush has been implemented. Not a big contribution since only little-endian is supported for now, but it had to be done. I was going to update the documentation accordingly, but it looks the doc source is not in the repository.

@gambaman
Copy link
Author

Hi, In order to implement multi-endian I have written some utility modules. In which directory do you prefer me to store them? Maybe in src/core/primitives?

P.D. I cannot send e-mails to scr1@syntacore.com because it is a restricted group.

@gambaman gambaman changed the title Fix comments Implement the RV32-only CSR mstatush Feb 14, 2024
…nfigurations

Now the data endianness can be selected in concordance with ISA V20211.
The default configuration is bi-endian so mstatush.MBE is writtable.
Single endian can be selected by editing scr1_arch_description.svh.
The following line can be uncommented to select little-endian only:
//`define SCR1_IMMUTABLE_ENDIANNES LITTLE_ENDIAN
The following line can be uncommented to select big-endian only:
//`define SCR1_IMMUTABLE_ENDIANNES BIG_ENDIAN
@gambaman gambaman changed the title Implement the RV32-only CSR mstatush Implement selectable big-endian, little-endian and bi-endian configurations Feb 20, 2024
@gambaman
Copy link
Author

gambaman commented Feb 20, 2024

Hello, Alexander. Selectable big-endian, little-endian and bi-endian configurations have been implemented.
Note that the compliance test expects a little-endian behavior. However, a bi-endian configuration will pass all the test because mstatush.MBE is set to 0 at reset so at start up endiannes is little-endian.
The default configuration is bi-endian so mstatush.MBE is writtable. A single endian implementation can be selected by editing scr1_arch_description.svh.

The following line must be uncommented to force a little-endian only implementation:
//`define SCR1_IMMUTABLE_ENDIANNES LITTLE_ENDIAN

The following line must be uncommented to force a big-endian only implementation:
//`define SCR1_IMMUTABLE_ENDIANNES BIG_ENDIAN

Again, the source code of the documentation is not available so I could not update it.
Best regards

@achuykov-sc
Copy link
Collaborator

Hi @gambaman,

Many thanks for update. Let me check it internally and back to you.
BTW, which compiler do you use to build test application for big-endian?

Best regards,
Alexander

@achuykov-sc achuykov-sc self-assigned this Feb 22, 2024
@gambaman
Copy link
Author

gambaman commented Feb 27, 2024

Hi @gambaman,

Many thanks for update. Let me check it internally and back to you. BTW, which compiler do you use to build test application for big-endian?

Best regards, Alexander

Hello, Alexander.

I'm not sure if you received my answer. Just in case, gcc can generate big-endian code for RV32 if you use the option -mbig-endian.

@achuykov-sc
Copy link
Collaborator

Hi @gambaman,

I did some checks of changes. Default and little-endian are working fine, but it is hard to say about big-endian because I cannot build and run test suite.
So, I have extra questions for you:

  1. Did you pass tests?
  2. Did you modify tests Makefiles?
  3. Could you please point me to your toolchain?

Best regards,
Alexander

@gambaman
Copy link
Author

Hi @gambaman,

I did some checks of changes. Default and little-endian are working fine, but it is hard to say about big-endian because I cannot build and run test suite. So, I have extra questions for you:

1. Did you pass tests?

Hello, Alexander. I don't know how to modify the test suit to expect a big-endian only implementation. I did test the big-endian behavior in a bi-endian implementation by setting mstatush.MBE bit just before every big-endian test access and clearing it right after. I did not found any error. However, today I have carried out more test and it looks that the SH instructions is not always working properly when mstatush.MBE=1. I will tell you as soon as I found the error.

2. Did you modify tests Makefiles?

Only the one in the src1 folder in order to carry out my own test.

3. Could you please point me to your toolchain?

I installed it from source following the instructions in page 10 of your user manual: https://github.com/riscv/riscv-gnu-toolchain

Best regars

@gambaman
Copy link
Author

gambaman commented Apr 10, 2024

Hello Alexander,

again, what I thought was a fail turned out to be a compiler issue. It looks the biendian implementation was working after all. I have pushed a sample program to test it. You can run with this command:

make TARGETS="biendian_sample"

It will test every load/store instruction using big-endian as well as little-endian byte order.

Best regards

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.

None yet

2 participants