Skip to content

Commit

Permalink
Add support for pulp-nnx as N-EUREKA testbench driver.
Browse files Browse the repository at this point in the history
This is not yet as clean as it should be. In particular,
the neureka_bsp.h is a compromise to "keep it simple", which
most likely will need to be changed to merge into main.
  • Loading branch information
FrancescoConti committed Feb 11, 2024
1 parent 9afe077 commit e7db934
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 7 deletions.
4 changes: 2 additions & 2 deletions inc/pulp_nnx_neureka.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
*/

#include "neureka.h"
#include "neureka_siracusa_bsp.h"
#include "neureka_bsp.h"
#include "neureka_task.h"
#include <stdint.h>

/* PULP-NNX interface */

void neureka_nnx_init(neureka_dev_t *dev, neureka_siracusa_conf_t *conf);
void neureka_nnx_init(neureka_dev_t *dev, neureka_bsp_conf_t *conf);
void neureka_nnx_term(neureka_dev_t *dev);

/** neureka_nnx_dispatch_check
Expand Down
13 changes: 13 additions & 0 deletions neureka/bsp/neureka_bsp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifdef NNX_NEUREKA_TESTBENCH
#include "neureka_testbench_bsp.h"
#define neureka_bsp_conf_t neureka_testbench_conf_t
#define neureka_bsp_open neureka_testbench_open
#define neureka_bsp_close neureka_testbench_close
#define neureka_bsp_event_wait_and_clear neureka_testbench_event_wait_and_clear
#else
#include "neureka_siracusa_bsp.h"
#define neureka_bsp_conf_t neureka_siracusa_conf_t
#define neureka_bsp_open neureka_siracusa_open
#define neureka_bsp_close neureka_siracusa_close
#define neureka_bsp_event_wait_and_clear neureka_siracusa_event_wait_and_clear
#endif
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions neureka/bsp/testbench/neureka_testbench_bsp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Luka Macan <[email protected]>
* Francesco Conti <[email protected]>
*
* Copyright 2023 ETH Zurich and University of Bologna
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "neureka_testbench_bsp.h"
#include <pmsis.h>

#define NEUREKA_TESTBENCH_CLUSTER_CTRL_BASE_ADDR (0x00100000)
#define NEUREKA_TESTBENCH_BASE_ADDR (0x00100000)
// fixme
// #define NEUREKA_TESTBENCH_WEIGHT_MEM_BASE_ADDR (0x10400000)
// #define NEUREKA_TESTBENCH_WEIGHT_MEM_MRAM_OFFSET (0x00000000)
// #define NEUREKA_TESTBENCH_WEIGHT_MEM_SRAM_OFFSET (0x00400000)

void neureka_testbench_open(neureka_testbench_conf_t *conf) {
return;
}

void neureka_testbench_close() {
return;
}

void neureka_testbench_event_wait_and_clear() {
asm volatile ("wfi" ::: "memory");
}

static const neureka_dev_t neureka_testbench_dev = {
.hwpe_dev = (struct hwpe_dev_t){
.base_addr = (volatile uint32_t *)NEUREKA_TESTBENCH_BASE_ADDR}};

const neureka_dev_t *neureka_testbench_get_dev() {
return &neureka_testbench_dev;
}
36 changes: 36 additions & 0 deletions neureka/bsp/testbench/neureka_testbench_bsp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Luka Macan <[email protected]>
*
* Copyright 2023 ETH Zurich and University of Bologna
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef __NEUREKA_TESTBENCH_BSP_H__
#define __NEUREKA_TESTBENCH_BSP_H__

#include "neureka.h"
#include <stdint.h>

typedef struct neureka_testbench_conf_t {
int max_stall;
} neureka_testbench_conf_t;

void neureka_testbench_open(neureka_testbench_conf_t *conf);
void neureka_testbench_close();
void neureka_testbench_event_wait_and_clear();
const neureka_dev_t *neureka_testbench_get_dev();

#endif // !__NEUREKA_TESTBENCH_BSP_H__
10 changes: 5 additions & 5 deletions src/pulp_nnx_neureka.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
#include <stdint.h>
#include <sys/types.h>

void neureka_nnx_init(neureka_dev_t *dev, neureka_siracusa_conf_t *conf) {
neureka_siracusa_open(conf);
void neureka_nnx_init(neureka_dev_t *dev, neureka_bsp_conf_t *conf) {
neureka_bsp_open(conf);
hwpe_soft_clear(&dev->hwpe_dev);
}

void neureka_nnx_term(neureka_dev_t *dev) {
hwpe_soft_clear(&dev->hwpe_dev);
neureka_siracusa_close();
neureka_bsp_close();
}

int neureka_nnx_dispatch_check(neureka_dev_t *dev) {
Expand All @@ -42,7 +42,7 @@ int neureka_nnx_dispatch_check(neureka_dev_t *dev) {

void neureka_nnx_dispatch_wait(neureka_dev_t *dev) {
while (!neureka_nnx_dispatch_check(dev)) {
neureka_siracusa_event_wait_and_clear();
neureka_bsp_event_wait_and_clear();
}
}

Expand Down Expand Up @@ -71,6 +71,6 @@ int neureka_nnx_resolve_check(neureka_dev_t *dev, neureka_task_t *task) {

void neureka_nnx_resolve_wait(neureka_dev_t *dev, neureka_task_t *task) {
while (!neureka_nnx_resolve_check(dev, task)) {
neureka_siracusa_event_wait_and_clear();
neureka_bsp_event_wait_and_clear();
}
}

0 comments on commit e7db934

Please sign in to comment.