diff --git a/.travis.yml b/.travis.yml index d652b27f..20f03e68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,9 @@ jobs: - stage: test name: coverage script: cp -r $PWD ../build_coverage && cd ../build_coverage && ./ci/travis_run.py ./ci/regression.sh -coverage + - stage: test + name: coverage64 + script: cp -r $PWD ../build_coverage && cd ../build_coverage && ./ci/travis_run.py ./ci/regression64.sh -coverage - stage: test name: tex script: cp -r $PWD ../build_tex && cd ../build_tex && ./ci/travis_run.py ./ci/regression.sh -tex diff --git a/ci/regression.sh b/ci/regression.sh index b99754af..359402b0 100755 --- a/ci/regression.sh +++ b/ci/regression.sh @@ -15,7 +15,7 @@ make -C tests/riscv/isa run-rtlsim make -C tests/regression run-vlsim make -C tests/opencl run-vlsim make -C tests/runtime run-simx -make -C tests/riscv/isa run-simx +make -C tests/riscv/isa run-simx-32imf make -C tests/regression run-simx make -C tests/opencl run-simx diff --git a/ci/toolchain_install.sh b/ci/toolchain_install.sh index 4aeef0a4..94fdefab 100755 --- a/ci/toolchain_install.sh +++ b/ci/toolchain_install.sh @@ -20,6 +20,19 @@ riscv() rm -rf riscv-gnu-toolchain } +riscv64() +{ + for x in {a..j} + do + wget $REPOSITORY/riscv-gnu-toolchain/ubuntu/bionic/riscv64-gnu-toolchain.tar.bz2.parta$x + done + cat riscv64-gnu-toolchain.tar.bz2.parta* > riscv64-gnu-toolchain.tar.bz2 + tar -xvf riscv64-gnu-toolchain.tar.bz2 + rm -f riscv64-gnu-toolchain.tar.bz2* + cp -r riscv64-gnu-toolchain $DESTDIR + rm -rf riscv64-gnu-toolchain +} + llvm() { for x in {a..b} @@ -53,7 +66,7 @@ verilator() usage() { - echo "usage: toolchain_install [[-riscv] [-llvm] [-pocl] [-verilator] [-all] [-h|--help]]" + echo "usage: toolchain_install [[-riscv] [-riscv64] [-llvm] [-pocl] [-verilator] [-all] [-h|--help]]" } while [ "$1" != "" ]; do @@ -64,6 +77,8 @@ while [ "$1" != "" ]; do ;; -riscv ) riscv ;; + -riscv64 ) riscv64 + ;; -llvm ) llvm ;; -all ) riscv diff --git a/runtime/Makefile b/runtime/Makefile index 8e1ec0a5..4c0241aa 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -1,12 +1,25 @@ -RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain -RISCV64_TOOLCHAIN_PATH ?= /nethome/ssrivatsan/riscv/ +XLEN ?= 32 -CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc -AR = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc-ar -DP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objdump -CP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objcopy +ifeq ($(XLEN),32) +RISCV_TOOLCHAIN_PATH = /opt/riscv-gnu-toolchain +else +RISCV_TOOLCHAIN_PATH = /opt/riscv64-gnu-toolchain +endif -CFLAGS += -O3 -march=rv32imf -mabi=ilp32f -mcmodel=medany -Wstack-usage=1024 -fno-exceptions -fdata-sections -ffunction-sections +RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf- + +CC = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)gcc +AR = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)gcc-ar +DP = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)objdump +CP = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)objcopy + +ifeq ($(XLEN),32) +CFLAGS += -march=rv32imf -mabi=ilp32f +else +CFLAGS += -march=rv64imfd -mabi=lp64d +endif + +CFLAGS += -O3 -mcmodel=medany -Wstack-usage=1024 -fno-exceptions -fdata-sections -ffunction-sections CFLAGS += -I./include -I../hw PROJECT = libvortexrt diff --git a/runtime/linker/vx_link.ld b/runtime/linker/vx_link.ld deleted file mode 100644 index 53fe7521..00000000 --- a/runtime/linker/vx_link.ld +++ /dev/null @@ -1,254 +0,0 @@ -/* ---- Original Script: /opt/riscv32i/riscv32-unknown-elf/lib/ldscripts/elf32lriscv.x ---- */ -/* Default linker script, for normal executables */ -/* Copyright (C) 2014-2017 Free Software Foundation, Inc. - Copying and distribution of this script, with or without modification, - are permitted in any medium without royalty provided the copyright - notice and this notice are preserved. */ -OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv") -OUTPUT_ARCH(riscv) -ENTRY(_start) -SECTIONS -{ - . = 0x80000000; - .interp : { *(.interp) } - .note.gnu.build-id : { *(.note.gnu.build-id) } - .hash : { *(.hash) } - .gnu.hash : { *(.gnu.hash) } - .dynsym : { *(.dynsym) } - .dynstr : { *(.dynstr) } - .gnu.version : { *(.gnu.version) } - .gnu.version_d : { *(.gnu.version_d) } - .gnu.version_r : { *(.gnu.version_r) } - .rela.dyn : - { - *(.rela.init) - *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) - *(.rela.fini) - *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) - *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) - *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) - *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) - *(.rela.ctors) - *(.rela.dtors) - *(.rela.got) - *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) - *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) - *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) - *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) - *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) - PROVIDE_HIDDEN (__rela_iplt_start = .); - *(.rela.iplt) - PROVIDE_HIDDEN (__rela_iplt_end = .); - } - .rela.plt : - { - *(.rela.plt) - } - .init : - { - KEEP (*(SORT_NONE(.init))) - } - .plt : { *(.plt) } - .iplt : { *(.iplt) } - .text : - { - *(.text.unlikely .text.*_unlikely .text.unlikely.*) - *(.text.exit .text.exit.*) - *(.text.startup .text.startup.*) - *(.text.hot .text.hot.*) - *(.text .stub .text.* .gnu.linkonce.t.*) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - } - .fini : - { - KEEP (*(SORT_NONE(.fini))) - } - PROVIDE (__etext = .); - PROVIDE (_etext = .); - PROVIDE (etext = .); - .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } - .rodata1 : { *(.rodata1) } - .sdata2 : - { - *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) - } - .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } - .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) } - .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } - .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } - .gnu_extab : ONLY_IF_RO { *(.gnu_extab*) } - /* These sections are generated by the Sun/Oracle C++ compiler. */ - .exception_ranges : ONLY_IF_RO { *(.exception_ranges*) } - /* Adjust the address for the data segment. We want to adjust up to - the same address within the page on the next page up. */ - . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); - /* Exception handling */ - .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } - .gnu_extab : ONLY_IF_RW { *(.gnu_extab) } - .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } - .exception_ranges : ONLY_IF_RW { *(.exception_ranges*) } - /* Thread Local Storage sections */ - .tdata : - { - PROVIDE_HIDDEN (__tdata_start = .); - *(.tdata .tdata.* .gnu.linkonce.td.*) - } - .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) - KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) - PROVIDE_HIDDEN (__init_array_end = .); - } - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) - KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) - PROVIDE_HIDDEN (__fini_array_end = .); - } - .ctors : - { - /* gcc uses crtbegin.o to find the start of - the constructors, so we make sure it is - first. Because this is a wildcard, it - doesn't matter if the user does not - actually link against crtbegin.o; the - linker won't look for a file to match a - wildcard. The wildcard also means that it - doesn't matter which directory crtbegin.o - is in. */ - KEEP (*crtbegin.o(.ctors)) - KEEP (*crtbegin?.o(.ctors)) - /* We don't want to include the .ctor section from - the crtend.o file until after the sorted ctors. - The .ctor section from the crtend file contains the - end of ctors marker and it must be last */ - KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) - } - .dtors : - { - KEEP (*crtbegin.o(.dtors)) - KEEP (*crtbegin?.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) - } - .jcr : { KEEP (*(.jcr)) } - .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) } - .dynamic : { *(.dynamic) } - . = DATA_SEGMENT_RELRO_END (0, .); - .data : - { - __DATA_BEGIN__ = .; - *(.data .data.* .gnu.linkonce.d.*) - SORT(CONSTRUCTORS) - } - .data1 : { *(.data1) } - .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } - /* We want the small data sections together, so single-instruction offsets - can access them all, and initialized data all before uninitialized, so - we can shorten the on-disk segment size. */ - .sdata : - { - __SDATA_BEGIN__ = .; - *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*) - *(.sdata .sdata.* .gnu.linkonce.s.*) - } - _edata = .; PROVIDE (edata = .); - . = .; - __bss_start = .; - .sbss : - { - *(.dynsbss) - *(.sbss .sbss.* .gnu.linkonce.sb.*) - *(.scommon) - } - .bss : - { - *(.dynbss) - *(.bss .bss.* .gnu.linkonce.b.*) - *(COMMON) - /* Align here to ensure that the .bss section occupies space up to - _end. Align after .bss to ensure correct alignment even if the - .bss section disappears because there are no input sections. - FIXME: Why do we need it? When there is no .bss section, we do not - pad the .data section. */ - . = ALIGN(. != 0 ? 32 / 8 : 1); - } - . = ALIGN(32 / 8); - . = SEGMENT_START("ldata-segment", .); - . = ALIGN(32 / 8); - __BSS_END__ = .; - __global_pointer = MIN(__SDATA_BEGIN__ + 0x800, - MAX(__DATA_BEGIN__ + 0x800, __BSS_END__ - 0x800)); - _end = .; PROVIDE (end = .); - . = DATA_SEGMENT_END (.); - - /* .stack_dummy section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections, and assign - * values to stack symbols later */ - .stack_dummy (COPY): - { - KEEP(*(.stack*)) - } - __stack_usage = SIZEOF(.stack_dummy); - PROVIDE(__stack_top = 0xFF000000); - PROVIDE(__stack_size = 0x400); - PROVIDE(__stack = __stack_top); - ASSERT(__stack_usage <= __stack_size, "stack overflow") - - /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - .gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) } - /* DWARF debug sections. - Symbols in the DWARF debugging sections are relative to the beginning - of the section so we begin them at 0. */ - /* DWARF 1 */ - .debug 0 : { *(.debug) } - .line 0 : { *(.line) } - /* GNU DWARF 1 extensions */ - .debug_srcinfo 0 : { *(.debug_srcinfo) } - .debug_sfnames 0 : { *(.debug_sfnames) } - /* DWARF 1.1 and DWARF 2 */ - .debug_aranges 0 : { *(.debug_aranges) } - .debug_pubnames 0 : { *(.debug_pubnames) } - /* DWARF 2 */ - .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } - .debug_abbrev 0 : { *(.debug_abbrev) } - .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) } - .debug_frame 0 : { *(.debug_frame) } - .debug_str 0 : { *(.debug_str) } - .debug_loc 0 : { *(.debug_loc) } - .debug_macinfo 0 : { *(.debug_macinfo) } - /* SGI/MIPS DWARF 2 extensions */ - .debug_weaknames 0 : { *(.debug_weaknames) } - .debug_funcnames 0 : { *(.debug_funcnames) } - .debug_typenames 0 : { *(.debug_typenames) } - .debug_varnames 0 : { *(.debug_varnames) } - /* DWARF 3 */ - .debug_pubtypes 0 : { *(.debug_pubtypes) } - .debug_ranges 0 : { *(.debug_ranges) } - /* DWARF Extension. */ - .debug_macro 0 : { *(.debug_macro) } - .debug_addr 0 : { *(.debug_addr) } - .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } - /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } - -} diff --git a/sim/simx/decode.cpp b/sim/simx/decode.cpp index 22bbe5f0..8cde32f8 100644 --- a/sim/simx/decode.cpp +++ b/sim/simx/decode.cpp @@ -488,9 +488,9 @@ std::shared_ptr Decoder::decode(Word code) const { case Opcode::I_INST: if (func3 == 0x1 || func3 == 0x5) { // int5 (XLEN = 32) / int6 (XLEN = 64) - int shamt_width = log2up(XLEN); - int shamt = ((func7 & 0x1) << 5) | rs2; - instr->setImm(sext(shamt, shamt_width)); + XWord shamt_mask = (1 << log2up(XLEN)) - 1; + XWord shamt = (((func7 & 0x1) << 5) | rs2) & shamt_mask; + instr->setImm(shamt); } else { // int12 instr->setImm(sext(code >> shift_rs2_, 12)); @@ -499,7 +499,8 @@ std::shared_ptr Decoder::decode(Word code) const { case Opcode::I_INST_64: if (func3 == 0x1 || func3 == 0x5) { // int5 - instr->setImm(sext64(rs2, 5)); + XWord shamt = rs2; + instr->setImm(shamt); } else { // int12 instr->setImm(sext64(code >> shift_rs2_, 12)); diff --git a/sim/simx/execute.cpp b/sim/simx/execute.cpp index 37fda9ae..e954c789 100644 --- a/sim/simx/execute.cpp +++ b/sim/simx/execute.cpp @@ -256,15 +256,18 @@ void Warp::execute(const Instr &instr, pipeline_trace_t *trace) { // RV32I: XOR rddata[t] = rsdata[t][0] ^ rsdata[t][1]; break; - case 5: + case 5: { + XWord shamt_mask = (1 << log2up(XLEN)) - 1; + XWord shamt = rsdata[t][1] & shamt_mask; if (func7) { // RV32I: SRA - rddata[t] = XWordI(rsdata[t][0]) >> XWordI(rsdata[t][1]); + rddata[t] = XWordI(rsdata[t][0]) >> shamt; } else { // RV32I: SRL - rddata[t] = XWord(rsdata[t][0]) >> XWord(rsdata[t][1]); + rddata[t] = XWord(rsdata[t][0]) >> shamt; } break; + } case 6: // RV32I: OR rddata[t] = rsdata[t][0] | rsdata[t][1]; @@ -315,7 +318,7 @@ void Warp::execute(const Instr &instr, pipeline_trace_t *trace) { rddata[t] = result; } else { // RV64I: SRLI - XWord result = rsdata[t][0] >> immsrc; + XWord result = XWord(rsdata[t][0]) >> immsrc; rddata[t] = result; } break; @@ -413,15 +416,18 @@ void Warp::execute(const Instr &instr, pipeline_trace_t *trace) { // RV64I: SLLW rddata[t] = sext64((Word)rsdata[t][0] << (Word)rsdata[t][1], 32); break; - case 5: + case 5: { + Word shamt_mask = 0x1F; + Word shamt = rsdata[t][1] & shamt_mask; if (func7) { // RV64I: SRAW - rddata[t] = sext64((WordI)rsdata[t][0] >> (WordI)rsdata[t][1], 32); + rddata[t] = sext64((WordI)rsdata[t][0] >> shamt, 32); } else { // RV64I: SRLW - rddata[t] = sext64((Word)rsdata[t][0] >> (Word)rsdata[t][1], 32); + rddata[t] = sext64((Word)rsdata[t][0] >> shamt, 32); } break; + } default: std::abort(); } @@ -449,11 +455,11 @@ void Warp::execute(const Instr &instr, pipeline_trace_t *trace) { case 5: if (func7) { // RV64I: SRAIW - XWord result = sext64((WordI)rsdata[t][0] >> (WordI)immsrc, 32); + XWord result = sext64((WordI)rsdata[t][0] >> immsrc, 32); rddata[t] = result; } else { // RV64I: SRLIW - XWord result = sext64((Word)rsdata[t][0] >> (Word)immsrc, 32); + XWord result = sext64((Word)rsdata[t][0] >> immsrc, 32); rddata[t] = result; } break; diff --git a/tests/runtime/fibonacci/Makefile b/tests/runtime/fibonacci/Makefile index 1ea96718..8d9f0605 100644 --- a/tests/runtime/fibonacci/Makefile +++ b/tests/runtime/fibonacci/Makefile @@ -1,15 +1,29 @@ -RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain +XLEN ?= 32 + +ifeq ($(XLEN),32) +RISCV_TOOLCHAIN_PATH = /opt/riscv-gnu-toolchain +else +RISCV_TOOLCHAIN_PATH = /opt/riscv64-gnu-toolchain +endif + +RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf- VORTEX_RT_PATH ?= $(realpath ../../../runtime) -CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc -AR = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc-ar -DP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objdump -CP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objcopy +CC = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)gcc +AR = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)gcc-ar +DP = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)objdump +CP = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)objcopy -CFLAGS += -march=rv32imf -mabi=ilp32f -O3 -Wstack-usage=1024 -ffreestanding -nostartfiles -fdata-sections -ffunction-sections +ifeq ($(XLEN),32) +CFLAGS += -march=rv32imf -mabi=ilp32f +else +CFLAGS += -march=rv64imfd -mabi=lp64d +endif + +CFLAGS += -O3 -Wstack-usage=1024 -mcmodel=medany -ffreestanding -nostartfiles -fdata-sections -ffunction-sections CFLAGS += -I$(VORTEX_RT_PATH)/include -I$(VORTEX_RT_PATH)/../hw -LDFLAGS += -lm -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld -Wl,--gc-sections $(VORTEX_RT_PATH)/libvortexrt.a +LDFLAGS += -lm -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link$(XLEN).ld -Wl,--gc-sections $(VORTEX_RT_PATH)/libvortexrt.a PROJECT = fibonacci diff --git a/tests/runtime/hello/Makefile b/tests/runtime/hello/Makefile index 708dc7c3..6150d445 100644 --- a/tests/runtime/hello/Makefile +++ b/tests/runtime/hello/Makefile @@ -1,15 +1,29 @@ -RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain +XLEN ?= 32 + +ifeq ($(XLEN),32) +RISCV_TOOLCHAIN_PATH = /opt/riscv-gnu-toolchain +else +RISCV_TOOLCHAIN_PATH = /opt/riscv64-gnu-toolchain +endif + +RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf- VORTEX_RT_PATH ?= $(realpath ../../../runtime) -CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc -AR = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc-ar -DP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objdump -CP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objcopy +CC = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)gcc +AR = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)gcc-ar +DP = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)objdump +CP = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)objcopy -CFLAGS += -march=rv32imf -mabi=ilp32f -O3 -Wstack-usage=1024 -mcmodel=medany -ffreestanding -nostartfiles -fdata-sections -ffunction-sections -CFLAGS += -I$(VORTEX_RT_PATH)/include -I$(VORTEX_RT_PATH)/../hw --save-temps -v +ifeq ($(XLEN),32) +CFLAGS += -march=rv32imf -mabi=ilp32f +else +CFLAGS += -march=rv64imfd -mabi=lp64d +endif -LDFLAGS += -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld -Wl,--gc-sections $(VORTEX_RT_PATH)/libvortexrt.a +CFLAGS += -O3 -Wstack-usage=1024 -mcmodel=medany -ffreestanding -nostartfiles -fdata-sections -ffunction-sections +CFLAGS += -I$(VORTEX_RT_PATH)/include -I$(VORTEX_RT_PATH)/../hw + +LDFLAGS += -lm -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link$(XLEN).ld -Wl,--gc-sections $(VORTEX_RT_PATH)/libvortexrt.a PROJECT = hello diff --git a/tests/runtime/simple/Makefile b/tests/runtime/simple/Makefile index 79e2a2e5..51163385 100644 --- a/tests/runtime/simple/Makefile +++ b/tests/runtime/simple/Makefile @@ -1,19 +1,33 @@ -RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain +XLEN ?= 32 + +ifeq ($(XLEN),32) +RISCV_TOOLCHAIN_PATH = /opt/riscv-gnu-toolchain +else +RISCV_TOOLCHAIN_PATH = /opt/riscv64-gnu-toolchain +endif + +RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf- VORTEX_RT_PATH ?= $(realpath ../../../runtime) -CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc -AR = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc-ar -DP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objdump -CP = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-objcopy +CC = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)gcc +AR = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)gcc-ar +DP = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)objdump +CP = $(RISCV_TOOLCHAIN_PATH)/bin/$(RISCV_PREFIX)objcopy -CFLAGS += -march=rv32imf -mabi=ilp32f -O3 -Wstack-usage=1024 -ffreestanding -nostartfiles -fdata-sections -ffunction-sections -fpermissive +ifeq ($(XLEN),32) +CFLAGS += -march=rv32imf -mabi=ilp32f +else +CFLAGS += -march=rv64imfd -mabi=lp64d +endif + +CFLAGS += -O3 -Wstack-usage=1024 -mcmodel=medany -ffreestanding -nostartfiles -fdata-sections -ffunction-sections CFLAGS += -I$(VORTEX_RT_PATH)/include -I$(VORTEX_RT_PATH)/../hw -LDFLAGS += -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link.ld -Wl,--gc-sections $(VORTEX_RT_PATH)/libvortexrt.a +LDFLAGS += -lm -Wl,-Bstatic,-T,$(VORTEX_RT_PATH)/linker/vx_link$(XLEN).ld -Wl,--gc-sections $(VORTEX_RT_PATH)/libvortexrt.a PROJECT = simple -SRCS = main.cpp tests.cpp +SRCS = main.cpp all: $(PROJECT).elf $(PROJECT).bin $(PROJECT).dump