Skip to content

Commit

Permalink
Merge pull request #99 from pulp-platform/ne16
Browse files Browse the repository at this point in the history
Adds NE16 accelerator model
  • Loading branch information
FrancescoConti authored Jun 3, 2021
2 parents 5b2bb32 + 239bd5d commit 0c44b32
Show file tree
Hide file tree
Showing 22 changed files with 3,102 additions and 4 deletions.
1 change: 1 addition & 0 deletions configs/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export PULP_CONFIGS_PATH=$PULP_SDK_HOME/tools/gap-configs/configs:$PULP_CONFIGS_
# GVSOC
export PULP_SDK_INSTALL=$INSTALL_DIR
export GVSOC_PATH=$INSTALL_DIR/python
export XTENSOR_INCLUDE_DIR=$PULP_SDK_HOME/ext/xtensor/include
export GVSOC_INC_PATHS="$PULP_SDK_HOME/rtos/pulpos/gap_archi/include/archi/chips/$TARGET_NAME $PULP_SDK_HOME/rtos/pulpos/gap_archi/include $PULP_SDK_HOME/rtos/pulpos/pulp_archi/include"

# FPGA
Expand Down
19 changes: 18 additions & 1 deletion rules/gvsoc.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
gvsoc.checkout.deps: json-tools.checkout gap-configs.checkout dpi-models.checkout pulp-debug-bridge.checkout
ext/xtensor:
mkdir -p ext/xtensor
rm -rf ext/xtensor/*
git clone https://github.com/xtensor-stack/xtl ext/xtensor/xtl
git clone https://github.com/xtensor-stack/xtensor ext/xtensor/xtensor
git clone https://github.com/xtensor-stack/xsimd ext/xtensor/xsimd
pushd ext/xtensor/xtl; git checkout tags/0.6.14; popd
pushd ext/xtensor/xtensor; git checkout tags/0.21.5; popd
pushd ext/xtensor/xsimd; git checkout tags/7.4.7; popd
mkdir ext/xtensor/include
mv ext/xtensor/xtl/include/xtl ext/xtensor/include/
mv ext/xtensor/xtensor/include/xtensor ext/xtensor/include/
mv ext/xtensor/xsimd/include/xsimd ext/xtensor/include/
rm -rf ext/xtensor/x*

gvsoc.ext: ext/xtensor

gvsoc.checkout.deps: json-tools.checkout gap-configs.checkout dpi-models.checkout pulp-debug-bridge.checkout gvsoc.ext
git submodule update --init rtos/pulpos/pulp_archi

gvsoc.checkout:
Expand Down
5 changes: 5 additions & 0 deletions tools/gap-configs/configs/chips/pulp/pulp.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@
"size": "0x00000800"
},

"ne16": {
"base": "0x10201000",
"size": "0x00000400"
},

"icache_ctrl": {
"base": "0x10201400",
"size": "0x00000400"
Expand Down
3 changes: 3 additions & 0 deletions tools/gap-configs/configs/ips/ne16/ne16.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"vp_component": "pulp.ne16.ne16"
}
26 changes: 26 additions & 0 deletions tools/gap-configs/python/generators/v1/cluster_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def get_config(tp, cluster_id):
has_hwce = tp.get('cluster/peripherals/hwce') is not None
has_hwacc = tp.get('cluster/peripherals/hwacc') is not None
has_ima = tp.get('cluster/peripherals/ima') is not None
has_ne16 = tp.get('cluster/peripherals/ne16') is not None
dma_irq_0 = tp.get('cluster/pe/irq').get_dict().index('dma_0')
dma_irq_1 = tp.get('cluster/pe/irq').get_dict().index('dma_1')
dma_irq_ext = tp.get('cluster/pe/irq').get_dict().index('dma_ext')
Expand All @@ -53,6 +54,9 @@ def get_config(tp, cluster_id):
if has_ima:
ima_irq = tp.get('cluster/pe/irq').get_dict().index('acc_0')

if has_ne16:
ne16_irq = tp.get('cluster/pe/irq').get_dict().index('acc_0')

core_conf = js.import_config_from_file("ips/riscv/%s.json" % cluster_core, find=True)


Expand Down Expand Up @@ -143,6 +147,11 @@ def get_config(tp, cluster_id):
("ima", get_mapping_area(tp.get_child_dict("cluster/peripherals/ima"), cluster_size, cluster_id, True))
]))

if has_ne16:
periph_ico_mappings.update(OrderedDict([
("ne16", get_mapping_area(tp.get_child_dict("cluster/peripherals/ne16"), cluster_size, cluster_id, True))
]))

cluster.periph_ico = Component(properties=OrderedDict([
('@includes@', ["ips/interco/router.json"]),
('mappings', periph_ico_mappings)
Expand Down Expand Up @@ -216,6 +225,8 @@ def get_config(tp, cluster_id):
l1_interleaver_nb_masters += 4
if has_ima:
l1_interleaver_nb_masters += ima_conf.get_int('nb_masters')
if has_ne16:
l1_interleaver_nb_masters += 1

cluster.l1_ico.interleaver = Component(properties=OrderedDict([
('@includes@', ["ips/interco/l1_interleaver.json"]),
Expand Down Expand Up @@ -311,6 +322,11 @@ def get_config(tp, cluster_id):
('@includes@', ["ips/ima/ima_v%d.json" % tp.get_child_int('cluster/peripherals/ima/version')])
]))

if has_ne16:
cluster.ne16 = Component(properties=OrderedDict([
('@includes@', ["ips/ne16/ne16.json"])
]))

cluster.icache_ctrl = Component(properties=OrderedDict([
('@includes@', ["ips/icache_ctrl/icache_ctrl_v2.json"])
]))
Expand Down Expand Up @@ -374,6 +390,8 @@ def get_config(tp, cluster_id):
cluster.periph_ico.hwacc = cluster.hwacc.input
if has_ima:
cluster.periph_ico.ima = cluster.ima.input
if has_ne16:
cluster.periph_ico.ne16 = cluster.ne16.input
cluster.periph_ico.event_unit = cluster.event_unit.input
cluster.periph_ico.cluster_ctrl = cluster.cluster_ctrl.input
cluster.periph_ico.timer = cluster.timer.input
Expand All @@ -392,6 +410,10 @@ def get_config(tp, cluster_id):
for i in range(0, nb_pe):
cluster.ima.irq = cluster.event_unit.new_itf('in_event_%d_pe_%d' % (ima_irq, i))

if has_ne16:
for i in range(0, nb_pe):
cluster.ne16.irq = cluster.event_unit.new_itf('in_event_%d_pe_%d' % (ne16_irq, i))

for i in range(0, nb_pe):
cluster.icache_ctrl.flush = cluster.get('pe%d' % i).flush_cache

Expand Down Expand Up @@ -491,6 +513,10 @@ def get_config(tp, cluster_id):
cluster.ima.set('out_%d' % i, cluster.l1_ico.new_itf('ima_in_%d' % i))
cluster.l1_ico.set('ima_in_%d' % i, cluster.l1_ico.interleaver.new_itf('in_%d' % (nb_pe + 4 + i)))

if has_ne16:
cluster.ne16.set('out', cluster.l1_ico.new_itf('ne16_in'))
cluster.l1_ico.set('ne16_in', cluster.l1_ico.interleaver.new_itf('in_%d' % (nb_pe + 4)))

for i in range(0, nb_pe):
cluster.l1_ico.get('pe%d_ico' % i).dma = cluster.l1_ico.new_itf('dma_%d'%i)

Expand Down
2 changes: 1 addition & 1 deletion tools/gvsoc/common/vp_models.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ifdef ARCHI_DIR
VP_COMP_CFLAGS += -I$(ARCHI_DIR)
endif

VP_COMP_CPPFLAGS=-std=c++11
VP_COMP_CPPFLAGS=-std=c++14
VP_COMP_LDFLAGS=-O2 -g -shared -L$(INSTALL_DIR)/lib
VP_COMP_STD_LDFLAGS=-lpulpvp
VP_COMP_DBG_LDFLAGS=-lpulpvp-debug
Expand Down
3 changes: 1 addition & 2 deletions tools/gvsoc/pulp/models/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ VP_DIRS=pulp pulp/fll pulp/stdout pulp/chips/pulpissimo \
pulp/chips/multino pulp/chips/arnold \
pulp/chips/pulpissimo_v1 \
pulp/gpio pulp/chips/pulp_v1 pulp/chips/vivosoc3_1 pulp/ima \


pulp/ne16 \

-include $(ROOT_VP_BUILD_DIR)/props.mk

Expand Down
19 changes: 19 additions & 0 deletions tools/gvsoc/pulp/models/pulp/ne16/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ifdef XTENSOR_INCLUDE_DIR
IMPLEMENTATIONS += pulp/ne16/ne16
pulp/ne16/ne16_SRCS = pulp/ne16/src/ne16.cpp \
pulp/ne16/src/ne16_fsm.cpp \
pulp/ne16/src/ne16_stream.cpp \
pulp/ne16/src/ne16_regfile.cpp \
pulp/ne16/src/ne16_clear.cpp \
pulp/ne16/src/ne16_load.cpp \
pulp/ne16/src/ne16_streamin.cpp \
pulp/ne16/src/ne16_matrixvec.cpp \
pulp/ne16/src/ne16_streamout.cpp \
pulp/ne16/src/ne16_normquant.cpp \
pulp/ne16/src/ne16_index.cpp \
pulp/ne16/src/ne16_debug.cpp
pulp/ne16/ne16_CFLAGS = -Ipulp/ne16/include -DXTENSOR_USE_XSIMD -isystem $(XTENSOR_INCLUDE_DIR) -march=native -std=c++14
else
IMPLEMENTATIONS += pulp/ne16/ne16
pulp/ne16/ne16_SRCS = pulp/ne16/src/ne16_empty.cpp
endif
Loading

0 comments on commit 0c44b32

Please sign in to comment.