arch: [Patch 1/5] Added RISC-V base instruction set RV64I
Review Request #3624 - Created Sept. 14, 2016 and submitted
| Information | |
|---|---|
| Alec Roelke | |
| gem5 | |
| default | |
| Reviewers | |
| Default | |
Changeset 11688:ccda87b39fe5 --------------------------- arch: [Patch 1/5] Added RISC-V base instruction set RV64I First of five patches adding RISC-V to GEM5. This patch introduces the base 64-bit ISA (RV64I) in src/arch/riscv for use with syscall emulation. The multiply, floating point, and atomic memory instructions will be added in additional patches, as well as support for more detailed CPU models. The loader is also modified to be able to parse RISC-V ELF files, and a "Hello world\!" example for RISC-V is added to test-progs. Patch 2 will implement the multiply extension, RV64M; patch 3 will implement the floating point (single- and double-precision) extensions, RV64FD; patch 4 will implement the atomic memory instructions, RV64A, and patch 5 will add support for timing, minor, and detailed CPU models that is missing from the first four patches (such as handling locked memory). [Removed several unused parameters and imports from RiscvInterrupts.py, RiscvISA.py, and RiscvSystem.py.] [Fixed copyright information in RISC-V files copied from elsewhere that had ARM licenses attached.] [Reorganized instruction definitions in decoder.isa so that they are sorted by opcode in preparation for the addition of ISA extensions M, A, F, D.] [Fixed formatting of several files, removed some variables and instructions that were missed when moving them to other patches, fixed RISC-V Foundation copyright attribution, and fixed history of files copied from other architectures using hg copy.] [Fixed indentation of switch cases in isa.cc.] [Reorganized syscall descriptions in linux/process.cc to remove large number of repeated unimplemented system calls and added implmementations to functions that have received them since it process.cc was first created.] [Fixed spacing for some copyright attributions.] [Replaced the rest of the file copies using hg copy.] [Fixed style check errors and corrected unaligned memory accesses.] [Fix some minor formatting mistakes.] Signed-off by: Alec Roelke
Thanks for the contribution. It looks pretty good! Could you give us a preview as to the other 4 patches? What is missing in this one?
I know nothing of how the ISA stuff works in gem5, but I reviewed most of the other parts of this patch.
Some high-level notes:
a.out probably shouldn't be in the patch.
Make sure you've updated all of the copyright information.
Have you run any of the RISC-V test suite on your code? (https://riscv.org/software-tools/riscv-tests/) In fact, we could probably incorporate some (all?) of that into the regression tests. How much we include depends on how long the tests take.
-
ext/libelf/elf_common.h (Diff revision 1) -
It would be nice if this were aligned with the above.
-
src/arch/riscv/RiscvISA.py (Diff revision 1) -
I didn't see num_threads or num_vpes ever used. If these aren't used they should be removed.
Also, is
systemever used? -
src/arch/riscv/RiscvSystem.py (Diff revision 1) -
For all of these parameters: are they used by the RiscvSystem code? Will they be used in the future?
It looks like you copied a lot of this code from MIPS. If the code isn't applicable to RISC-V, it should be removed.
-
src/arch/riscv/RiscvSystem.py (Diff revision 1) -
Does this mean RISC-V only supports 32 bit? (I noticed the x86 mask is 64-bit.)
-
src/arch/riscv/RiscvSystem.py (Diff revision 1) -
Is this paraemter ever used? I didn't see it.
Description: |
|
|||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+8298 -1) |
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+8067 -2) |
-
src/arch/riscv/RiscvISA.py (Diff revisions 2 - 3) -
Regarding the license edits, the "normal" 3-clause BSD is the bottom two paragraphs.
I would encourage you to add your Copyright notice only for those paragraphs, and not the first one in the files with three. The top paragraph in this and other files with three paragraphs is an ARM addition that is technically an extension to the 3-clause BSD. You have a number of examples throughout the codebase.
Makes sense?
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+8075 -2) |
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 5 (+8075 -2) |
Thanks again for getting this in shape. There are a few minor questions and comment on the patch, the most important one is related to the copyrights.
Also, I assume you have used hg copy for the files that are more or less 1:1 copies from other architectures?
-
ext/libelf/elf_common.h (Diff revision 5) -
Would be good to stick to the same spacing, and not change the AARCH64 line
-
src/arch/riscv/faults.hh (Diff revision 5) -
Could you perhaps elaborate on why this is ok as is?
-
src/arch/riscv/faults.cc (Diff revision 5) -
odd indentation here
-
src/arch/riscv/faults.cc (Diff revision 5) -
odd indentation
-
src/arch/riscv/idle_event.hh (Diff revision 5) -
Not that it matters, but could you update this as well?
-
src/arch/riscv/isa/base.isa (Diff revision 5) -
? Is that a legal entity?
-
src/arch/riscv/isa/bitfields.isa (Diff revision 5) -
Same as above
-
src/arch/riscv/mmapped_ipr.hh (Diff revision 5) -
RISCV has mmapped IPRs?
-
src/arch/riscv/pagetable.hh (Diff revision 5) -
What are the implications?
Also, should this class not inherint from Serializable?
-
src/arch/riscv/process.hh (Diff revision 5) -
ARCH_RISCV_...
-
src/arch/riscv/process.cc (Diff revision 5) -
This block has some formatting issues. Space around operators, and I think it is officially a convention to also keep the operator on the line of the first operand.
-
src/arch/riscv/tlb.cc (Diff revision 5) -
I am really surprise that this and a few other files do not have a Uni Virginia copyright. Is that intentional?
-
src/arch/riscv/tlb.cc (Diff revision 5) -
Not convention
-
src/arch/riscv/tlb.cc (Diff revision 5) -
?
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 6 (+7996 -2) |
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 7 (+6002 -2) |
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 8 (+6002 -2) |
-
ext/libelf/elf_common.h (Diff revision 8) -
I think this particular line should not be changed and the line below should stick with the same spacing.
-
src/arch/riscv/isa_traits.hh (Diff revision 8) -
Was the spacing like this already?
-
src/arch/riscv/microcode_rom.hh (Diff revision 8) -
Was the spacing like this (in this and other files)? I think traditionally we did not align the legal entity names.
-
src/arch/riscv/process.cc (Diff revision 8) -
Is this based on a spec? If so, could you provide a pointer?
-
src/arch/riscv/process.cc (Diff revision 8) -
Not that it really matters, but feel free to use "auto"
-
src/arch/riscv/registers.hh (Diff revision 8) -
Spacing as before
Some minor questions and cosmetic issues.
Could you please also confirm that the files that are copied (and then modified) started out as hg copy (as previously discussed).
Besides that I think this is looking really good. Thanks Alec!
Steve, can we retire Alpha now to make up for the additional build and test time? :-)
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 9 (+6002 -2) |
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 10 (+5967 -1) |
Looks good to me. It would be good if someone else could review this as well.
Sorry for the slow reviewing. I have a few minor changes.
First, when I apply the patch, I get a number of errors from the style checker. Make sure you're using the most up-to-date version of gem5 when you rebase your patch.
Second, when I apply the patch and try to compile, I get a number of errors. Most are about the endianness functions:
build/RISCV/config/the_isa.hh:25:16: error: 'gtoh' is not a member of 'RiscvISA'Third, I'm getting a number of "unused-variable" warnings (errors). If the variables are used for debugging (e.g., in asserts) you can use the macro M5_VAR_USED after the variable name and before the assignment.
I'm not sure if the problem is that you've based this on an older version of gem5, or maybe we're just using different compilers (I'm use gcc-4.8).
Looks good overall! Just a few minor nits, really.
-
ext/libelf/elf_common.h (Diff revision 10) -
misspelled 'Berkeley' :)
-
src/arch/riscv/isa/formats/mem.isa (Diff revision 10) -
space after 'if' (here and below)... even though these aren't C++ files, the C++ code should still follow the style guide
-
src/arch/riscv/isa_traits.hh (Diff revision 10) -
shouldn't this be 'false'? or is the comment incorrect?
-
src/arch/riscv/microcode_rom.hh (Diff revision 10) -
Do you really need a microcode ROM? Seems like this whole file should not be necessary.
Description: |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 11 (+5980 -1) |
Sorry for the delay. I finally got everything working and it looks good to me! I'll start testing the other patches in the series soon.
A few minor things, otherwise it looks pretty good.
-
src/arch/riscv/decoder.hh (Diff revision 11) -
nullptr. Fix throughout.
-
src/arch/riscv/faults.hh (Diff revision 11) -
Are these duplicate values right?
-
src/arch/riscv/faults.hh (Diff revision 11) -
Public/private should be indented 2 spaces. Fix throughout.
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 12 (+5980 -1) |
Ship It!
