From ea5b0f1c41704bbc3fb9ba3c61c37c1f0a0e7a47 Mon Sep 17 00:00:00 2001 From: Jasonyanyusong Date: Sat, 23 Mar 2024 14:10:45 -0700 Subject: [PATCH 1/4] [Temp] Draft of rv32/64 support Now resolving bug related to rv64 toolchain compiled the *bad* rv32 bin --- machines/platform.mk | 2 +- machines/pod_1x1/Makefile.machine.include | 2 + .../pod_1x1_2X2Y/Makefile.machine.include | 2 + .../pod_1x1_2X2Y_64b/Makefile.machine.include | 46 ++++++++++++++++++ .../pod_1x1_4X2Y/Makefile.machine.include | 2 + .../pod_1x1_4X2Y_64b/Makefile.machine.include | 46 ++++++++++++++++++ machines/pod_1x1_64b/Makefile.machine.include | 45 ++++++++++++++++++ .../pod_1x1_hbm2/Makefile.machine.include | 2 + .../pod_1x1_hbm2_64b/Makefile.machine.include | 45 ++++++++++++++++++ machines/pod_4x4/Makefile.machine.include | 2 + machines/pod_4x4_64b/Makefile.machine.include | 47 +++++++++++++++++++ .../pod_4x4_hbm2/Makefile.machine.include | 2 + .../pod_4x4_hbm2_64b/Makefile.machine.include | 47 +++++++++++++++++++ software/mk/Makefile.builddefs | 22 ++++----- software/mk/Makefile.tail_rules | 2 +- software/riscv-tools/Makefile | 14 +++--- 16 files changed, 309 insertions(+), 19 deletions(-) create mode 100644 machines/pod_1x1_2X2Y_64b/Makefile.machine.include create mode 100644 machines/pod_1x1_4X2Y_64b/Makefile.machine.include create mode 100644 machines/pod_1x1_64b/Makefile.machine.include create mode 100644 machines/pod_1x1_hbm2_64b/Makefile.machine.include create mode 100644 machines/pod_4x4_64b/Makefile.machine.include create mode 100644 machines/pod_4x4_hbm2_64b/Makefile.machine.include diff --git a/machines/platform.mk b/machines/platform.mk index 3d2065787..07177e649 100644 --- a/machines/platform.mk +++ b/machines/platform.mk @@ -2,7 +2,7 @@ BSG_PLATFORM ?= vcs ifeq ($(BSG_PLATFORM),vcs) -DEFAULT_MACHINES = pod_1x1 pod_1x1_hbm2 pod_4x4 pod_4x4_hbm2 +DEFAULT_MACHINES = pod_4x4_hbm2 BSG_SIM_BASE = simv else ifeq ($(BSG_PLATFORM),verilator) DEFAULT_MACHINES = pod_1x1_4X2Y diff --git a/machines/pod_1x1/Makefile.machine.include b/machines/pod_1x1/Makefile.machine.include index ef1aacb3c..bac6bccaa 100644 --- a/machines/pod_1x1/Makefile.machine.include +++ b/machines/pod_1x1/Makefile.machine.include @@ -1,6 +1,8 @@ BSG_MACHINE_PODS_X = 1 BSG_MACHINE_PODS_Y = 1 +BSG_MACHINE_XLEN = 32 + BSG_MACHINE_GLOBAL_X = 16 BSG_MACHINE_GLOBAL_Y = 8 diff --git a/machines/pod_1x1_2X2Y/Makefile.machine.include b/machines/pod_1x1_2X2Y/Makefile.machine.include index a264cd7a3..9605f56dc 100644 --- a/machines/pod_1x1_2X2Y/Makefile.machine.include +++ b/machines/pod_1x1_2X2Y/Makefile.machine.include @@ -1,6 +1,8 @@ BSG_MACHINE_PODS_X = 1 BSG_MACHINE_PODS_Y = 1 +BSG_MACHINE_XLEN = 32 + BSG_MACHINE_GLOBAL_X = 2 BSG_MACHINE_GLOBAL_Y = 2 diff --git a/machines/pod_1x1_2X2Y_64b/Makefile.machine.include b/machines/pod_1x1_2X2Y_64b/Makefile.machine.include new file mode 100644 index 000000000..91569053c --- /dev/null +++ b/machines/pod_1x1_2X2Y_64b/Makefile.machine.include @@ -0,0 +1,46 @@ +BSG_MACHINE_PODS_X = 1 +BSG_MACHINE_PODS_Y = 1 + +BSG_MACHINE_XLEN = 64 + +BSG_MACHINE_GLOBAL_X = 2 +BSG_MACHINE_GLOBAL_Y = 2 + +BSG_MACHINE_X_CORD_WIDTH = 7 +BSG_MACHINE_Y_CORD_WIDTH = 7 + +BSG_MACHINE_RUCHE_FACTOR_X = 1 +BSG_MACHINE_BARRIER_RUCHE_FACTOR_X = 1 +BSG_MACHINE_WH_RUCHE_FACTOR = 1 + +BSG_MACHINE_NUM_VCACHE_ROWS = 1 +BSG_MACHINE_VCACHE_SET = 64 +BSG_MACHINE_VCACHE_WAY = 4 +BSG_MACHINE_VCACHE_BLOCK_SIZE_WORDS = 8 +BSG_MACHINE_VCACHE_DMA_DATA_WIDTH = 32 +BSG_MACHINE_NUM_VCACHES_PER_CHANNEL = 2 +BSG_MACHINE_VCACHE_WORD_TRACKING = 1 + + +BSG_MACHINE_DRAM_SIZE_WORDS = 536870912 +BSG_MACHINE_DRAM_BANK_SIZE_WORDS = 16777216 +BSG_MACHINE_DRAM_INCLUDED = 1 + +BSG_MACHINE_MAX_EPA_WIDTH = 28 +BSG_MACHINE_BRANCH_TRACE_EN = 0 +BSG_MACHINE_HETERO_TYPE_VEC = default:0 + +BSG_MACHINE_ORIGIN_Y_CORD = 2 +BSG_MACHINE_ORIGIN_X_CORD = 2 + +BSG_MACHINE_HOST_Y_CORD = 0 +BSG_MACHINE_HOST_X_CORD = 2 + +BSG_MACHINE_NETWORK_CFG = e_network_mesh +BSG_MACHINE_MEM_CFG = e_vcache_test_mem +BSG_MACHINE_DRAMSIM3_PKG = bsg_dramsim3_hbm2_8gb_x128_pkg + +BSG_MACHINE_SUBARRAY_X = 1 +BSG_MACHINE_SUBARRAY_Y = 1 + +BSG_MACHINE_IPOLY_HASHING = 0 diff --git a/machines/pod_1x1_4X2Y/Makefile.machine.include b/machines/pod_1x1_4X2Y/Makefile.machine.include index 5226d0de0..c575ee49a 100644 --- a/machines/pod_1x1_4X2Y/Makefile.machine.include +++ b/machines/pod_1x1_4X2Y/Makefile.machine.include @@ -1,6 +1,8 @@ BSG_MACHINE_PODS_X = 1 BSG_MACHINE_PODS_Y = 1 +BSG_MACHINE_XLEN = 32 + BSG_MACHINE_GLOBAL_X = 4 BSG_MACHINE_GLOBAL_Y = 2 diff --git a/machines/pod_1x1_4X2Y_64b/Makefile.machine.include b/machines/pod_1x1_4X2Y_64b/Makefile.machine.include new file mode 100644 index 000000000..1de0be8c3 --- /dev/null +++ b/machines/pod_1x1_4X2Y_64b/Makefile.machine.include @@ -0,0 +1,46 @@ +BSG_MACHINE_PODS_X = 1 +BSG_MACHINE_PODS_Y = 1 + +BSG_MACHINE_XLEN = 64 + +BSG_MACHINE_GLOBAL_X = 4 +BSG_MACHINE_GLOBAL_Y = 2 + +BSG_MACHINE_X_CORD_WIDTH = 7 +BSG_MACHINE_Y_CORD_WIDTH = 7 + +BSG_MACHINE_RUCHE_FACTOR_X = 3 +BSG_MACHINE_BARRIER_RUCHE_FACTOR_X = 3 +BSG_MACHINE_WH_RUCHE_FACTOR = 2 + +BSG_MACHINE_NUM_VCACHE_ROWS = 1 +BSG_MACHINE_VCACHE_SET = 64 +BSG_MACHINE_VCACHE_WAY = 4 +BSG_MACHINE_VCACHE_BLOCK_SIZE_WORDS = 8 +BSG_MACHINE_VCACHE_DMA_DATA_WIDTH = 32 +BSG_MACHINE_NUM_VCACHES_PER_CHANNEL = 2 +BSG_MACHINE_VCACHE_WORD_TRACKING = 1 + + +BSG_MACHINE_DRAM_SIZE_WORDS = 536870912 +BSG_MACHINE_DRAM_BANK_SIZE_WORDS = 16777216 +BSG_MACHINE_DRAM_INCLUDED = 1 + +BSG_MACHINE_MAX_EPA_WIDTH = 28 +BSG_MACHINE_BRANCH_TRACE_EN = 0 +BSG_MACHINE_HETERO_TYPE_VEC = default:0 + +BSG_MACHINE_ORIGIN_Y_CORD = 2 +BSG_MACHINE_ORIGIN_X_CORD = 4 + +BSG_MACHINE_HOST_Y_CORD = 0 +BSG_MACHINE_HOST_X_CORD = 4 + +BSG_MACHINE_NETWORK_CFG = e_network_half_ruche_x +BSG_MACHINE_MEM_CFG = e_vcache_test_mem +BSG_MACHINE_DRAMSIM3_PKG = bsg_dramsim3_hbm2_8gb_x128_pkg + +BSG_MACHINE_SUBARRAY_X = 1 +BSG_MACHINE_SUBARRAY_Y = 1 + +BSG_MACHINE_IPOLY_HASHING = 0 diff --git a/machines/pod_1x1_64b/Makefile.machine.include b/machines/pod_1x1_64b/Makefile.machine.include new file mode 100644 index 000000000..dd4b5df4b --- /dev/null +++ b/machines/pod_1x1_64b/Makefile.machine.include @@ -0,0 +1,45 @@ +BSG_MACHINE_PODS_X = 1 +BSG_MACHINE_PODS_Y = 1 + +BSG_MACHINE_XLEN = 64 + +BSG_MACHINE_GLOBAL_X = 16 +BSG_MACHINE_GLOBAL_Y = 8 + +BSG_MACHINE_X_CORD_WIDTH = 7 +BSG_MACHINE_Y_CORD_WIDTH = 7 + +BSG_MACHINE_RUCHE_FACTOR_X = 3 +BSG_MACHINE_BARRIER_RUCHE_FACTOR_X = 3 +BSG_MACHINE_WH_RUCHE_FACTOR = 2 + +BSG_MACHINE_NUM_VCACHE_ROWS = 1 +BSG_MACHINE_VCACHE_SET = 64 +BSG_MACHINE_VCACHE_WAY = 4 +BSG_MACHINE_VCACHE_BLOCK_SIZE_WORDS = 8 +BSG_MACHINE_VCACHE_DMA_DATA_WIDTH = 32 +BSG_MACHINE_NUM_VCACHES_PER_CHANNEL = 16 +BSG_MACHINE_VCACHE_WORD_TRACKING = 1 + +BSG_MACHINE_DRAM_SIZE_WORDS = 536870912 +BSG_MACHINE_DRAM_BANK_SIZE_WORDS = 16777216 +BSG_MACHINE_DRAM_INCLUDED = 1 + +BSG_MACHINE_MAX_EPA_WIDTH = 28 +BSG_MACHINE_BRANCH_TRACE_EN = 0 +BSG_MACHINE_HETERO_TYPE_VEC = default:0 + +BSG_MACHINE_ORIGIN_Y_CORD = 8 +BSG_MACHINE_ORIGIN_X_CORD = 16 + +BSG_MACHINE_HOST_Y_CORD = 0 +BSG_MACHINE_HOST_X_CORD = 16 + +BSG_MACHINE_NETWORK_CFG = e_network_half_ruche_x +BSG_MACHINE_MEM_CFG = e_vcache_test_mem +BSG_MACHINE_DRAMSIM3_PKG = bsg_dramsim3_hbm2_8gb_x128_pkg + +BSG_MACHINE_SUBARRAY_X = 1 +BSG_MACHINE_SUBARRAY_Y = 1 + +BSG_MACHINE_IPOLY_HASHING = 1 diff --git a/machines/pod_1x1_hbm2/Makefile.machine.include b/machines/pod_1x1_hbm2/Makefile.machine.include index ba4315be7..e58ee2c1d 100644 --- a/machines/pod_1x1_hbm2/Makefile.machine.include +++ b/machines/pod_1x1_hbm2/Makefile.machine.include @@ -1,6 +1,8 @@ BSG_MACHINE_PODS_X = 1 BSG_MACHINE_PODS_Y = 1 +BSG_MACHINE_XLEN = 32 + BSG_MACHINE_GLOBAL_X = 16 BSG_MACHINE_GLOBAL_Y = 8 diff --git a/machines/pod_1x1_hbm2_64b/Makefile.machine.include b/machines/pod_1x1_hbm2_64b/Makefile.machine.include new file mode 100644 index 000000000..1de810f42 --- /dev/null +++ b/machines/pod_1x1_hbm2_64b/Makefile.machine.include @@ -0,0 +1,45 @@ +BSG_MACHINE_PODS_X = 1 +BSG_MACHINE_PODS_Y = 1 + +BSG_MACHINE_XLEN = 64 + +BSG_MACHINE_GLOBAL_X = 16 +BSG_MACHINE_GLOBAL_Y = 8 + +BSG_MACHINE_X_CORD_WIDTH = 7 +BSG_MACHINE_Y_CORD_WIDTH = 7 + +BSG_MACHINE_RUCHE_FACTOR_X = 3 +BSG_MACHINE_BARRIER_RUCHE_FACTOR_X = 3 +BSG_MACHINE_WH_RUCHE_FACTOR = 2 + +BSG_MACHINE_NUM_VCACHE_ROWS = 1 +BSG_MACHINE_VCACHE_SET = 64 +BSG_MACHINE_VCACHE_WAY = 8 +BSG_MACHINE_VCACHE_BLOCK_SIZE_WORDS = 16 +BSG_MACHINE_VCACHE_DMA_DATA_WIDTH = 32 +BSG_MACHINE_NUM_VCACHES_PER_CHANNEL = $(shell expr $(BSG_MACHINE_GLOBAL_X) \* 2) +BSG_MACHINE_VCACHE_WORD_TRACKING = 1 + +BSG_MACHINE_DRAM_SIZE_WORDS = 268435456 +BSG_MACHINE_DRAM_BANK_SIZE_WORDS = $(shell expr $(BSG_MACHINE_DRAM_SIZE_WORDS) / 2 / $(BSG_MACHINE_GLOBAL_X)) +BSG_MACHINE_DRAM_INCLUDED = 1 + +BSG_MACHINE_MAX_EPA_WIDTH = 28 +BSG_MACHINE_BRANCH_TRACE_EN = 0 +BSG_MACHINE_HETERO_TYPE_VEC = default:0 + +BSG_MACHINE_ORIGIN_Y_CORD = $(BSG_MACHINE_GLOBAL_Y) +BSG_MACHINE_ORIGIN_X_CORD = $(BSG_MACHINE_GLOBAL_X) + +BSG_MACHINE_HOST_Y_CORD = 0 +BSG_MACHINE_HOST_X_CORD = $(BSG_MACHINE_GLOBAL_X) + +BSG_MACHINE_NETWORK_CFG = e_network_half_ruche_x +BSG_MACHINE_MEM_CFG = e_vcache_hbm2 +BSG_MACHINE_DRAMSIM3_PKG = bsg_dramsim3_hbm2_1gb_x64_32ba_pkg + +BSG_MACHINE_SUBARRAY_X = 1 +BSG_MACHINE_SUBARRAY_Y = 1 + +BSG_MACHINE_IPOLY_HASHING = 1 diff --git a/machines/pod_4x4/Makefile.machine.include b/machines/pod_4x4/Makefile.machine.include index 5d839f02d..3fa09ea92 100644 --- a/machines/pod_4x4/Makefile.machine.include +++ b/machines/pod_4x4/Makefile.machine.include @@ -1,6 +1,8 @@ BSG_MACHINE_PODS_X = 4 BSG_MACHINE_PODS_Y = 4 +BSG_MACHINE_XLEN = 32 + BSG_MACHINE_GLOBAL_X = 16 BSG_MACHINE_GLOBAL_Y = 8 diff --git a/machines/pod_4x4_64b/Makefile.machine.include b/machines/pod_4x4_64b/Makefile.machine.include new file mode 100644 index 000000000..f2bbbf9e1 --- /dev/null +++ b/machines/pod_4x4_64b/Makefile.machine.include @@ -0,0 +1,47 @@ +BSG_MACHINE_PODS_X = 4 +BSG_MACHINE_PODS_Y = 4 + +BSG_MACHINE_XLEN = 64 + +BSG_MACHINE_GLOBAL_X = 16 +BSG_MACHINE_GLOBAL_Y = 8 + +BSG_MACHINE_X_CORD_WIDTH = 7 +BSG_MACHINE_Y_CORD_WIDTH = 7 + +BSG_MACHINE_RUCHE_FACTOR_X = 3 +BSG_MACHINE_BARRIER_RUCHE_FACTOR_X = 3 +BSG_MACHINE_WH_RUCHE_FACTOR = 2 + +BSG_MACHINE_NUM_VCACHE_ROWS = 1 +BSG_MACHINE_VCACHE_SET = 64 +BSG_MACHINE_VCACHE_WAY = 4 +BSG_MACHINE_VCACHE_BLOCK_SIZE_WORDS = 8 +BSG_MACHINE_VCACHE_DMA_DATA_WIDTH = 32 +BSG_MACHINE_NUM_VCACHES_PER_CHANNEL = 16 +BSG_MACHINE_VCACHE_WORD_TRACKING = 1 + +BSG_MACHINE_DRAM_SIZE_WORDS = 536870912 +BSG_MACHINE_DRAM_BANK_SIZE_WORDS = 16777216 +BSG_MACHINE_DRAM_INCLUDED = 1 + +BSG_MACHINE_MAX_EPA_WIDTH = 28 +BSG_MACHINE_BRANCH_TRACE_EN = 0 +BSG_MACHINE_HETERO_TYPE_VEC = default:0 + +# possible origin Y = 8, 24,40,56 +# possible origin X = 16,32,48,64 +BSG_MACHINE_ORIGIN_Y_CORD = 8 +BSG_MACHINE_ORIGIN_X_CORD = 16 + +BSG_MACHINE_HOST_Y_CORD = 0 +BSG_MACHINE_HOST_X_CORD = 16 + +BSG_MACHINE_NETWORK_CFG = e_network_half_ruche_x +BSG_MACHINE_MEM_CFG = e_vcache_test_mem +BSG_MACHINE_DRAMSIM3_PKG = bsg_dramsim3_hbm2_8gb_x128_pkg + +BSG_MACHINE_SUBARRAY_X = 1 +BSG_MACHINE_SUBARRAY_Y = 1 + +BSG_MACHINE_IPOLY_HASHING = 1 diff --git a/machines/pod_4x4_hbm2/Makefile.machine.include b/machines/pod_4x4_hbm2/Makefile.machine.include index 74a0efabb..47325e4a8 100644 --- a/machines/pod_4x4_hbm2/Makefile.machine.include +++ b/machines/pod_4x4_hbm2/Makefile.machine.include @@ -1,6 +1,8 @@ BSG_MACHINE_PODS_X = 4 BSG_MACHINE_PODS_Y = 4 +BSG_MACHINE_XLEN = 32 + BSG_MACHINE_GLOBAL_X = 16 BSG_MACHINE_GLOBAL_Y = 8 diff --git a/machines/pod_4x4_hbm2_64b/Makefile.machine.include b/machines/pod_4x4_hbm2_64b/Makefile.machine.include new file mode 100644 index 000000000..3f2f028e8 --- /dev/null +++ b/machines/pod_4x4_hbm2_64b/Makefile.machine.include @@ -0,0 +1,47 @@ +BSG_MACHINE_PODS_X = 4 +BSG_MACHINE_PODS_Y = 4 + +BSG_MACHINE_XLEN = 64 + +BSG_MACHINE_GLOBAL_X = 16 +BSG_MACHINE_GLOBAL_Y = 8 + +BSG_MACHINE_X_CORD_WIDTH = 7 +BSG_MACHINE_Y_CORD_WIDTH = 7 + +BSG_MACHINE_RUCHE_FACTOR_X = 3 +BSG_MACHINE_BARRIER_RUCHE_FACTOR_X = 3 +BSG_MACHINE_WH_RUCHE_FACTOR = 2 + +BSG_MACHINE_NUM_VCACHE_ROWS = 2 +BSG_MACHINE_VCACHE_SET = 64 +BSG_MACHINE_VCACHE_WAY = 4 +BSG_MACHINE_VCACHE_BLOCK_SIZE_WORDS = 16 +BSG_MACHINE_VCACHE_DMA_DATA_WIDTH = 64 +BSG_MACHINE_NUM_VCACHES_PER_CHANNEL = 32 +BSG_MACHINE_VCACHE_WORD_TRACKING = 1 + +BSG_MACHINE_DRAM_SIZE_WORDS = 536870912 +BSG_MACHINE_DRAM_BANK_SIZE_WORDS = 16777216 +BSG_MACHINE_DRAM_INCLUDED = 1 + +BSG_MACHINE_MAX_EPA_WIDTH = 28 +BSG_MACHINE_BRANCH_TRACE_EN = 0 +BSG_MACHINE_HETERO_TYPE_VEC = default:0 + +# possible origin Y = 8, 24,40,56 +# possible origin X = 16,32,48,64 +BSG_MACHINE_ORIGIN_Y_CORD = 8 +BSG_MACHINE_ORIGIN_X_CORD = 16 + +BSG_MACHINE_HOST_Y_CORD = 0 +BSG_MACHINE_HOST_X_CORD = 16 + +BSG_MACHINE_NETWORK_CFG = e_network_half_ruche_x +BSG_MACHINE_MEM_CFG = e_vcache_hbm2 +BSG_MACHINE_DRAMSIM3_PKG = bsg_dramsim3_hbm2_8gb_x128_pkg + +BSG_MACHINE_SUBARRAY_X = 1 +BSG_MACHINE_SUBARRAY_Y = 1 + +BSG_MACHINE_IPOLY_HASHING = 1 diff --git a/software/mk/Makefile.builddefs b/software/mk/Makefile.builddefs index c49512aa2..65c4cffd1 100644 --- a/software/mk/Makefile.builddefs +++ b/software/mk/Makefile.builddefs @@ -56,11 +56,11 @@ ifeq ($(RISCV_BIN_DIR),) $(error RISCV_BIN_DIR not defined) endif -RISCV_GCC ?= $(RISCV_BIN_DIR)/riscv32-unknown-elf-dramfs-gcc -RISCV_GXX ?= $(RISCV_BIN_DIR)/riscv32-unknown-elf-dramfs-g++ +RISCV_GCC ?= $(RISCV_BIN_DIR)/riscv64-unknown-elf-dramfs-gcc +RISCV_GXX ?= $(RISCV_BIN_DIR)/riscv64-unknown-elf-dramfs-g++ RISCV_ELF2HEX ?= LD_LIBRARY_PATH=$(RISCV_BIN_DIR)/../lib $(RISCV_BIN_DIR)/elf2hex -RISCV_OBJCOPY ?= $(RISCV_BIN_DIR)/riscv32-unknown-elf-dramfs-objcopy -RISCV_AR ?= $(RISCV_BIN_DIR)/riscv32-unknown-elf-dramfs-ar +RISCV_OBJCOPY ?= $(RISCV_BIN_DIR)/riscv64-unknown-elf-dramfs-objcopy +RISCV_AR ?= $(RISCV_BIN_DIR)/riscv64-unknown-elf-dramfs-ar RISCV_SIM ?= $(RISCV_BIN_DIR)/spike BSG_ROM_GEN = $(BSG_IP_CORES_DIR)/bsg_mem/bsg_ascii_to_rom.py @@ -83,7 +83,7 @@ vpath %.S $(COMMON_SRC_DIRS) # flags OPT_LEVEL ?= -O2 RISCV_GCC_EXTRA_OPTS ?= -RISCV_GCC_OPTS =-march=$(ARCH_OP) -static -std=gnu99 -ffast-math -fno-common -mtune=bsg_vanilla_2020 +RISCV_GCC_OPTS =-march=$(ARCH_OP) -mabi=$(ABI) -static -std=gnu99 -ffast-math -fno-common -mtune=bsg_vanilla_2020 RISCV_GCC_OPTS +=$(RISCV_GCC_EXTRA_OPTS) -I$(BSG_MANYCORE_DIR)/software/spmd/common/ -I$(BSG_MANYCORE_DIR)/software/bsg_manycore_lib RISCV_GCC_OPTS +=-Dbsg_tiles_X=$(bsg_tiles_X) -Dbsg_tiles_Y=$(bsg_tiles_Y) @@ -124,7 +124,7 @@ LFS_BLOCK_SIZE ?= 128 LFS_BLOCK_COUNT ?= 64 lfs.c: $(IN_FILES) - $(RISCV_BIN_DIR)/../riscv32-unknown-elf-dramfs/bin/dramfs_mklfs $(LFS_BLOCK_SIZE) $(LFS_BLOCK_COUNT) $(IN_FILES) > $@ + $(RISCV_BIN_DIR)/../riscv64-unknown-elf-dramfs/bin/dramfs_mklfs $(LFS_BLOCK_SIZE) $(LFS_BLOCK_COUNT) $(IN_FILES) > $@ endif # Manycore C library archiving rule @@ -230,15 +230,15 @@ $(LLVM_DIR): # Opt can run optimizations in any order, so it doesn't matter %.ll: %.c $(LLVM_DIR) $(RUNTIME_FNS) $(LLVM_CLANG) $(CLANG_TARGET_OPTS) $(RISCV_GCC_OPTS) \ - --sysroot=$(RISCV_BIN_DIR)/../riscv32-unknown-elf-dramfs \ + --sysroot=$(RISCV_BIN_DIR)/../riscv64-unknown-elf-dramfs \ $(OPT_LEVEL) $(spmd_defs) -c -emit-llvm -S $(INCS) $< -o $@ # do the same for C++ sources %.ll: %.cpp $(LLVM_DIR) $(RUNTIME_FNS) $(LLVM_CLANGPP) $(CLANG_TARGET_OPTS) $(RISCV_GXX_OPTS) \ - --sysroot=$(RISCV_BIN_DIR)/../riscv32-unknown-elf-dramfs \ - -I$(RISCV_BIN_DIR)/../riscv32-unknown-elf-dramfs/include/c++/9.2.0 \ - -I$(RISCV_BIN_DIR)/../riscv32-unknown-elf-dramfs/include/c++/9.2.0/riscv32-unknown-elf-dramfs \ + --sysroot=$(RISCV_BIN_DIR)/../riscv64-unknown-elf-dramfs \ + -I$(RISCV_BIN_DIR)/../riscv64-unknown-elf-dramfs/include/c++/9.2.0 \ + -I$(RISCV_BIN_DIR)/../riscv64-unknown-elf-dramfs/include/c++/9.2.0/riscv64-unknown-elf-dramfs \ $(OPT_LEVEL) $(spmd_defs) -c -emit-llvm -S $(INCS) $< -o $@ ifdef ENABLE_LLVM_PASSES @@ -319,7 +319,7 @@ SKIP_ZEROS ?= 0 python $(HEX2BIN) $< 32 > $@ %.dis: %.riscv - $(RISCV_BIN_DIR)/riscv32-unknown-elf-dramfs-objdump -M numeric --disassemble-all -S $< + $(RISCV_BIN_DIR)/riscv64-unknown-elf-dramfs-objdump -M numeric --disassemble-all -S $< PROG_NAME ?= main diff --git a/software/mk/Makefile.tail_rules b/software/mk/Makefile.tail_rules index 788f26b9e..3f4f362c5 100644 --- a/software/mk/Makefile.tail_rules +++ b/software/mk/Makefile.tail_rules @@ -18,7 +18,7 @@ query_vcs_licenses: make -C $(CAD_DIR) USE_EE=$(USE_EE) -f cadenv_debug.mk $@ pp_trace: - $(TRACE_PP_SCRIPT) vanilla.log $(PROG_NAME).riscv $(RISCV_BIN_DIR)/riscv32-unknown-elf-objdump + $(TRACE_PP_SCRIPT) vanilla.log $(PROG_NAME).riscv $(RISCV_BIN_DIR)/riscv64-unknown-elf-objdump pp_spike_trace: cat spike.log | tr '\n' '@' | sed 's/@3/; /g' | sed 's/@/\n/g' > spike_pp.log diff --git a/software/riscv-tools/Makefile b/software/riscv-tools/Makefile index 6ae180c86..938247c5b 100644 --- a/software/riscv-tools/Makefile +++ b/software/riscv-tools/Makefile @@ -27,9 +27,9 @@ # .DEFAULT_GOAL := help -TARGET_ARCH := rv32imaf -TARGET_ABI := ilp32f -TARGET_CFLAGS := '-fno-common' +TARGET_MULTILIB := rv32imaf-ilp32f-- rv64imaf-lp64f-- +TARGET_CFLAGS := '-fno-common -mstrict-align -mcmodel=medany' +TARGET_CXXFLAGS := '-fno-common -mstrict-align -mcmodel=medany' TOOLCHAIN_REPO := riscv-gnu-toolchain TOOLCHAIN_URL := https://github.com/bespoke-silicon-group/$(TOOLCHAIN_REPO) @@ -135,14 +135,16 @@ configure-riscv-gnu-tools: @echo "=====================================" @echo "Configuring toolchain..." @echo "=====================================" - cd riscv-gnu-toolchain && \ - ./configure --prefix=$(RISCV) --disable-linux --with-arch=$(TARGET_ARCH) --with-abi=$(TARGET_ABI) --disable-gdb --with-tune=bsg_vanilla_2020 + ./$(TOOLCHAIN_REPO)/riscv-gcc/gcc/config/riscv/multilib-generator $(TARGET_MULTILIB) > $(TOOLCHAIN_REPO)/riscv-gcc/gcc/config/riscv/t-elf-multilib && \ + cd riscv-gnu-toolchain && \ + ./configure --prefix=$(RISCV) --disable-linux --enable-multilib --disable-gdb --with-tune=bsg_vanilla_2020 --with-cmodel=medany build-riscv-gnu-tools: configure-riscv-gnu-tools @echo "=====================================" @echo "Building toolchain..." @echo "=====================================" - cd riscv-gnu-toolchain && $(MAKE) -j 16 CFLAGS_FOR_TARGET_EXTRA=$(TARGET_CFLAGS) + cd riscv-gnu-toolchain && \ + $(MAKE) -j 16 CFLAGS_FOR_TARGET_EXTRA=$(TARGET_CFLAGS) CXXFLAGS_FOR_TARGET_EXTRA=$(TARGET_CXXFLAGS) build-spike: @echo "=====================================" From 0fc6de4ac28b1076679dbf127e5c47994ca5ef04 Mon Sep 17 00:00:00 2001 From: Jasonyanyusong Date: Mon, 25 Mar 2024 08:09:53 -0700 Subject: [PATCH 2/4] update: rv32 compiling bug fixed, now work on support in rv64 --- software/mk/Makefile.builddefs | 5 +++-- software/py/bsg_manycore_link_gen.py | 15 ++++++++++++--- software/py/nbf.py | 4 +++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/software/mk/Makefile.builddefs b/software/mk/Makefile.builddefs index 65c4cffd1..45d21f6a9 100644 --- a/software/mk/Makefile.builddefs +++ b/software/mk/Makefile.builddefs @@ -164,7 +164,7 @@ endif LINK_SCRIPT ?= $(CURR_DIR)/bsg_link.ld $(CURR_DIR)/bsg_link.ld: $(LINK_GEN) - python $(LINK_GEN) $(LINK_GEN_OPTS) --out=$@ + python $(LINK_GEN) $(LINK_GEN_OPTS) --xlen=32 --out=$@ RISCV_LINK_OPTS ?= @@ -313,7 +313,8 @@ SKIP_ZEROS ?= 0 $(bsg_pods_X) $(bsg_pods_Y) \ $(SKIP_DRAM_INSTRUCTION_LOAD) \ $(SKIP_ZEROS) \ - $(BSG_MACHINE_IPOLY_HASHING) > $*.nbf + $(BSG_MACHINE_IPOLY_HASHING) \ + $(BSG_MACHINE_XLEN) > $*.nbf %.bin: %.hex python $(HEX2BIN) $< 32 > $@ diff --git a/software/py/bsg_manycore_link_gen.py b/software/py/bsg_manycore_link_gen.py index 720cb517f..417f60242 100755 --- a/software/py/bsg_manycore_link_gen.py +++ b/software/py/bsg_manycore_link_gen.py @@ -44,16 +44,18 @@ class bsg_manycore_link_gen: "/*********************************************************\n" \ + " BSG Manycore Linker Script \n\n" - def __init__(self, default_data_loc, dram_size, imem_size, sp): + def __init__(self, default_data_loc, dram_size, imem_size, sp, xlen): self._default_data_loc = default_data_loc self._dram_size = dram_size self._imem_size = imem_size self._sp = sp + self._xlen = xlen self._opening_comment += \ " data default: {0}\n".format(default_data_loc) \ + " dram memory size: 0x{0:08x}\n".format(dram_size) \ + " imem allocated size: 0x{0:08x}\n".format(imem_size) \ + " stack pointer init: 0x{0:08x}\n".format(sp) \ + + " RISC-V XLEN: {0}".format(xlen)\ + "\n" \ + " Generated at " + str(datetime.now()) + "\n" \ + "**********************************************************/\n" @@ -235,7 +237,10 @@ def script(self): # .text section virtual address starts at 0x0 but # loaded at 0x80000000 if sec == ".text.dram": - vaddr = "0x0" + if self._xlen == '32': + vaddr = "0x0" + else: + vaddr = "0x80000000" # Append .dram to output section name if re.search(".dram$", sec) == None and self._default_data_loc == 'dram': @@ -315,12 +320,16 @@ def script(self): parser.add_argument('--out', help = 'Output file name', default = None) + parser.add_argument('--xlen', + help = 'RISC-V XLEN', + default = '32', + choices = ['32', '64']) args = parser.parse_args() # Generate linker script link_gen = bsg_manycore_link_gen(args.default_data_loc, args.dram_size, - args.imem_size, args.sp) + args.imem_size, args.sp, args.xlen) if args.out is None: print(link_gen.script()) diff --git a/software/py/nbf.py b/software/py/nbf.py index 6370a9e61..23ef31f27 100644 --- a/software/py/nbf.py +++ b/software/py/nbf.py @@ -536,7 +536,7 @@ def dump(self): # if __name__ == "__main__": - if len(sys.argv) == 23: + if len(sys.argv) == 24: # config setting config = { "riscv_file" : sys.argv[1], @@ -562,6 +562,7 @@ def dump(self): "skip_dram_instruction_load": int(sys.argv[20]), "skip_zeros": int(sys.argv[21]), "ipoly_hashing": int(sys.argv[22]), + "riscv_xlen" : int(sys.argv[23]), } converter = NBF(config) @@ -578,5 +579,6 @@ def dump(self): command += "{skip_dram_instruction_load} " command += "{skip_zeros} " command += "{ipoly_hashing} " + command += "{riscv_xlen} " print(command) From 815c90448772bedd48fad55ea24bba744579bff1 Mon Sep 17 00:00:00 2001 From: Jasonyanyusong Date: Mon, 25 Mar 2024 08:25:24 -0700 Subject: [PATCH 3/4] update: support multiarch --- software/mk/Makefile.builddefs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/software/mk/Makefile.builddefs b/software/mk/Makefile.builddefs index 45d21f6a9..17ce49467 100644 --- a/software/mk/Makefile.builddefs +++ b/software/mk/Makefile.builddefs @@ -1,8 +1,16 @@ ######################################################### # Chip Architecture -ARCH_OP=rv32imaf -ABI=ilp32f +# read BSG_MACHINE_XLEN from machine's Makefile +ifeq ($(BSG_MACHINE_XLEN), 64) + ARCH_OP=rv64imaf + ABI=lp64f + ARCH_NAME=riscv64 +else + ARCH_OP=rv32imaf + ABI=ilp32f + ARCH_NAME=riscv32 +endif ####################################################### @@ -164,7 +172,7 @@ endif LINK_SCRIPT ?= $(CURR_DIR)/bsg_link.ld $(CURR_DIR)/bsg_link.ld: $(LINK_GEN) - python $(LINK_GEN) $(LINK_GEN_OPTS) --xlen=32 --out=$@ + python $(LINK_GEN) $(LINK_GEN_OPTS) --xlen=$(BSG_MACHINE_XLEN) --out=$@ RISCV_LINK_OPTS ?= @@ -204,12 +212,12 @@ LLVM_CLANG ?= $(LLVM_DIR)/bin/clang LLVM_CLANGPP ?= $(LLVM_DIR)/bin/clang++ LLVM_OPT ?= $(LLVM_DIR)/bin/opt LLVM_LLC ?= $(LLVM_DIR)/bin/llc -CLANG_TARGET_OPTS ?= --target=riscv32 -march=$(ARCH_OP) -mabi=$(ABI) +CLANG_TARGET_OPTS ?= --target=$(ARCH_NAME) -march=$(ARCH_OP) -mabi=$(ABI) # Ideally LLC should infer targets option provided to Clang. But LLC 11.0.0 fails # to infer the architecture extensions correctly. Hence the information is repeated # in LLC target options below. -LLC_TARGET_OPTS ?= -march=riscv32 -mcpu=hb-rv32 -mattr=+m,+a,+f +LLC_TARGET_OPTS ?= -march=$(ARCH_NAME) -mcpu=hb-rv$(BSG_MACHINE_XLEN) -mattr=+m,+a,+f ifdef ENABLE_LLVM_PASSES PASS_DIR ?= $(BSG_MANYCORE_DIR)/software/manycore-llvm-pass From c2e21494736bfb2fb9c9f92df85acf4683b45274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=9F=E9=9B=A8=E6=9D=BE=20Yan=20Yusong?= <75596608+Jasonyanyusong@users.noreply.github.com> Date: Mon, 25 Mar 2024 09:53:52 -0700 Subject: [PATCH 4/4] Update platform.mk revert change of default machines --- machines/platform.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machines/platform.mk b/machines/platform.mk index 07177e649..3d2065787 100644 --- a/machines/platform.mk +++ b/machines/platform.mk @@ -2,7 +2,7 @@ BSG_PLATFORM ?= vcs ifeq ($(BSG_PLATFORM),vcs) -DEFAULT_MACHINES = pod_4x4_hbm2 +DEFAULT_MACHINES = pod_1x1 pod_1x1_hbm2 pod_4x4 pod_4x4_hbm2 BSG_SIM_BASE = simv else ifeq ($(BSG_PLATFORM),verilator) DEFAULT_MACHINES = pod_1x1_4X2Y