Comments (9)
Cause I had found that the unexpected output only occur when the size of the previous array is not equal to
multiples of four byte
, so I suspected that maybe their have some bug inlw
orla
.
The concept of alignment is dependent upon the size of data. For word data the address is either multiple of 4 (aligned), or it is misaligned. @maromaSamsa, you can now prepare a revised MRE which reflects the above findings.
from rv32emu.
Thanks for your reply, I think this explanation convince me why the unexpected output doesn't print any character when misaligned occur in rv32emu, and I am curious about the source code.
You can check the op_load
function in file emulate.c
.
from rv32emu.
@maromaSamsa, you shall provide a minimal reproducible example (MRE) instead of hyperlinks. Edit the description of this issue to inline MRE.
from rv32emu.
@maromaSamsa I want to check your problem. Does your problem is that the emulator executes wrong when instruction la
is changed to instruction lw
?
Example:
la s1, arr1 -> lw s1, arr1
from rv32emu.
@maromaSamsa I want to check your problem. Does your problem is that the emulator executes wrong when instruction
la
is changed to instructionlw
?Example:
la s1, arr1 -> lw s1, arr1
Actually I am not sure, in this RISC-V source code I just use la
to get address of the byte array, and use lw
to load 4 byte value from the array.
Cause I had found that the unexpected output only occur when the size of the previous array is not equal to multiples of four byte
, so I suspected that maybe their have some bug in lw
or la
.
from rv32emu.
Cause I had found that the unexpected output only occur when the size of the previous array is not equal to
multiples of four byte
, so I suspected that maybe their have some bug inlw
orla
.The concept of alignment is dependent upon the size of data. For word data the address is either multiple of 4 (aligned), or it is misaligned. @maromaSamsa, you can now prepare a revised MRE which reflects the above findings.
Please check this commit
the output is normal when you change the test case
.data
arr1:
.byte 48, 49, 50 # this will cause unexpected output
#.byte 48, 49, 50, 51 # check this
PS: sorry for the wrong term in this commit, is MRE
(minimal reproducible example) not MSE
(Mean squared error).
from rv32emu.
@maromaSamsa, I already checked this commit. The reason why test case .byte 48, 49, 50
cause unexpected output is misalignment.
In the rv32emu
, arr1
and arr2
are stored in contiguous memory address. First lw
instruction checks whether the address of arr1
+ 4 is misaligned. Because the start address of arr1
is aligned, the address of arr1
+ 4 is also aligned. Therefore, first lw
instruction loads 3 bytes of data of arr1
and 1 byte of data of arr2
. However, the start address of arr2
is the start address of arr1
+ 3, so second lw
instruction finds out arr2
+ 4 is misaligned and calls exeception handler without printing any data.
As alternative, you can use lb
instruction to load a byte of data.
from rv32emu.
However, the start address of
arr2
is the start address ofarr1
+ 3, so secondlw
instruction finds outarr2
+ 4 is misaligned and calls exeception handler without printing any data.
Thanks for your reply, I think this explanation convince me why the unexpected output doesn't print any character when misaligned occur in rv32emu
, and I am curious about the source code.
As alternative, you can use
lb
instruction to load a byte of data.
Since I hope I can save the memory by constrain the test data into byte, and also lw
is more efficiency than lb
cause I can spent only one instruction time to load 4 byte, I choose to use lw
if it is possible.
from rv32emu.
I probably close this as the issue is not one of emulator flaws.
from rv32emu.
Related Issues (20)
- Fix potential security issue in benchmark script
- jit: code generation tool should be aware of comments
- jit: Incomplete `muldivmod`
- Evaluate a hybrid approach for macro-operation fusion in both the decoding and execution stages
- Consolidate public header by integrating src/state.h HOT 1
- jit: Several errors are detected when running CoreMark
- Refactoring RISC-V emulation APIs for easier adoption and porting HOT 30
- jit: Enhance security by Control-Flow Integrity
- Comparing Interpreter performance with Wasm3
- Incorrect global/static float array initialization HOT 2
- Fail to build when ENABLE_EXT_C=0 ENABLE_JIT=1 HOT 1
- Accelerate ISA simulation by tiered JIT compilation HOT 13
- Assertion fail when running jit-bf with ENABLE_JIT=1
- jit: Implement register allocation for T1C HOT 2
- Provide minimal cross-platform GUI library HOT 2
- Incorrect basename generated by dynamic profiler
- jit: Assertion while running aes.elf HOT 2
- Potential uninitialized value read without initialization HOT 2
- Specialize JALR Instruction HOT 6
- Use the canonical order of RISC-V extension names in the repository description
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rv32emu.