-
Notifications
You must be signed in to change notification settings - Fork 67
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
Memory access issue when xlen=64 #146
Comments
You are right that there is problem with
at end of the code and then load value by
but that solution is not compatible with compilation in 32-bit mode, because The I have thought what is the best solution even in past but I have not come to clean/preferred solution yet. Another option is to map UART to 0xffffffffffffc000 location in 64-bit mode. The memory model even allows multiple mapping of peripheral but it slows down memory access execution and there is already alias at 0xffff0000 for UART which keep code compatibility with QtSpim in QtMips time. So some feedback what seems acceptable is welcomed for decision about future development steps. Easy to improve is to add But in general, I suggest to use 32-bits for basic teaching for now. 64-bits are there to allow to run simple binaries for standard RISC-V Linux kernel system where 64-bit mode prevails and even QtRvSim syscalls should work in 64-bit mode, has been designed and updated for compatibility with it. There is another problem that full 64-bit values do not fit and propagate into signal labels in the CPU diagram. |
The commit 09435a4 Machine: add peripherals high/top address aliases for XLEN=64 provides aliases for peripherals in 64-bit mode to allow template.S and other code to work properly in 64-bit mode where LUI leads to sign extended values and internal assembler does not allow to specify full 64-bit constant. I do not like this mapping duplication but it should help users and keep code compiled bu full featured assembler where original addresses in top of 4 GiB address space are preserved. I am not sure with the rest and it is not material for actual release for sure. In general, if the support for larger memory ranges emulation is clean (@jdupak review would be helpful) then I agree with its merging in the next development cycle. The variable depth would have some overhead, mainly if deeper tree and shorter one are used in parallel (more branch patters miss-predictions) but simulator is already slow by other components. On the other hand, I am not sure if I want to see extension of the address space to be enabled by default and I see disabling peripherals at 0xffxxxxxx addresses as unwelcome. Some config option could be possible. There would be need to invest precise time into memory viewers sliding windows and ergonomic. 16 digits in goto line and in the address column are unreadable for people like me. |
In the new simulator phase, we can set xlen to 64.
However, even after configuring it to 64-bit, the simulator's memory access range remains 32-bit, while the registers are 64-bit. This discrepancy will cause issues with instructions such as load during execution.
For more details, you may refer to example.S, where you will find that an infinite loop occurs due to the inability to read pre-set values from memory.(After
lw
, the x5 remain 0)The text was updated successfully, but these errors were encountered: