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

Implement the compressed instructions #5

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

Conversation

eriktai
Copy link

@eriktai eriktai commented Jan 11, 2020

Some modification of rv32emu to support C ext.

  1. Add a new variable named insn_type to distinguish the 16-bit and 32-bit instruction.
  2. Modify the unsigned char get_insn32(uint32_t, uint32_t*) to return the type of instruction and then assign the pointer the machine code of the instruction.
  3. Modify the instruction offset, instead of always proceeding 4 bytes, it will depend on the type of instruction.
    • 16-bits : 2 bytes
    • 32-bits : 4 bytes
  4. Rearrange the offset of outputing the signature.
  5. Update the comparing function, which can compare the groundtruth and output of signature of this emulator for debugging.
  6. It is also the version of fixing start address of stack pointer.
  7. Imp and finish the test of all 32-bit version compressed instructions except those 64-bit version, 128-bit version and F ext.

Future work

  • I would like to imp the floating point extension.

@jserv
Copy link
Contributor

jserv commented Jan 11, 2020

Remove the generated files and rework!

CSRs.h Outdated
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

The range from Line 1 to 68 is not necessary. Remove these lines.

Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Author

Choose a reason for hiding this comment

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

Sor, I may forget about it.

@jserv
Copy link
Contributor

jserv commented Jan 11, 2020

Hint: use git rebase -i to rework these Git commits.

@eriktai
Copy link
Author

eriktai commented Jan 11, 2020

Sorry, I have a question.
Do I need to rework all the commit messages?

@jserv
Copy link
Contributor

jserv commented Jan 11, 2020

Sorry, I have a question.
Do I need to rework all the commit messages?

Yes, all commits should be reworked. You shall squash the similar changes and make the commits clear.

@eriktai
Copy link
Author

eriktai commented Jan 11, 2020

Hello, Jserv
I have reworked these commit messages.
Please check, thank you~

@jserv
Copy link
Contributor

jserv commented Jan 11, 2020

After reworking Git commits with git rebase -i, you should perform git push --force for this branch.

@@ -1,19 +1,60 @@
BINS = emu-rv32i test1
TEST_TARGETS = \
Copy link
Contributor

Choose a reason for hiding this comment

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

Send another pull request for adding RISC-V test cases.

@jserv
Copy link
Contributor

jserv commented Jan 11, 2020

Ensure no generated files such as ELF, log, dump files in Git repository.

@jserv
Copy link
Contributor

jserv commented Jan 12, 2020

You have to rebase master branch of upstream. And then, force push.

@jserv
Copy link
Contributor

jserv commented Jan 12, 2020

Don't use git merge. Use git rebase instead.

@jserv
Copy link
Contributor

jserv commented Jan 12, 2020

Reference instructions:

  1. set upstream: git remote add upstream https://github.com/sysprog21/rv32emu && git fetch upstream
  2. Perform rebase: git rebase upstream/master
  3. Fix the conflicts.

CSRs.h Outdated

#include <stdint.h>


Copy link
Contributor

Choose a reason for hiding this comment

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

Can you introduce a dedicated structure for preserving the following fields?

emu-rv32i.c Outdated
After this you can run it with the emulator like this:
emu-rv32i zephyr/zephyr.elf
original copyright:
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the range from Line 1 to Line 35.

emu-rv32i.c Outdated
// #define DEBUG_OUTPUT
// #define DEBUG_EXTRA
#define DEBUG_OUTPUT
#define DEBUG_EXTRA
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't do that.

emu-rv32i.c Outdated
#define DEBUG_EXTRA

#if 1
#define RV32C
Copy link
Contributor

Choose a reason for hiding this comment

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

RV32C should be assigned via Makefile

emu-rv32i.c Outdated
""};
#define C_STATS_NUM 64

#ifndef RV32C
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to use the following:

char statnames[STATS_NUM + C_STATS_NUM][16] = {
    ... /* RV32I instructions */
#if defined(RV32C)
    ... /* RV32C specific instructions */
#endif
} 

Copy link
Author

Choose a reason for hiding this comment

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

OK! It's more structural.

emu-rv32i.c Outdated
maxmemr = maxmemw = 0;
for(int i=0;i<STATS_NUM;i++) stats[i]=0;
#ifdef RV32C
for(int i=0;i<C_STATS_NUM;i++) stats[i+64] = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto. You can define macro for the range. Thus, we don't have to duplicate the loops.

@jserv
Copy link
Contributor

jserv commented Jan 12, 2020

Before submitting the changes, ensure the completion of executing clang-format -i *.[ch]

@jserv jserv changed the title Finishing the compressed instruction of rv32emu Implement the compressed instructions Jan 16, 2020
@jserv
Copy link
Contributor

jserv commented Jan 16, 2020

Reworked yet?

@eriktai
Copy link
Author

eriktai commented Jan 19, 2020 via email

@eriktai
Copy link
Author

eriktai commented Jan 20, 2020

Hello Jserv,
Sorry about the absence a few days ago.
I have rebased all commits.

sig.txt
rom.v
debug.txt
CSR.h
Copy link
Contributor

Choose a reason for hiding this comment

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

CSR.h was tracked in GIT repository.

@@ -23,6 +24,8 @@
// #define DEBUG_OUTPUT
// #define DEBUG_EXTRA


/* added by Shaos: */
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't have to mention the contributor name inside source file.

@@ -140,7 +163,7 @@ uint64_t mtimecmp;
/* virtual start address for index 0 in the ram array */
uint32_t ram_start;

/* program entry point */
/* Program entry point */
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't do that. Let's minimize the changes.

/* CPU state */
uint32_t pc;
uint32_t next_pc;
uint32_t insn;
uint32_t reg[32];


Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto. Minimize the changes.

@jserv
Copy link
Contributor

jserv commented Jan 20, 2020

Thank @kksweet8845 again for contributing to this project. However, we shall always merge commits with better Git commit messages for further development. Please split this pull request into the following:

  1. New pull request for rv32i conformance tests;
  2. Once the above is merged, modify the pull request to concentrate on RV32C;

Changes regarding CSR instructions should be addressed in part 1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants