Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sail support for rvv #149

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
24 changes: 24 additions & 0 deletions .github/workflows/csim&rvfi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on: [push, pull_request]

jobs:
build:
runs-on: [ubuntu-18.04]
steps:
- name: Install opam2
run: |
sudo add-apt-repository -y ppa:avsm/ppa
sudo apt install -y opam zlib1g-dev pkg-config libgmp-dev z3
- name: Init opam
run: opam init --disable-sandboxing -y
- name: Install sail
run: opam install -y sail
- name: Check out repository code
uses: actions/checkout@HEAD
with:
submodules: true
- name: Build RV32 simulators
run: eval $(opam env) && make ARCH=RV32 -j2 csim rvfi
- name: Build RV64 simulators
run: eval $(opam env) && make ARCH=RV64 -j2 csim rvfi
Comment on lines +1 to +24
Copy link
Contributor

@abukharmeh abukharmeh Mar 5, 2022

Choose a reason for hiding this comment

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

I dont think changing workflow script does any good in this instance, if there is an issue with the CI script, that should be addressed elsewhere (issues, seperate PR), I advise you to delete this and keep the original one.

24 changes: 24 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on: [push, pull_request]

jobs:
build:
runs-on: [ubuntu-18.04]
steps:
- name: Install opam2
run: |
sudo add-apt-repository -y ppa:avsm/ppa
sudo apt install -y opam zlib1g-dev pkg-config libgmp-dev z3
- name: Init opam
run: opam init --disable-sandboxing -y
- name: Install sail
run: opam install -y sail
- name: Check out repository code
uses: actions/checkout@HEAD
with:
submodules: true
- name: Build RV32 simulators
run: eval $(opam env) && make ARCH=RV32 -j2 csim rvfi osim
- name: Build RV64 simulators
run: eval $(opam env) && make ARCH=RV64 -j2 csim rvfi osim
Comment on lines +1 to +24
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

22 changes: 18 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ else
endif

SAIL_FLEN := riscv_flen_D.sail
SAIL_VLEN = riscv_vlen.sail

# Instruction sources, depending on target
SAIL_CHECK_SRCS = riscv_addr_checks_common.sail riscv_addr_checks.sail riscv_misa_ext.sail
Expand All @@ -36,6 +37,8 @@ SAIL_DEFAULT_INST += riscv_insts_zks.sail
SAIL_DEFAULT_INST += riscv_insts_zbkb.sail
SAIL_DEFAULT_INST += riscv_insts_zbkx.sail

SAIL_DEFAULT_INST += riscv_insts_vext_total.sail

SAIL_SEQ_INST = $(SAIL_DEFAULT_INST) riscv_jalr_seq.sail
SAIL_RMEM_INST = $(SAIL_DEFAULT_INST) riscv_jalr_rmem.sail riscv_insts_rmem.sail

Expand All @@ -44,6 +47,7 @@ SAIL_RMEM_INST_SRCS = riscv_insts_begin.sail $(SAIL_RMEM_INST) riscv_insts_end.s

# System and platform sources
SAIL_SYS_SRCS = riscv_csr_map.sail
SAIL_SYS_SRCS += riscv_vext_control.sail
SAIL_SYS_SRCS += riscv_next_regs.sail
SAIL_SYS_SRCS += riscv_sys_exceptions.sail # default basic helpers for exception handling
SAIL_SYS_SRCS += riscv_sync_exception.sail # define the exception structure used in the model
Expand All @@ -63,18 +67,21 @@ SAIL_VM_SRCS += $(SAIL_RV64_VM_SRCS)
endif

# Non-instruction sources
PRELUDE = prelude.sail prelude_mapping.sail $(SAIL_XLEN) $(SAIL_FLEN) prelude_mem_metadata.sail prelude_mem.sail
PRELUDE = prelude.sail prelude_mapping.sail $(SAIL_XLEN) $(SAIL_FLEN) $(SAIL_VLEN) prelude_mem_metadata.sail prelude_mem.sail

SAIL_REGS_SRCS = riscv_reg_type.sail riscv_freg_type.sail riscv_regs.sail riscv_pc_access.sail riscv_sys_regs.sail
SAIL_REGS_SRCS += riscv_reg_type_vector.sail riscv_regs_vector.sail
SAIL_REGS_SRCS += riscv_pmp_regs.sail riscv_pmp_control.sail
SAIL_REGS_SRCS += riscv_ext_regs.sail $(SAIL_CHECK_SRCS)
SAIL_REGS_SRCS += riscv_types_vector.sail

SAIL_ARCH_SRCS = $(PRELUDE)
SAIL_ARCH_SRCS += riscv_types_common.sail riscv_types_ext.sail riscv_types.sail
SAIL_ARCH_SRCS += riscv_vmem_types.sail $(SAIL_REGS_SRCS) $(SAIL_SYS_SRCS) riscv_platform.sail
SAIL_ARCH_SRCS += riscv_mem.sail $(SAIL_VM_SRCS)
SAIL_ARCH_RVFI_SRCS = $(PRELUDE) rvfi_dii.sail riscv_types_common.sail riscv_types_ext.sail riscv_types.sail riscv_vmem_types.sail $(SAIL_REGS_SRCS) $(SAIL_SYS_SRCS) riscv_platform.sail riscv_mem.sail $(SAIL_VM_SRCS) riscv_types_kext.sail
SAIL_ARCH_SRCS += riscv_types_kext.sail # Shared/common code for the cryptography extension.
#SAIL_ARCH_SRCS += riscv_types_vector.sail

SAIL_STEP_SRCS = riscv_step_common.sail riscv_step_ext.sail riscv_decode_ext.sail riscv_fetch.sail riscv_step.sail
RVFI_STEP_SRCS = riscv_step_common.sail riscv_step_rvfi.sail riscv_decode_ext.sail riscv_fetch_rvfi.sail riscv_step.sail
Expand Down Expand Up @@ -197,7 +204,14 @@ riscv.smt_model: $(SAIL_SRCS)
cgen: $(SAIL_SRCS) model/main.sail
$(SAIL) -cgen $(SAIL_FLAGS) $(SAIL_SRCS) model/main.sail

generated_definitions/ocaml/$(ARCH)/riscv.ml: $(SAIL_SRCS) Makefile
riscv_vlen: FORCE
ifdef VLEN
ifdef ELEN
python gen_vlen.py $(VLEN) $(ELEN)
endif
endif

generated_definitions/ocaml/$(ARCH)/riscv.ml: riscv_vlen $(SAIL_SRCS) Makefile
mkdir -p generated_definitions/ocaml/$(ARCH)
$(SAIL) $(SAIL_FLAGS) -ocaml -ocaml-nobuild -ocaml_build_dir generated_definitions/ocaml/$(ARCH) -o riscv $(SAIL_SRCS)

Expand Down Expand Up @@ -235,7 +249,7 @@ generated_definitions/ocaml/riscv_duopod_ocaml: $(PRELUDE_SRCS) model/riscv_duop
ocaml_emulator/tracecmp: ocaml_emulator/tracecmp.ml
ocamlfind ocamlopt -annot -linkpkg -package unix $^ -o $@

generated_definitions/c/riscv_model_$(ARCH).c: $(SAIL_SRCS) model/main.sail Makefile
generated_definitions/c/riscv_model_$(ARCH).c: riscv_vlen $(SAIL_SRCS) model/main.sail Makefile
mkdir -p generated_definitions/c
$(SAIL) $(SAIL_FLAGS) -O -Oconstant_fold -memo_z3 -c -c_include riscv_prelude.h -c_include riscv_platform.h -c_no_main $(SAIL_SRCS) model/main.sail -o $(basename $@)

Expand All @@ -248,7 +262,7 @@ $(SOFTFLOAT_LIBS):

# convenience target
.PHONY: csim
csim: c_emulator/riscv_sim_$(ARCH)
csim: c_emulator/riscv_sim_$(ARCH)
Copy link
Contributor

@abukharmeh abukharmeh Mar 5, 2022

Choose a reason for hiding this comment

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

Trim trailing space across all source files !

.PHONY: osim
osim: ocaml_emulator/riscv_ocaml_sim_$(ARCH)
.PHONY: rvfi
Expand Down
8 changes: 4 additions & 4 deletions build_simulators.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ function test_build () {
fi
}

test_build make ARCH=RV32 ocaml_emulator/riscv_ocaml_sim_RV32
test_build make ARCH=RV64 ocaml_emulator/riscv_ocaml_sim_RV64
test_build make ARCH=RV32 ocaml_emulator/riscv_ocaml_sim_RV32 -j24
test_build make ARCH=RV64 ocaml_emulator/riscv_ocaml_sim_RV64 -j24

test_build make ARCH=RV32 c_emulator/riscv_sim_RV32
test_build make ARCH=RV64 c_emulator/riscv_sim_RV64
test_build make ARCH=RV32 c_emulator/riscv_sim_RV32 -j24
test_build make ARCH=RV64 c_emulator/riscv_sim_RV64 -j24

Comment on lines +13 to 18
Copy link
Contributor

@abukharmeh abukharmeh Mar 5, 2022

Choose a reason for hiding this comment

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

I dont see any reason that this is changed to exactly 24 jobs, one could argue that maybe should -j$(nproc), but I advise just to leave it as is here (in this PR) !

18 changes: 16 additions & 2 deletions c_emulator/SoftFloat-3e/build/Linux-386-GCC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ OBJS_OTHERS = \
f16_le_quiet$(OBJ) \
f16_lt_quiet$(OBJ) \
f16_isSignalingNaN$(OBJ) \
f16_classify$(OBJ) \
f32_to_ui32$(OBJ) \
f32_to_ui64$(OBJ) \
f32_to_i32$(OBJ) \
Expand Down Expand Up @@ -220,6 +221,7 @@ OBJS_OTHERS = \
f32_le_quiet$(OBJ) \
f32_lt_quiet$(OBJ) \
f32_isSignalingNaN$(OBJ) \
f32_classify$(OBJ) \
f64_to_ui32$(OBJ) \
f64_to_ui64$(OBJ) \
f64_to_i32$(OBJ) \
Expand Down Expand Up @@ -247,6 +249,7 @@ OBJS_OTHERS = \
f64_le_quiet$(OBJ) \
f64_lt_quiet$(OBJ) \
f64_isSignalingNaN$(OBJ) \
f64_classify$(OBJ) \
extF80M_to_ui32$(OBJ) \
extF80M_to_ui64$(OBJ) \
extF80M_to_i32$(OBJ) \
Expand Down Expand Up @@ -299,12 +302,20 @@ OBJS_OTHERS = \
f128M_le_quiet$(OBJ) \
f128M_lt_quiet$(OBJ) \

OBJS_ALL = $(OBJS_PRIMITIVES) $(OBJS_SPECIALIZE) $(OBJS_OTHERS)
OBJS_RECIPROCAL = \
f16_rsqrte7$(OBJ) \
f16_recip7$(OBJ) \
f32_rsqrte7$(OBJ) \
f32_recip7$(OBJ) \
f64_rsqrte7$(OBJ) \
f64_recip7$(OBJ) \

OBJS_ALL = $(OBJS_PRIMITIVES) $(OBJS_SPECIALIZE) $(OBJS_OTHERS) $(OBJS_RECIPROCAL)

$(OBJS_ALL): \
$(OTHER_HEADERS) platform.h $(SOURCE_DIR)/include/primitiveTypes.h \
$(SOURCE_DIR)/include/primitives.h
$(OBJS_SPECIALIZE) $(OBJS_OTHERS): \
$(OBJS_SPECIALIZE) $(OBJS_OTHERS) $(OBJS_RECIPROCAL): \
$(SOURCE_DIR)/include/softfloat_types.h $(SOURCE_DIR)/include/internals.h \
$(SOURCE_DIR)/$(SPECIALIZE_TYPE)/specialize.h \
$(SOURCE_DIR)/include/softfloat.h
Expand All @@ -315,6 +326,9 @@ $(OBJS_PRIMITIVES) $(OBJS_OTHERS): %$(OBJ): $(SOURCE_DIR)/%.c
$(OBJS_SPECIALIZE): %$(OBJ): $(SOURCE_DIR)/$(SPECIALIZE_TYPE)/%.c
$(COMPILE_C) $(SOURCE_DIR)/$(SPECIALIZE_TYPE)/$*.c

$(OBJS_RECIPROCAL): %$(OBJ): $(SOURCE_DIR)/fall_reciprocal.c
$(COMPILE_C) $(SOURCE_DIR)/fall_reciprocal.c

softfloat$(LIB): $(OBJS_ALL)
$(DELETE) $@
$(MAKELIB) $^
Expand Down
18 changes: 16 additions & 2 deletions c_emulator/SoftFloat-3e/build/Linux-386-SSE2-GCC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ OBJS_OTHERS = \
f16_le_quiet$(OBJ) \
f16_lt_quiet$(OBJ) \
f16_isSignalingNaN$(OBJ) \
f16_classify$(OBJ) \
f32_to_ui32$(OBJ) \
f32_to_ui64$(OBJ) \
f32_to_i32$(OBJ) \
Expand Down Expand Up @@ -220,6 +221,7 @@ OBJS_OTHERS = \
f32_le_quiet$(OBJ) \
f32_lt_quiet$(OBJ) \
f32_isSignalingNaN$(OBJ) \
f32_classify$(OBJ) \
f64_to_ui32$(OBJ) \
f64_to_ui64$(OBJ) \
f64_to_i32$(OBJ) \
Expand Down Expand Up @@ -247,6 +249,7 @@ OBJS_OTHERS = \
f64_le_quiet$(OBJ) \
f64_lt_quiet$(OBJ) \
f64_isSignalingNaN$(OBJ) \
f64_classify$(OBJ) \
extF80M_to_ui32$(OBJ) \
extF80M_to_ui64$(OBJ) \
extF80M_to_i32$(OBJ) \
Expand Down Expand Up @@ -299,12 +302,20 @@ OBJS_OTHERS = \
f128M_le_quiet$(OBJ) \
f128M_lt_quiet$(OBJ) \

OBJS_ALL = $(OBJS_PRIMITIVES) $(OBJS_SPECIALIZE) $(OBJS_OTHERS)
OBJS_RECIPROCAL = \
f16_rsqrte7$(OBJ) \
f16_recip7$(OBJ) \
f32_rsqrte7$(OBJ) \
f32_recip7$(OBJ) \
f64_rsqrte7$(OBJ) \
f64_recip7$(OBJ) \

OBJS_ALL = $(OBJS_PRIMITIVES) $(OBJS_SPECIALIZE) $(OBJS_OTHERS) $(OBJS_RECIPROCAL)

$(OBJS_ALL): \
$(OTHER_HEADERS) platform.h $(SOURCE_DIR)/include/primitiveTypes.h \
$(SOURCE_DIR)/include/primitives.h
$(OBJS_SPECIALIZE) $(OBJS_OTHERS): \
$(OBJS_SPECIALIZE) $(OBJS_OTHERS) $(OBJS_RECIPROCAL): \
$(SOURCE_DIR)/include/softfloat_types.h $(SOURCE_DIR)/include/internals.h \
$(SOURCE_DIR)/$(SPECIALIZE_TYPE)/specialize.h \
$(SOURCE_DIR)/include/softfloat.h
Expand All @@ -315,6 +326,9 @@ $(OBJS_PRIMITIVES) $(OBJS_OTHERS): %$(OBJ): $(SOURCE_DIR)/%.c
$(OBJS_SPECIALIZE): %$(OBJ): $(SOURCE_DIR)/$(SPECIALIZE_TYPE)/%.c
$(COMPILE_C) $(SOURCE_DIR)/$(SPECIALIZE_TYPE)/$*.c

$(OBJS_RECIPROCAL): %$(OBJ): $(SOURCE_DIR)/fall_reciprocal.c
$(COMPILE_C) $(SOURCE_DIR)/fall_reciprocal.c

softfloat$(LIB): $(OBJS_ALL)
$(DELETE) $@
$(MAKELIB) $^
Expand Down
18 changes: 16 additions & 2 deletions c_emulator/SoftFloat-3e/build/Linux-ARM-VFPv2-GCC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ OBJS_OTHERS = \
f16_le_quiet$(OBJ) \
f16_lt_quiet$(OBJ) \
f16_isSignalingNaN$(OBJ) \
f16_classify$(OBJ) \
f32_to_ui32$(OBJ) \
f32_to_ui64$(OBJ) \
f32_to_i32$(OBJ) \
Expand Down Expand Up @@ -218,6 +219,7 @@ OBJS_OTHERS = \
f32_le_quiet$(OBJ) \
f32_lt_quiet$(OBJ) \
f32_isSignalingNaN$(OBJ) \
f32_classify$(OBJ) \
f64_to_ui32$(OBJ) \
f64_to_ui64$(OBJ) \
f64_to_i32$(OBJ) \
Expand Down Expand Up @@ -245,6 +247,7 @@ OBJS_OTHERS = \
f64_le_quiet$(OBJ) \
f64_lt_quiet$(OBJ) \
f64_isSignalingNaN$(OBJ) \
f64_classify$(OBJ) \
extF80M_to_ui32$(OBJ) \
extF80M_to_ui64$(OBJ) \
extF80M_to_i32$(OBJ) \
Expand Down Expand Up @@ -297,12 +300,20 @@ OBJS_OTHERS = \
f128M_le_quiet$(OBJ) \
f128M_lt_quiet$(OBJ) \

OBJS_ALL = $(OBJS_PRIMITIVES) $(OBJS_SPECIALIZE) $(OBJS_OTHERS)
OBJS_RECIPROCAL = \
f16_rsqrte7$(OBJ) \
f16_recip7$(OBJ) \
f32_rsqrte7$(OBJ) \
f32_recip7$(OBJ) \
f64_rsqrte7$(OBJ) \
f64_recip7$(OBJ) \

OBJS_ALL = $(OBJS_PRIMITIVES) $(OBJS_SPECIALIZE) $(OBJS_OTHERS) $(OBJS_RECIPROCAL)

$(OBJS_ALL): \
$(OTHER_HEADERS) platform.h $(SOURCE_DIR)/include/primitiveTypes.h \
$(SOURCE_DIR)/include/primitives.h
$(OBJS_SPECIALIZE) $(OBJS_OTHERS): \
$(OBJS_SPECIALIZE) $(OBJS_OTHERS) $(OBJS_RECIPROCAL): \
$(SOURCE_DIR)/include/softfloat_types.h $(SOURCE_DIR)/include/internals.h \
$(SOURCE_DIR)/$(SPECIALIZE_TYPE)/specialize.h \
$(SOURCE_DIR)/include/softfloat.h
Expand All @@ -313,6 +324,9 @@ $(OBJS_PRIMITIVES) $(OBJS_OTHERS): %$(OBJ): $(SOURCE_DIR)/%.c
$(OBJS_SPECIALIZE): %$(OBJ): $(SOURCE_DIR)/$(SPECIALIZE_TYPE)/%.c
$(COMPILE_C) $(SOURCE_DIR)/$(SPECIALIZE_TYPE)/$*.c

