Skip to content

Commit d511c1e

Browse files
authored
Use the canonical order of RISC-V extension names (#363)
The RISC-V Instruction Set Manual Vol. 1 specifies the canonical order in which ISA extension names should appear in architecture name strings in Table 1.1 of Chapter 27. However, the repository description and the code state that rv32emu supports RV32IMACF, whereas the correct string in canonical order should be RV32IMAFC. This string may cause problems when used in some tools that need the canonical order of extensions, such as the -march option of GCC. Close #359
1 parent fc3207e commit d511c1e

File tree

5 files changed

+27
-26
lines changed

5 files changed

+27
-26
lines changed

.github/workflows/main.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ jobs:
5757
run: |
5858
make distclean ENABLE_EXT_M=0 check
5959
make distclean ENABLE_EXT_A=0 check
60-
make distclean ENABLE_EXT_C=0 check
6160
make distclean ENABLE_EXT_F=0 check
61+
make distclean ENABLE_EXT_C=0 check
6262
make distclean ENABLE_SDL=0 check
6363
- name: gdbstub test
6464
run: |
@@ -67,8 +67,8 @@ jobs:
6767
run: |
6868
make ENABLE_JIT=1 clean check
6969
make ENABLE_EXT_A=0 ENABLE_JIT=1 clean check
70-
make ENABLE_EXT_C=0 ENABLE_JIT=1 clean check
7170
make ENABLE_EXT_F=0 ENABLE_JIT=1 clean check
71+
make ENABLE_EXT_C=0 ENABLE_JIT=1 clean check
7272
7373
host-arm64:
7474
needs: [detect-code-related-file-changes]
@@ -97,8 +97,8 @@ jobs:
9797
make check
9898
make ENABLE_JIT=1 clean check
9999
make ENABLE_EXT_A=0 ENABLE_JIT=1 clean check
100-
make ENABLE_EXT_C=0 ENABLE_JIT=1 clean check
101100
make ENABLE_EXT_F=0 ENABLE_JIT=1 clean check
101+
make ENABLE_EXT_C=0 ENABLE_JIT=1 clean check
102102
103103
coding-style:
104104
needs: [detect-code-related-file-changes]

Makefile

+12-12
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ CFLAGS += $(CFLAGS_NO_CET)
3535

3636
OBJS_EXT :=
3737

38-
# Control and Status Register (CSR)
39-
ENABLE_Zicsr ?= 1
40-
$(call set-feature, Zicsr)
41-
42-
# Instruction-Fetch Fence
43-
ENABLE_Zifencei ?= 1
44-
$(call set-feature, Zifencei)
45-
4638
# Integer Multiplication and Division instructions
4739
ENABLE_EXT_M ?= 1
4840
$(call set-feature, EXT_M)
@@ -51,10 +43,6 @@ $(call set-feature, EXT_M)
5143
ENABLE_EXT_A ?= 1
5244
$(call set-feature, EXT_A)
5345

54-
# Compressed extension instructions
55-
ENABLE_EXT_C ?= 1
56-
$(call set-feature, EXT_C)
57-
5846
# Single-precision floating point instructions
5947
ENABLE_EXT_F ?= 1
6048
$(call set-feature, EXT_F)
@@ -74,6 +62,18 @@ LDFLAGS += $(SOFTFLOAT_LIB)
7462
LDFLAGS += -lm
7563
endif
7664

65+
# Compressed extension instructions
66+
ENABLE_EXT_C ?= 1
67+
$(call set-feature, EXT_C)
68+
69+
# Control and Status Register (CSR)
70+
ENABLE_Zicsr ?= 1
71+
$(call set-feature, Zicsr)
72+
73+
# Instruction-Fetch Fence
74+
ENABLE_Zifencei ?= 1
75+
$(call set-feature, Zifencei)
76+
7777
# Experimental SDL oriented system calls
7878
ENABLE_SDL ?= 1
7979
ifeq ($(call has, SDL), 1)

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RISC-V RV32I[MACF] emulator
1+
# RISC-V RV32I[MAFC] emulator
22
![GitHub Actions](https://github.com/sysprog21/rv32emu/actions/workflows/main.yml/badge.svg)
33
```
44
/--===============------\
@@ -24,7 +24,7 @@ a focus on efficiency and readability.
2424

2525
Features:
2626
* Fast interpreter for executing the RV32 ISA
27-
* Comprehensive support for RV32I and M, A, C, F extensions
27+
* Comprehensive support for RV32I and M, A, F, C extensions
2828
* Memory-efficient design
2929
* Built-in ELF loader
3030
* Implementation of commonly used newlib system calls
@@ -75,8 +75,8 @@ The image containing all the necessary tools for development and testing can be
7575
`rv32emu` is configurable, and you can override the below variable(s) to fit your expectations:
7676
* `ENABLE_EXT_M`: Standard Extension for Integer Multiplication and Division
7777
* `ENABLE_EXT_A`: Standard Extension for Atomic Instructions
78-
* `ENABLE_EXT_C`: Standard Extension for Compressed Instructions (RV32C.D excluded)
7978
* `ENABLE_EXT_F`: Standard Extension for Single-Precision Floating Point Instructions
79+
* `ENABLE_EXT_C`: Standard Extension for Compressed Instructions (RV32C.D excluded)
8080
* `ENABLE_Zicsr`: Control and Status Register (CSR)
8181
* `ENABLE_Zifencei`: Instruction-Fetch Fence
8282
* `ENABLE_GDBSTUB` : GDB remote debugging support

src/feature.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
#define RV32_FEATURE_EXT_A 1
1818
#endif
1919

20-
/* Standard Extension for Compressed Instructions */
21-
#ifndef RV32_FEATURE_EXT_C
22-
#define RV32_FEATURE_EXT_C 1
23-
#endif
24-
2520
/* Standard Extension for Single-Precision Floating Point Instructions */
2621
#ifndef RV32_FEATURE_EXT_F
2722
#define RV32_FEATURE_EXT_F 1
2823
#endif
2924

25+
/* Standard Extension for Compressed Instructions */
26+
#ifndef RV32_FEATURE_EXT_C
27+
#define RV32_FEATURE_EXT_C 1
28+
#endif
29+
3030
/* Control and Status Register (CSR) */
3131
#ifndef RV32_FEATURE_Zicsr
3232
#define RV32_FEATURE_Zicsr 1

src/riscv.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -467,16 +467,17 @@ void rv_reset(riscv_t *rv, riscv_word_t pc)
467467
#if RV32_HAS(EXT_C)
468468
rv->csr_misa |= MISA_C;
469469
#endif
470-
#if RV32_HAS(EXT_M)
471-
rv->csr_misa |= MISA_M;
472-
#endif
473470
#if RV32_HAS(EXT_F)
474471
rv->csr_misa |= MISA_F;
475472
/* reset float registers */
476473
for (int i = 0; i < N_RV_REGS; i++)
477474
rv->F[i].v = 0;
478475
rv->csr_fcsr = 0;
479476
#endif
477+
#if RV32_HAS(EXT_M)
478+
rv->csr_misa |= MISA_M;
479+
#endif
480+
480481

481482
rv->halt = false;
482483
}

0 commit comments

Comments
 (0)