Commit f731e0e6 by Luis Vega Committed by eqy

fix hardware-makefile for osx, bugfix chisel-RegFile, and rename driver (#3371)

parent 2b045c56
...@@ -20,12 +20,11 @@ export PYTHONPATH:=$(PWD)/python:$(PYTHONPATH) ...@@ -20,12 +20,11 @@ export PYTHONPATH:=$(PWD)/python:$(PYTHONPATH)
BUILD_NAME = build BUILD_NAME = build
build_dir = $(abspath .)/$(BUILD_NAME) build_dir = $(abspath .)/$(BUILD_NAME)
default: verilog driver run_verilog default: verilog driver
python3 tests/python/verilog_accel.py
run_chisel: chisel driver run_chisel: chisel driver
python3 tests/python/chisel_accel.py python3 tests/python/chisel_accel.py
.PHONY: cmake
driver: | $(build_dir) driver: | $(build_dir)
cd $(build_dir) && cmake .. && make cd $(build_dir) && cmake .. && make
...@@ -39,9 +38,6 @@ verilog: ...@@ -39,9 +38,6 @@ verilog:
chisel: chisel:
make -C hardware/chisel make -C hardware/chisel
run_verilog:
python3 tests/python/verilog_accel.py
clean: clean:
-rm -rf $(build_dir) -rm -rf $(build_dir)
make -C hardware/chisel clean make -C hardware/chisel clean
......
...@@ -84,11 +84,17 @@ else ...@@ -84,11 +84,17 @@ else
cxx_flags += -DVM_TRACE=0 cxx_flags += -DVM_TRACE=0
endif endif
# The following is to be consistent with cmake
ifeq ($(shell uname), Darwin)
lib_path = $(build_dir)/$(LIBNAME).dylib
else
lib_path = $(build_dir)/$(LIBNAME).so
endif
default: lib default: lib
lib: $(build_dir)/$(LIBNAME).so lib: $(lib_path)
$(build_dir)/$(LIBNAME).so: $(verilator_build_dir)/V$(TOP).cpp $(lib_path): $(verilator_build_dir)/V$(TOP).cpp
echo $(cxx_files)
g++ $(cxx_flags) $(cxx_files) -o $@ g++ $(cxx_flags) $(cxx_files) -o $@
verilator: $(verilator_build_dir)/V$(TOP).cpp verilator: $(verilator_build_dir)/V$(TOP).cpp
......
...@@ -53,7 +53,7 @@ class RegFile(implicit config: AccelConfig) extends Module { ...@@ -53,7 +53,7 @@ class RegFile(implicit config: AccelConfig) extends Module {
val finish = Input(Bool()) val finish = Input(Bool())
val ecnt = Vec(config.nECnt, Flipped(ValidIO(UInt(config.regBits.W)))) val ecnt = Vec(config.nECnt, Flipped(ValidIO(UInt(config.regBits.W))))
val vals = Output(Vec(config.nVals, UInt(config.regBits.W))) val vals = Output(Vec(config.nVals, UInt(config.regBits.W)))
val ptrs = Output(Vec(config.nPtrs, UInt(config.regBits.W))) val ptrs = Output(Vec(config.nPtrs, UInt(config.ptrBits.W)))
val host = new VTAHostDPIClient val host = new VTAHostDPIClient
}) })
val sIdle :: sRead :: Nil = Enum(2) val sIdle :: sRead :: Nil = Enum(2)
......
...@@ -83,10 +83,17 @@ else ...@@ -83,10 +83,17 @@ else
cxx_flags += -DVM_TRACE=0 cxx_flags += -DVM_TRACE=0
endif endif
# The following is to be consistent with cmake
ifeq ($(shell uname), Darwin)
lib_path = $(build_dir)/$(LIBNAME).dylib
else
lib_path = $(build_dir)/$(LIBNAME).so
endif
default: lib default: lib
lib: $(build_dir)/$(LIBNAME).so lib: $(lib_path)
$(build_dir)/$(LIBNAME).so: $(build_dir)/V$(TOP).cpp $(lib_path): $(build_dir)/V$(TOP).cpp
g++ $(cxx_flags) $(cxx_files) -o $@ g++ $(cxx_flags) $(cxx_files) -o $@
verilator: $(build_dir)/V$(TOP).cpp verilator: $(build_dir)/V$(TOP).cpp
......
...@@ -34,8 +34,8 @@ def driver(hw_backend): ...@@ -34,8 +34,8 @@ def driver(hw_backend):
_sw_libname = "libsw" + _ext _sw_libname = "libsw" + _ext
_cur_path = osp.dirname(osp.abspath(osp.expanduser(__file__))) _cur_path = osp.dirname(osp.abspath(osp.expanduser(__file__)))
if hw_backend in ("verilog", "chisel"): if hw_backend in ("verilog", "chisel"):
_hw_lib = osp.join(_cur_path, "..", "..", "hardware", hw_backend, "build", _hw_libname) _hw_lib = osp.join(_cur_path, "..", "hardware", hw_backend, "build", _hw_libname)
_sw_lib = osp.join(_cur_path, "..", "..", "build", _sw_libname) _sw_lib = osp.join(_cur_path, "..", "build", _sw_libname)
def load_dll(dll): def load_dll(dll):
try: try:
......
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
import tvm import tvm
import numpy as np import numpy as np
import tsim
from accel.driver import driver
def test_accel(): def test_accel():
rmax = 64 rmax = 64
...@@ -27,7 +26,7 @@ def test_accel(): ...@@ -27,7 +26,7 @@ def test_accel():
ctx = tvm.cpu(0) ctx = tvm.cpu(0)
a = tvm.nd.array(np.random.randint(rmax, size=n).astype("uint64"), ctx) a = tvm.nd.array(np.random.randint(rmax, size=n).astype("uint64"), ctx)
b = tvm.nd.array(np.zeros(n).astype("uint64"), ctx) b = tvm.nd.array(np.zeros(n).astype("uint64"), ctx)
f = driver("chisel") f = tsim.driver("chisel")
cycles = f(a, b, c) cycles = f(a, b, c)
msg = "cycles:{0:4} n:{1:2} c:{2:2}".format(cycles, n, c) msg = "cycles:{0:4} n:{1:2} c:{2:2}".format(cycles, n, c)
np.testing.assert_equal(b.asnumpy(), a.asnumpy() + c, err_msg = "[FAIL] " + msg) np.testing.assert_equal(b.asnumpy(), a.asnumpy() + c, err_msg = "[FAIL] " + msg)
......
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
import tvm import tvm
import numpy as np import numpy as np
import tsim
from accel.driver import driver
def test_accel(): def test_accel():
rmax = 64 rmax = 64
...@@ -27,7 +26,7 @@ def test_accel(): ...@@ -27,7 +26,7 @@ def test_accel():
ctx = tvm.cpu(0) ctx = tvm.cpu(0)
a = tvm.nd.array(np.random.randint(rmax, size=n).astype("uint64"), ctx) a = tvm.nd.array(np.random.randint(rmax, size=n).astype("uint64"), ctx)
b = tvm.nd.array(np.zeros(n).astype("uint64"), ctx) b = tvm.nd.array(np.zeros(n).astype("uint64"), ctx)
f = driver("verilog") f = tsim.driver("verilog")
cycles = f(a, b, c) cycles = f(a, b, c)
msg = "cycles:{0:4} n:{1:2} c:{2:2}".format(cycles, n, c) msg = "cycles:{0:4} n:{1:2} c:{2:2}".format(cycles, n, c)
np.testing.assert_equal(b.asnumpy(), a.asnumpy() + c, err_msg = "[FAIL] " + msg) np.testing.assert_equal(b.asnumpy(), a.asnumpy() + c, err_msg = "[FAIL] " + msg)
......
...@@ -86,10 +86,17 @@ else ...@@ -86,10 +86,17 @@ else
cxx_flags += -DVM_TRACE=0 cxx_flags += -DVM_TRACE=0
endif endif
# The following is to be consistent with cmake
ifeq ($(shell uname), Darwin)
lib_path = $(vta_dir)/$(BUILD_NAME)/$(VTA_LIBNAME).dylib
else
lib_path = $(vta_dir)/$(BUILD_NAME)/$(VTA_LIBNAME).so
endif
default: lib default: lib
lib: $(vta_dir)/$(BUILD_NAME)/$(VTA_LIBNAME).so lib: $(lib_path)
$(vta_dir)/$(BUILD_NAME)/$(VTA_LIBNAME).so: $(verilator_build_dir)/V$(TOP_TEST).cpp $(lib_path): $(verilator_build_dir)/V$(TOP_TEST).cpp
g++ $(cxx_flags) $(cxx_files) -o $@ g++ $(cxx_flags) $(cxx_files) -o $@
verilator: $(verilator_build_dir)/V$(TOP_TEST).cpp verilator: $(verilator_build_dir)/V$(TOP_TEST).cpp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment