diff --git a/driver/hw/Makefile b/driver/hw/Makefile index 74d99109..a5333bb0 100644 --- a/driver/hw/Makefile +++ b/driver/hw/Makefile @@ -1,27 +1,35 @@ -BUILD_DIR=build_sim +BUILD_DIR=build_ase all: ase fpga -ase: build-setup +ase: setup-ase make -C $(BUILD_DIR) -fpga: build-setup - # TODO +fpga: setup-fpga + cd build_fpga && qsub-synth -build-setup: $(BUILD_DIR)/Makefile +setup-ase: build_ase/Makefile -$(BUILD_DIR)/Makefile: - afu_sim_setup --sources=sources.txt --platform discrete_pcie3 $(BUILD_DIR) -f +setup-fpga: build_fpga/build/dcp.qpf + +build_ase/Makefile: + afu_sim_setup --s sources.txt build_ase + +build_fpga/build/dcp.qpf: + afu_synth_setup -s sources.txt build_fpga run-ase: - cd $(BUILD_DIR) && MENT_VSIM_OPT="-dpicpppath /usr/bin/gcc" make sim + cd build_ase && make sim wave: - vsim -view $(BUILD_DIR)/work/vsim.wlf -do wave.do + vsim -view build_ase/work/vsim.wlf -do wave.do run-fpga: # TODO -clean: - rm -rf $(BUILD_DIR) \ No newline at end of file +clean-ase: + rm -rf build_ase + +clean-fpga: + rm -rf build_fpga \ No newline at end of file diff --git a/driver/hw/vortex_afu.sv b/driver/hw/vortex_afu.sv index 3cc0517c..d34dac2a 100644 --- a/driver/hw/vortex_afu.sv +++ b/driver/hw/vortex_afu.sv @@ -175,7 +175,8 @@ begin 16'h0006: af2cp_sTxPort.c2.data <= 64'h0; // next AFU 16'h0008: af2cp_sTxPort.c2.data <= 64'h0; // reserved MMIO_CSR_STATUS: begin - $display("%t: STATUS: state=%0d", $time, state); + if (state != af2cp_sTxPort.c2.data) + $display("%t: STATUS: state=%0d", $time, state); af2cp_sTxPort.c2.data <= state; end default: af2cp_sTxPort.c2.data <= 64'h0; diff --git a/driver/set_env.sh b/driver/set_env.sh index 8d94b148..2aa5fb10 100644 --- a/driver/set_env.sh +++ b/driver/set_env.sh @@ -1,3 +1,5 @@ +#!/bin/bash + source /tools/reconfig/intel/19.3/rg_intel_fpga_end_19.3.sh export PATH=/tools/opae/1.4.0/bin:/tools/reconfig/intel/19.3/modelsim_ase/bin:$PATH export LD_LIBRARY_PATH=/tools/opae/1.4.0/lib:$PATH diff --git a/driver/sw/Makefile b/driver/sw/Makefile index 5811f3c3..fe10c1c1 100644 --- a/driver/sw/Makefile +++ b/driver/sw/Makefile @@ -1,6 +1,9 @@ -all: opae rtlsim simx +all: dummy + +dummy: + $(MAKE) -C dummy opae: $(MAKE) -C opae @@ -12,6 +15,7 @@ simx: $(MAKE) -C simx clean: + $(MAKE) clean -C dummy $(MAKE) clean -C opae $(MAKE) clean -C rtlsim $(MAKE) clean -C simx diff --git a/driver/sw/dummy/Makefile b/driver/sw/dummy/Makefile new file mode 100644 index 00000000..871f86f2 --- /dev/null +++ b/driver/sw/dummy/Makefile @@ -0,0 +1,20 @@ +CXXFLAGS += -std=c++11 -O3 -Wall -Wextra -pedantic -Wfatal-errors +#CXXFLAGS += -std=c++11 -g -O0 -Wall -Wextra -pedantic -Wfatal-errors + +CXXFLAGS += -I../include -I../../../runtime + +CXXFLAGS += -fPIC + +LDFLAGS += -shared -pthread + +SRCS = vortex.cpp ../vx_utils.cpp + +PROJECT = libvortex.so + +all: $(PROJECT) + +$(PROJECT): $(SRCS) + $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@ + +clean: + rm -rf $(PROJECT) obj_dir \ No newline at end of file diff --git a/driver/sw/dummy/vortex.cpp b/driver/sw/dummy/vortex.cpp new file mode 100644 index 00000000..13f09ae5 --- /dev/null +++ b/driver/sw/dummy/vortex.cpp @@ -0,0 +1,45 @@ +#include + +extern int vx_dev_open(vx_device_h* /*hdevice*/) { + return -1; +} + +extern int vx_dev_close(vx_device_h /*hdevice*/) { + return -1; +} + +extern int vx_alloc_dev_mem(vx_device_h /*hdevice*/, size_t /*size*/, size_t* /*dev_maddr*/) { + return -1; +} + +extern int vx_flush_caches(vx_device_h /*hdevice*/, size_t /*dev_maddr*/, size_t /*size*/) { + return -1; +} + +extern int vx_alloc_shared_mem(vx_device_h /*hdevice*/, size_t /*size*/, vx_buffer_h* /*hbuffer*/) { + return -1; +} + +extern volatile void* vx_host_ptr(vx_buffer_h /*hbuffer*/) { + return nullptr; +} + +extern int vx_buf_release(vx_buffer_h /*hbuffer*/) { + return -1; +} + +extern int vx_copy_to_dev(vx_buffer_h /*hbuffer*/, size_t /*dev_maddr*/, size_t /*size*/, size_t /*src_offset*/) { + return -1; +} + +extern int vx_copy_from_dev(vx_buffer_h /*hbuffer*/, size_t /*dev_maddr*/, size_t /*size*/, size_t /*dest_offset*/) { + return -1; +} + +extern int vx_start(vx_device_h /*hdevice*/) { + return -1; +} + +extern int vx_ready_wait(vx_device_h /*hdevice*/, long long /*timeout*/) { + return -1; +} diff --git a/driver/sw/vx_utils.cpp b/driver/sw/vx_utils.cpp index 023f013c..d81d5ba2 100644 --- a/driver/sw/vx_utils.cpp +++ b/driver/sw/vx_utils.cpp @@ -35,7 +35,7 @@ extern int vx_upload_kernel_bytes(vx_device_h device, const void* content, size_ if (NULL == content || 0 == size) return -1; - uint32_t buffer_transfer_size = 4096; + uint32_t buffer_transfer_size = 65536; uint32_t kernel_base_addr = vx_dev_caps(VX_CAPS_KERNEL_BASE_ADDR); // allocate device buffer diff --git a/driver/tests/basic/Makefile b/driver/tests/basic/Makefile index 089739a1..f29b8e64 100644 --- a/driver/tests/basic/Makefile +++ b/driver/tests/basic/Makefile @@ -1,5 +1,5 @@ -CXXFLAGS += -std=c++17 -O0 -g -Wall -Wextra -pedantic -Wfatal-errors +CXXFLAGS += -std=c++11 -O0 -g -Wall -Wextra -pedantic -Wfatal-errors CXXFLAGS += -I../../sw/include @@ -12,13 +12,13 @@ SRCS = basic.cpp all: $(PROJECT) $(PROJECT): $(SRCS) - $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -L../../sw/simx -lvortex -o $@ + $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -L../../sw/dummy -lvortex -o $@ run-fpga: $(PROJECT) LD_LIBRARY_PATH=../../sw/opae:$(LD_LIBRARY_PATH) ./$(PROJECT) run-ase: $(PROJECT) - LD_LIBRARY_PATH=../../sw/opae/ase:$(LD_LIBRARY_PATH) ./$(PROJECT) + ASE_LOG=0 LD_LIBRARY_PATH=../../sw/opae/ase:$(LD_LIBRARY_PATH) ./$(PROJECT) run-rtlsim: $(PROJECT) LD_LIBRARY_PATH=../../sw/rtlsim:$(LD_LIBRARY_PATH) ./$(PROJECT) diff --git a/driver/tests/basic/basic b/driver/tests/basic/basic index f3a0e08b..1ec3ae80 100755 Binary files a/driver/tests/basic/basic and b/driver/tests/basic/basic differ diff --git a/driver/tests/basic/basic.cpp b/driver/tests/basic/basic.cpp index 44bce63c..9e13183b 100755 --- a/driver/tests/basic/basic.cpp +++ b/driver/tests/basic/basic.cpp @@ -2,13 +2,19 @@ #include #include +int test = -1; + static void parse_args(int argc, char **argv) { int c; - while ((c = getopt(argc, argv, "?")) != -1) { + while ((c = getopt(argc, argv, "t:h?")) != -1) { switch (c) { + case 't': { + test = atoi(optarg); + } break; + case 'h': case '?': { std::cout << "Test." << std::endl; - std::cout << "Usage: [-h: help]" << std::endl; + std::cout << "Usage: [-t testno][-h: help]" << std::endl; exit(0); } break; default: @@ -21,11 +27,11 @@ uint64_t shuffle(int i, uint64_t value) { return (value << i) | (value & ((1 << i)-1));; } -int run_test(vx_buffer_h sbuf, - vx_buffer_h dbuf, - uint32_t address, - uint64_t value, - int num_blocks) { +int run_test_0(vx_buffer_h sbuf, + vx_buffer_h dbuf, + uint32_t address, + uint64_t value, + int num_blocks) { int ret; int errors = 0; @@ -67,6 +73,33 @@ int run_test(vx_buffer_h sbuf, return 0; } +int run_test_1(vx_device_h device, const char* program) { + int ret; + + // upload program + std::cout << "upload program" << std::endl; + ret = vx_upload_kernel_file(device, program); + if (ret != 0) { + return ret; + } + + // start device + std::cout << "start device" << std::endl; + ret = vx_start(device); + if (ret != 0) { + return ret; + } + + // wait for completion + std::cout << "wait for completion" << std::endl; + ret = vx_ready_wait(device, -1); + if (ret != 0) { + return ret; + } + + return 0; +} + vx_device_h device = nullptr; vx_buffer_h sbuf = nullptr; vx_buffer_h dbuf = nullptr; @@ -112,30 +145,51 @@ int main(int argc, char *argv[]) { return ret; } - // run tests - std::cout << "run tests" << std::endl; - ret = run_test(sbuf, dbuf, 0x10000000, 0x0badf00d00ff00ff, 1); - if (ret != 0) { - cleanup(); - return ret; + // run tests + if (0 == test || -1 == test) { + std::cout << "run test suite 0" << std::endl; + + ret = run_test_0(sbuf, dbuf, 0x10000000, 0x0badf00d00ff00ff, 1); + if (ret != 0) { + cleanup(); + return ret; + } + + ret = run_test_0(sbuf, dbuf, 0x10000000, 0x0badf00d00ff00ff, 2); + if (ret != 0) { + cleanup(); + return ret; + } + + ret = run_test_0(sbuf, dbuf, 0x20000000, 0xff00ff00ff00ff00, 4); + if (ret != 0) { + cleanup(); + return ret; + } + + ret = run_test_0(sbuf, dbuf, 0x20000000, 0x0badf00d40ff40ff, 8); + if (ret != 0) { + cleanup(); + return ret; + } } - ret = run_test(sbuf, dbuf, 0x10000000, 0x0badf00d00ff00ff, 2); - if (ret != 0) { - cleanup(); - return ret; + if (1 == test || -1 == test) { + std::cout << "run test suite 1" << std::endl; + ret = run_test_1(device, "rv32ui-p-lw.bin"); + if (ret != 0) { + cleanup(); + return ret; + } } - ret = run_test(sbuf, dbuf, 0x20000000, 0xff00ff00ff00ff00, 4); - if (ret != 0) { - cleanup(); - return ret; - } - - ret = run_test(sbuf, dbuf, 0x20000000, 0x0badf00d40ff40ff, 8); - if (ret != 0) { - cleanup(); - return ret; + if (2 == test || -1 == test) { + std::cout << "run test suite 1" << std::endl; + ret = run_test_1(device, "rv32ui-p-sw.bin"); + if (ret != 0) { + cleanup(); + return ret; + } } // cleanup diff --git a/driver/tests/basic/rv32ui-p-lw.bin b/driver/tests/basic/rv32ui-p-lw.bin new file mode 100644 index 00000000..51c28eaa Binary files /dev/null and b/driver/tests/basic/rv32ui-p-lw.bin differ diff --git a/driver/tests/basic/rv32ui-p-sw.bin b/driver/tests/basic/rv32ui-p-sw.bin new file mode 100644 index 00000000..4a3db3b8 Binary files /dev/null and b/driver/tests/basic/rv32ui-p-sw.bin differ diff --git a/driver/tests/demo/Makefile b/driver/tests/demo/Makefile index 48effb87..eeaa2756 100644 --- a/driver/tests/demo/Makefile +++ b/driver/tests/demo/Makefile @@ -40,13 +40,13 @@ kernel.elf: $(SRCS) $(VX_CC) $(VX_CFLAGS) $(VX_STR) $(VX_FIO) $(VX_NEWLIB) $(VX_INT) $(VX_IO) $(VX_API) $(VX_SRCS) -I$(VX_RT_PATH) -o kernel.elf $(PROJECT): $(SRCS) - $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -L../../sw/simx -lvortex -o $@ + $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -L../../sw/dummy -lvortex -o $@ run-fpga: $(PROJECT) LD_LIBRARY_PATH=../../sw/opae:$(LD_LIBRARY_PATH) ./$(PROJECT) -f kernel.bin -n 16 run-ase: $(PROJECT) - LD_LIBRARY_PATH=../../sw/opae/ase:$(LD_LIBRARY_PATH) ./$(PROJECT) -f kernel.bin -n 16 + ASE_LOG=0 LD_LIBRARY_PATH=../../sw/opae/ase:$(LD_LIBRARY_PATH) ./$(PROJECT) -f kernel.bin -n 16 run-rtlsim: $(PROJECT) LD_LIBRARY_PATH=../../sw/rtlsim:$(LD_LIBRARY_PATH) ./$(PROJECT) -f kernel.bin -n 16 diff --git a/driver/tests/demo/demo b/driver/tests/demo/demo index 513c7ed8..22c3b0a9 100755 Binary files a/driver/tests/demo/demo and b/driver/tests/demo/demo differ