$(OBJS_RECIPROCAL): %$(OBJ): $(SOURCE_DIR)/fall_reciprocal.c
$(COMPILE_C) $(SOURCE_DIR)/fall_reciprocal.c

softfloat$(LIB): $(OBJS_ALL)
$(DELETE) $@
$(MAKELIB) $^
Expand Down
18 changes: 16 additions & 2 deletions c_emulator/SoftFloat-3e/build/Linux-RISCV-GCC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ OBJS_OTHERS = \
f16_le_quiet$(OBJ) \
f16_lt_quiet$(OBJ) \
f16_isSignalingNaN$(OBJ) \
f16_classify$(OBJ) \
f32_to_ui32$(OBJ) \
f32_to_ui64$(OBJ) \
f32_to_i32$(OBJ) \
Expand Down Expand Up @@ -220,6 +221,7 @@ OBJS_OTHERS = \
f32_le_quiet$(OBJ) \
f32_lt_quiet$(OBJ) \
f32_isSignalingNaN$(OBJ) \
f32_classify$(OBJ) \
f64_to_ui32$(OBJ) \
f64_to_ui64$(OBJ) \
f64_to_i32$(OBJ) \
Expand Down Expand Up @@ -249,6 +251,7 @@ OBJS_OTHERS = \
f64_le_quiet$(OBJ) \
f64_lt_quiet$(OBJ) \
f64_isSignalingNaN$(OBJ) \
f64_classify$(OBJ) \
extF80_to_ui32$(OBJ) \
extF80_to_ui64$(OBJ) \
extF80_to_i32$(OBJ) \
Expand Down Expand Up @@ -354,12 +357,20 @@ OBJS_OTHERS = \
f128M_le_quiet$(OBJ) \
f128M_lt_quiet$(OBJ) \

OBJS_ALL = $(OBJS_PRIMITIVES) $(OBJS_SPECIALIZE) $(OBJS_OTHERS)
OBJS_RECIPROCAL = \
f16_rsqrte7$(OBJ) \
f16_recip7$(OBJ) \
f32_rsqrte7$(OBJ) \
f32_recip7$(OBJ) \
f64_rsqrte7$(OBJ) \
f64_recip7$(OBJ) \

OBJS_ALL = $(OBJS_PRIMITIVES) $(OBJS_SPECIALIZE) $(OBJS_OTHERS) $(OBJS_RECIPROCAL)

$(OBJS_ALL): \
$(OTHER_HEADERS) platform.h $(SOURCE_DIR)/include/primitiveTypes.h \
$(SOURCE_DIR)/include/primitives.h
$(OBJS_SPECIALIZE) $(OBJS_OTHERS): \
$(OBJS_SPECIALIZE) $(OBJS_OTHERS) $(OBJS_RECIPROCAL): \
$(SOURCE_DIR)/include/softfloat_types.h $(SOURCE_DIR)/include/internals.h \
$(SOURCE_DIR)/$(SPECIALIZE_TYPE)/specialize.h \
$(SOURCE_DIR)/include/softfloat.h
Expand All @@ -370,6 +381,9 @@ $(OBJS_PRIMITIVES) $(OBJS_OTHERS): %$(OBJ): $(SOURCE_DIR)/%.c
$(OBJS_SPECIALIZE): %$(OBJ): $(SOURCE_DIR)/$(SPECIALIZE_TYPE)/%.c
$(COMPILE_C) $(SOURCE_DIR)/$(SPECIALIZE_TYPE)/$*.c

$(OBJS_RECIPROCAL): %$(OBJ): $(SOURCE_DIR)/fall_reciprocal.c
$(COMPILE_C) $(SOURCE_DIR)/fall_reciprocal.c

softfloat$(LIB): $(OBJS_ALL)
$(DELETE) $@
$(MAKELIB) $^
Expand Down
Loading