merged fpu_port branch
This commit is contained in:
@@ -173,7 +173,7 @@ extern int vx_dev_open(vx_device_h* hdevice) {
|
||||
{
|
||||
// Load device CAPS
|
||||
int ret = 0;
|
||||
ret |= vx_csr_get(device, 0, CSR_IMPL_ID, &device->implementation_id);
|
||||
ret |= vx_csr_get(device, 0, CSR_MIMPID, &device->implementation_id);
|
||||
ret |= vx_csr_get(device, 0, CSR_NC, &device->num_cores);
|
||||
ret |= vx_csr_get(device, 0, CSR_NW, &device->num_warps);
|
||||
ret |= vx_csr_get(device, 0, CSR_NT, &device->num_threads);
|
||||
@@ -217,14 +217,14 @@ extern int vx_dev_close(vx_device_h hdevice) {
|
||||
unsigned value;
|
||||
|
||||
int ret = 0;
|
||||
ret |= vx_csr_get(hdevice, 0, CSR_INSTR_H, &value);
|
||||
ret |= vx_csr_get(hdevice, 0, CSR_INSTRET_H, &value);
|
||||
instrs = value;
|
||||
ret |= vx_csr_get(hdevice, 0, CSR_INSTR_L, &value);
|
||||
ret |= vx_csr_get(hdevice, 0, CSR_INSTRET, &value);
|
||||
instrs = (instrs << 32) | value;
|
||||
|
||||
ret |= vx_csr_get(hdevice, 0, CSR_CYCLE_H, &value);
|
||||
cycles = value;
|
||||
ret |= vx_csr_get(hdevice, 0, CSR_CYCLE_L, &value);
|
||||
ret |= vx_csr_get(hdevice, 0, CSR_CYCLE, &value);
|
||||
cycles = (cycles << 32) | value;
|
||||
|
||||
float IPC = (float)(double(instrs) / double(cycles));
|
||||
|
||||
@@ -21,7 +21,7 @@ DBG_FLAGS += -DDBG_CORE_REQ_INFO
|
||||
#CONFIGS += -DNUM_CLUSTERS=1 -DNUM_CORES=2 -DL2_ENABLE=0
|
||||
CONFIGS += -DNUM_CLUSTERS=1 -DNUM_CORES=1
|
||||
|
||||
DEBUG=1
|
||||
#DEBUG=1
|
||||
#AFU=1
|
||||
|
||||
CFLAGS += -fPIC
|
||||
@@ -35,11 +35,13 @@ TOP = Vortex
|
||||
|
||||
SRCS = vortex.cpp ../common/vx_utils.cpp ../../hw/simulate/simulator.cpp
|
||||
|
||||
RTL_INCLUDE = -I../../hw/rtl -I../../hw/rtl/libs -I../../hw/rtl/interfaces -I../../hw/rtl/cache
|
||||
FPU_INCLUDE = -I../../hw/rtl/fp_cores/fpnew/src/common_cells/include -I../../hw/rtl/fp_cores/fpnew/src/common_cells/src -I../../hw/rtl/fp_cores/fpnew/src/fpu_div_sqrt_mvp/hdl -I../../hw/rtl/fp_cores/fpnew/src
|
||||
RTL_INCLUDE = -I../../hw/rtl -I../../hw/rtl/libs -I../../hw/rtl/interfaces -I../../hw/rtl/cache -I../../hw/rtl/fp_cores $(FPU_INCLUDE)
|
||||
|
||||
VL_FLAGS += --language 1800-2009 --assert -Wall -Wpedantic $(CONFIGS)
|
||||
VL_FLAGS += -Wno-DECLFILENAME
|
||||
VL_FLAGS += --x-initial unique --x-assign unique
|
||||
VL_FLAGS += verilator.vlt
|
||||
|
||||
# Enable Verilator multithreaded simulation
|
||||
#THREADS ?= $(shell python3 -c 'import multiprocessing as mp; print(max(1, mp.cpu_count() // 2))')
|
||||
@@ -70,7 +72,7 @@ PROJECT = libvortex.so
|
||||
all: $(PROJECT)
|
||||
|
||||
$(PROJECT): $(SRCS)
|
||||
verilator --exe --cc $(TOP) $(RTL_INCLUDE) $(VL_FLAGS) $(SRCS) -CFLAGS '$(CFLAGS)' -LDFLAGS '$(LDFLAGS)' -o ../$(PROJECT)
|
||||
verilator --exe --cc $(TOP) --top-module $(TOP) $(RTL_INCLUDE) $(VL_FLAGS) $(SRCS) -CFLAGS '$(CFLAGS)' -LDFLAGS '$(LDFLAGS)' -o ../$(PROJECT)
|
||||
make -j -C obj_dir -f V$(TOP).mk
|
||||
|
||||
clean:
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
#include "simulator.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
|
||||
uint64_t timestamp = 0;
|
||||
|
||||
double sc_time_stamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
Simulator::Simulator() {
|
||||
// force random values for unitialized signals
|
||||
const char* args[] = {"", "+verilator+rand+reset+2", "+verilator+seed+50"};
|
||||
Verilated::commandArgs(3, args);
|
||||
|
||||
vortex_ = new Vvortex_afu_sim();
|
||||
|
||||
#ifdef VCD_OUTPUT
|
||||
Verilated::traceEverOn(true);
|
||||
trace_ = new VerilatedVcdC;
|
||||
vortex_->trace(trace_, 99);
|
||||
trace_->open("trace.vcd");
|
||||
#endif
|
||||
}
|
||||
|
||||
Simulator::~Simulator() {
|
||||
#ifdef VCD_OUTPUT
|
||||
trace_->close();
|
||||
#endif
|
||||
delete vortex_;
|
||||
}
|
||||
|
||||
void Simulator::reset() {
|
||||
#ifndef NDEBUG
|
||||
std::cout << timestamp << ": [sim] reset()" << std::endl;
|
||||
#endif
|
||||
vortex_->reset = 1;
|
||||
this->step();
|
||||
vortex_->reset = 0;
|
||||
|
||||
dram_rsp_vec_.clear();
|
||||
}
|
||||
|
||||
void Simulator::step() {
|
||||
vortex_->clk = 0;
|
||||
this->eval();
|
||||
|
||||
vortex_->clk = 1;
|
||||
this->eval();
|
||||
|
||||
avs_driver();
|
||||
ccip_driver();
|
||||
}
|
||||
|
||||
void Simulator::eval() {
|
||||
vortex_->eval();
|
||||
#ifdef VCD_OUTPUT
|
||||
trace_->dump(timestamp);
|
||||
#endif
|
||||
++timestamp;
|
||||
}
|
||||
|
||||
void Simulator::avs_driver() {
|
||||
//--
|
||||
}
|
||||
|
||||
void Simulator::ccip_driver() {
|
||||
//--
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Vvortex_afu_sim.h"
|
||||
#include "Vvortex_afu_sim__Syms.h"
|
||||
#include "verilated.h"
|
||||
|
||||
#ifdef VCD_OUTPUT
|
||||
#include <verilated_vcd_c.h>
|
||||
#endif
|
||||
|
||||
#include <VX_config.h>
|
||||
#include "ram.h"
|
||||
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
#define ENABLE_DRAM_STALLS
|
||||
#define DRAM_LATENCY 100
|
||||
#define DRAM_RQ_SIZE 16
|
||||
#define DRAM_STALLS_MODULO 16
|
||||
|
||||
typedef struct {
|
||||
int cycles_left;
|
||||
uint8_t *data;
|
||||
unsigned tag;
|
||||
} dram_req_t;
|
||||
|
||||
class Simulator {
|
||||
public:
|
||||
|
||||
Simulator();
|
||||
virtual ~Simulator();
|
||||
|
||||
void reset();
|
||||
|
||||
void step();
|
||||
|
||||
int mmio_read(uint64_t addr, uint64_t* value);
|
||||
|
||||
int mmio_write(uint64_t addr, uint64_t value);
|
||||
|
||||
private:
|
||||
|
||||
void eval();
|
||||
|
||||
void avs_driver();
|
||||
|
||||
void ccip_driver();
|
||||
|
||||
std::vector<dram_req_t> dram_rsp_vec_;
|
||||
|
||||
RAM ram_;
|
||||
Vvortex_afu_sim *vortex_;
|
||||
|
||||
|
||||
#ifdef VCD_OUTPUT
|
||||
VerilatedVcdC *trace_;
|
||||
#endif
|
||||
};
|
||||
9
driver/rtlsim/verilator.vlt
Normal file
9
driver/rtlsim/verilator.vlt
Normal file
@@ -0,0 +1,9 @@
|
||||
`verilator_config
|
||||
|
||||
lint_off -rule BLKANDNBLK -file "../../hw/rtl/fp_cores/fpnew/*"
|
||||
lint_off -rule UNOPTFLAT -file "../../hw/rtl/fp_cores/fpnew/*"
|
||||
lint_off -rule WIDTH -file "../../hw/rtl/fp_cores/fpnew/*"
|
||||
lint_off -rule UNUSED -file "../../hw/rtl/fp_cores/fpnew/*"
|
||||
lint_off -rule LITENDIAN -file "../../hw/rtl/fp_cores/fpnew/*"
|
||||
lint_off -rule IMPORTSTAR -file "../../hw/rtl/fp_cores/fpnew/*"
|
||||
lint_off -rule PINCONNECTEMPTY -file "../../hw/rtl/fp_cores/fpnew/*"
|
||||
@@ -36,16 +36,16 @@ $(PROJECT): $(SRCS)
|
||||
$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -L../../stub -lvortex -o $@
|
||||
|
||||
run-fpga: $(PROJECT)
|
||||
LD_LIBRARY_PATH=../../opae:$(LD_LIBRARY_PATH) ./$(PROJECT) -n 16
|
||||
LD_LIBRARY_PATH=../../opae:$(LD_LIBRARY_PATH) ./$(PROJECT) -n 64
|
||||
|
||||
run-ase: $(PROJECT)
|
||||
ASE_LOG=0 LD_LIBRARY_PATH=../../opae/ase:$(LD_LIBRARY_PATH) ./$(PROJECT) -n 16
|
||||
ASE_LOG=0 LD_LIBRARY_PATH=../../opae/ase:$(LD_LIBRARY_PATH) ./$(PROJECT) -n 64
|
||||
|
||||
run-rtlsim: $(PROJECT)
|
||||
LD_LIBRARY_PATH=../../rtlsim:$(LD_LIBRARY_PATH) ./$(PROJECT) -n 16
|
||||
LD_LIBRARY_PATH=../../rtlsim:$(LD_LIBRARY_PATH) ./$(PROJECT) -n 64
|
||||
|
||||
run-simx: $(PROJECT)
|
||||
LD_LIBRARY_PATH=../../simx:$(LD_LIBRARY_PATH) ./$(PROJECT) -n 16
|
||||
LD_LIBRARY_PATH=../../simx:$(LD_LIBRARY_PATH) ./$(PROJECT) -n 64
|
||||
|
||||
.depend: $(SRCS)
|
||||
$(CXX) $(CXXFLAGS) -MM $^ > .depend;
|
||||
|
||||
BIN
driver/tests/demo/kernel.bin
Normal file → Executable file
BIN
driver/tests/demo/kernel.bin
Normal file → Executable file
Binary file not shown.
@@ -97,7 +97,7 @@ Disassembly of section .text:
|
||||
80000134: 0005006b 0x5006b
|
||||
80000138: 00002197 auipc gp,0x2
|
||||
8000013c: d3818193 addi gp,gp,-712 # 80001e70 <__global_pointer$>
|
||||
80000140: f14025f3 csrr a1,mhartid
|
||||
80000140: 022025f3 csrr a1,0x22
|
||||
80000144: 00a59593 slli a1,a1,0xa
|
||||
80000148: 02002673 csrr a2,0x20
|
||||
8000014c: 00261613 slli a2,a2,0x2
|
||||
@@ -145,7 +145,7 @@ Disassembly of section .text:
|
||||
800001ac: 00008067 ret
|
||||
|
||||
800001b0 <vx_thread_gid>:
|
||||
800001b0: f1402573 csrr a0,mhartid
|
||||
800001b0: 02202573 csrr a0,0x22
|
||||
800001b4: 00008067 ret
|
||||
|
||||
800001b8 <vx_core_id>:
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user