Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Modify target_write_u32() to make 32-bit data output easier #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions emu-rv32i.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ int target_write_u32(uint32_t addr, uint32_t val)
return 1;
}
if (addr == MTIMECMP_ADDR) {
printf("%d", val);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose the change is improving the verbosity of data read operations, right? If so, please consider to wrap it with DEBUG_EXTRA.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was intended to mimic line 822, which output a character when UART receives data.
Because UART outputs every byte received as character, even if I divide an integer by 4 and send them respectively, the processor still cannot display it correctly. I think we need a way to display data in any data type, and 4-byte integer is a very commonly used one. So at least I want the processor to display integer when it detects integer write. So I put a printf() in target_write_u32(), and it works.
But maybe this is not an appropriate way to deal with data output... (indeed this output is more like debug message rather than standard output) Should I use try other ways to output data > 8 bits?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can manipulate the serialized data with a buffer and then flush later.

mtimecmp = (mtimecmp & 0xffffffff00000000ll) | val;
mip &= ~MIP_MTIP;
} else if (addr == MTIMECMP_ADDR + 4) {
Expand Down