extending basic test
This commit is contained in:
@@ -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)
|
||||
clean-ase:
|
||||
rm -rf build_ase
|
||||
|
||||
clean-fpga:
|
||||
rm -rf build_fpga
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
20
driver/sw/dummy/Makefile
Normal file
20
driver/sw/dummy/Makefile
Normal file
@@ -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
|
||||
45
driver/sw/dummy/vortex.cpp
Normal file
45
driver/sw/dummy/vortex.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include <vortex.h>
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Binary file not shown.
@@ -2,13 +2,19 @@
|
||||
#include <unistd.h>
|
||||
#include <vortex.h>
|
||||
|
||||
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
|
||||
|
||||
BIN
driver/tests/basic/rv32ui-p-lw.bin
Normal file
BIN
driver/tests/basic/rv32ui-p-lw.bin
Normal file
Binary file not shown.
BIN
driver/tests/basic/rv32ui-p-sw.bin
Normal file
BIN
driver/tests/basic/rv32ui-p-sw.bin
Normal file
Binary file not shown.
@@ -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
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user