From 60938c29c7cac3b17d3a5301fe77c56ed7e8fdde Mon Sep 17 00:00:00 2001 From: Angelo Garofalo Date: Sun, 15 Mar 2020 22:31:21 +0100 Subject: [PATCH 1/5] add fpga config for pulp & marsellus --- configs/fpgas/marsellus/virtex7.sh | 23 +++++++++++++++++++++++ configs/fpgas/pulp/virtex7.sh | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 configs/fpgas/marsellus/virtex7.sh create mode 100644 configs/fpgas/pulp/virtex7.sh diff --git a/configs/fpgas/marsellus/virtex7.sh b/configs/fpgas/marsellus/virtex7.sh new file mode 100644 index 0000000..02a6612 --- /dev/null +++ b/configs/fpgas/marsellus/virtex7.sh @@ -0,0 +1,23 @@ + +#!/bin/bash -e + +export PULPRT_TARGET=marsellus +export PULPRUN_TARGET=marsellus + +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi + +source $scriptDir/../../common.sh + +export PULPRUN_PLATFORM=fpga + +#Virtex7 uses 50MHz SoC Frequency +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=50000000' + +export io=uart \ No newline at end of file diff --git a/configs/fpgas/pulp/virtex7.sh b/configs/fpgas/pulp/virtex7.sh new file mode 100644 index 0000000..5b31806 --- /dev/null +++ b/configs/fpgas/pulp/virtex7.sh @@ -0,0 +1,23 @@ + +#!/bin/bash -e + +export PULPRT_TARGET=pulp +export PULPRUN_TARGET=pulp + +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi + +source $scriptDir/../../common.sh + +export PULPRUN_PLATFORM=fpga + +#Virtex7 uses 50MHz SoC Frequency +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=50000000' + +export io=uart \ No newline at end of file From df7d47dd56f7e5a970ff433d833dbd35e39f473e Mon Sep 17 00:00:00 2001 From: Angelo Garofalo Date: Sun, 15 Mar 2020 22:31:21 +0100 Subject: [PATCH 2/5] add fpga config for pulp & marsellus --- configs/fpgas/marsellus/virtex7.sh | 23 +++++++++++++++++++++++ configs/fpgas/pulp/virtex7.sh | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 configs/fpgas/marsellus/virtex7.sh create mode 100644 configs/fpgas/pulp/virtex7.sh diff --git a/configs/fpgas/marsellus/virtex7.sh b/configs/fpgas/marsellus/virtex7.sh new file mode 100644 index 0000000..02a6612 --- /dev/null +++ b/configs/fpgas/marsellus/virtex7.sh @@ -0,0 +1,23 @@ + +#!/bin/bash -e + +export PULPRT_TARGET=marsellus +export PULPRUN_TARGET=marsellus + +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi + +source $scriptDir/../../common.sh + +export PULPRUN_PLATFORM=fpga + +#Virtex7 uses 50MHz SoC Frequency +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=50000000' + +export io=uart \ No newline at end of file diff --git a/configs/fpgas/pulp/virtex7.sh b/configs/fpgas/pulp/virtex7.sh new file mode 100644 index 0000000..5b31806 --- /dev/null +++ b/configs/fpgas/pulp/virtex7.sh @@ -0,0 +1,23 @@ + +#!/bin/bash -e + +export PULPRT_TARGET=pulp +export PULPRUN_TARGET=pulp + +if [ -n "${ZSH_VERSION:-}" ]; then + DIR="$(readlink -f -- "${(%):-%x}")" + scriptDir="$(dirname $DIR)" +else + + scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" + +fi + +source $scriptDir/../../common.sh + +export PULPRUN_PLATFORM=fpga + +#Virtex7 uses 50MHz SoC Frequency +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=50000000' + +export io=uart \ No newline at end of file From 1d7dcdd017f3446d1011f0107cf992e34fb2d4c8 Mon Sep 17 00:00:00 2001 From: Angelo Garofalo Date: Wed, 1 Apr 2020 20:33:28 +0200 Subject: [PATCH 3/5] add fpga config for marsellus --- configs/fpgas/marsellus/virtex7.sh | 5 ++--- include/archi/chips/marsellus/properties.h | 9 +++++++++ kernel/chips/marsellus/soc.c | 13 +++++++++++++ rules/pulpos/targets/marsellus.mk | 5 +++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/configs/fpgas/marsellus/virtex7.sh b/configs/fpgas/marsellus/virtex7.sh index 02a6612..6a876c4 100644 --- a/configs/fpgas/marsellus/virtex7.sh +++ b/configs/fpgas/marsellus/virtex7.sh @@ -1,4 +1,3 @@ - #!/bin/bash -e export PULPRT_TARGET=marsellus @@ -18,6 +17,6 @@ source $scriptDir/../../common.sh export PULPRUN_PLATFORM=fpga #Virtex7 uses 50MHz SoC Frequency -export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=50000000' +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=20000000' -export io=uart \ No newline at end of file +export io=uart diff --git a/include/archi/chips/marsellus/properties.h b/include/archi/chips/marsellus/properties.h index 248321d..28b9894 100644 --- a/include/archi/chips/marsellus/properties.h +++ b/include/archi/chips/marsellus/properties.h @@ -22,8 +22,17 @@ * FPGA */ +#ifndef ARCHI_FPGA_FREQUENCY #define ARCHI_FPGA_FREQUENCY 5000000 +#endif +#ifndef ARCHI_FPGA_FC_FREQUENCY +#define ARCHI_FPGA_FC_FREQUENCY 5000000 +#endif + +#ifndef ARCHI_FPGA_CL_FREQUENCY +#define ARCHI_FPGA_CL_FREQUENCY 5000000 +#endif /* * MEMORIES */ diff --git a/kernel/chips/marsellus/soc.c b/kernel/chips/marsellus/soc.c index 5c3c9a4..8626f91 100644 --- a/kernel/chips/marsellus/soc.c +++ b/kernel/chips/marsellus/soc.c @@ -18,12 +18,25 @@ void pos_soc_init() { +#if __PLATFORM__ != ARCHI_PLATFORM_FPGA + pos_fll_constructor(); pos_freq_domains[PI_FREQ_DOMAIN_FC] = pos_fll_init(POS_FLL_FC); pos_freq_domains[PI_FREQ_DOMAIN_PERIPH] = pos_fll_init(POS_FLL_PERIPH); + pos_freq_domains[PI_FREQ_DOMAIN_CL] = pos_fll_init(POS_FLL_CL); + +#else + + pos_freq_domains[PI_FREQ_DOMAIN_FC] = ARCHI_FPGA_FC_FREQUENCY; + + pos_freq_domains[PI_FREQ_DOMAIN_PERIPH] = ARCHI_FPGA_FREQUENCY; + + pos_freq_domains[PI_FREQ_DOMAIN_CL] = ARCHI_FPGA_CL_FREQUENCY; + +#endif } diff --git a/rules/pulpos/targets/marsellus.mk b/rules/pulpos/targets/marsellus.mk index 9b47b38..61e7fec 100644 --- a/rules/pulpos/targets/marsellus.mk +++ b/rules/pulpos/targets/marsellus.mk @@ -41,4 +41,9 @@ PULP_SRCS += kernel/chips/marsellus/soc.c include $(PULPRT_HOME)/rules/pulpos/configs/default.mk + +ifeq '$(platform)' 'fpga' +CONFIG_IO_UART=1 +endif + include $(PULPRT_HOME)/rules/pulpos/default_rules.mk \ No newline at end of file From b89dac68903449bd624525bc0e25b39c79d8a55f Mon Sep 17 00:00:00 2001 From: Angelo Garofalo Date: Wed, 1 Apr 2020 21:24:07 +0200 Subject: [PATCH 4/5] fix frequency for marsellus on fpga --- configs/fpgas/marsellus/virtex7.sh | 2 +- configs/fpgas/pulp/virtex7.sh | 2 +- include/archi/chips/marsellus/properties.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/configs/fpgas/marsellus/virtex7.sh b/configs/fpgas/marsellus/virtex7.sh index 6a876c4..40c5b7d 100644 --- a/configs/fpgas/marsellus/virtex7.sh +++ b/configs/fpgas/marsellus/virtex7.sh @@ -17,6 +17,6 @@ source $scriptDir/../../common.sh export PULPRUN_PLATFORM=fpga #Virtex7 uses 50MHz SoC Frequency -export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=20000000' +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=10000000' export io=uart diff --git a/configs/fpgas/pulp/virtex7.sh b/configs/fpgas/pulp/virtex7.sh index 5b31806..9ae9201 100644 --- a/configs/fpgas/pulp/virtex7.sh +++ b/configs/fpgas/pulp/virtex7.sh @@ -18,6 +18,6 @@ source $scriptDir/../../common.sh export PULPRUN_PLATFORM=fpga #Virtex7 uses 50MHz SoC Frequency -export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=50000000' +export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_FREQUENCY=10000000' export io=uart \ No newline at end of file diff --git a/include/archi/chips/marsellus/properties.h b/include/archi/chips/marsellus/properties.h index 28b9894..735c687 100644 --- a/include/archi/chips/marsellus/properties.h +++ b/include/archi/chips/marsellus/properties.h @@ -23,15 +23,15 @@ */ #ifndef ARCHI_FPGA_FREQUENCY -#define ARCHI_FPGA_FREQUENCY 5000000 +#define ARCHI_FPGA_FREQUENCY 1000000 #endif #ifndef ARCHI_FPGA_FC_FREQUENCY -#define ARCHI_FPGA_FC_FREQUENCY 5000000 +#define ARCHI_FPGA_FC_FREQUENCY 2000000 #endif #ifndef ARCHI_FPGA_CL_FREQUENCY -#define ARCHI_FPGA_CL_FREQUENCY 5000000 +#define ARCHI_FPGA_CL_FREQUENCY 20000000 #endif /* * MEMORIES From 413213a97d4a8bc81d3673c6b793d8fc65709e62 Mon Sep 17 00:00:00 2001 From: Germain Haugou Date: Thu, 2 Apr 2020 11:09:49 +0200 Subject: [PATCH 5/5] Cluster stacks are now dynamically allocated to avoid long preloading on netlist sim --- include/pulp.h | 8 ++++++++ kernel/alloc_pool.c | 11 +++++++++++ kernel/cluster.c | 8 +++++++- kernel/crt0.S | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/pulp.h b/include/pulp.h index 2ddf606..c56b2d5 100755 --- a/include/pulp.h +++ b/include/pulp.h @@ -78,6 +78,14 @@ int uart_read(int uart_id, void *buffer, uint32_t size); void synch_barrier(); +void *pi_l1_malloc(int cid, int size); +void pi_l1_free(int cid, void *chunk, int size); + +void *pi_l2_malloc(int size); +void pi_l2_free(void *_chunk, int size); + + + #endif diff --git a/kernel/alloc_pool.c b/kernel/alloc_pool.c index 1b0b869..a04278a 100644 --- a/kernel/alloc_pool.c +++ b/kernel/alloc_pool.c @@ -90,6 +90,17 @@ void alloc_init_l1(int cid) { pos_alloc_init(&pos_alloc_l1[cid], pos_l1_base(cid), pos_l1_size(cid)); } + +void *pi_l1_malloc(int cid, int size) +{ + return pos_alloc(&pos_alloc_l1[cid], size); +} + +void pi_l1_free(int cid, void *chunk, int size) +{ + return pos_free(&pos_alloc_l1[cid], chunk, size); +} + #endif diff --git a/kernel/cluster.c b/kernel/cluster.c index 71bd412..872eab9 100644 --- a/kernel/cluster.c +++ b/kernel/cluster.c @@ -20,7 +20,7 @@ volatile void *cluster_entry; -L1_DATA char cluster_stacks[ARCHI_CLUSTER_NB_PE*CLUSTER_STACK_SIZE]; +L1_DATA char *cluster_stacks; static volatile int cluster_running; @@ -78,6 +78,12 @@ void cluster_start(int cid, int (*entry)()) cluster_core_init(); } + alloc_init_l1(cid); + + cluster_stacks = pi_l1_malloc(cid, ARCHI_CLUSTER_NB_PE*CLUSTER_STACK_SIZE); + if (cluster_stacks == NULL) + return; + cluster_running = 1; // Fetch all cores diff --git a/kernel/crt0.S b/kernel/crt0.S index 5e71de9..f377889 100644 --- a/kernel/crt0.S +++ b/kernel/crt0.S @@ -160,6 +160,7 @@ pos_semihosting_call: #if defined(ARCHI_HAS_CLUSTER) pe_start: la x2, cluster_stacks + lw x2, 0(x2) li x3, CLUSTER_STACK_SIZE addi a1, a1, 1 mul x1, x3, a1