Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-pytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
- run: cd proj/mnv2_first && pwd && make pytest
- run: cd proj/proj_accel_1 && pwd && make pytest
- run: cd proj/proj_template && pwd && make pytest
- run: echo "nmigen_cfu tests"; python/nmigen_cfu/run_unit_tests.sh
- run: echo "amaranth_cfu tests"; python/amaranth_cfu/run_unit_tests.sh
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
[submodule "soc/deps/pythondata_cpu_vexriscv"]
path = third_party/python/pythondata_cpu_vexriscv
url = https://github.com/litex-hub/pythondata-cpu-vexriscv.git
[submodule "third_party/python/nmigen"]
path = third_party/python/nmigen
url = https://github.com/nmigen/nmigen
[submodule "third_party/python/pyvcd"]
path = third_party/python/pyvcd
url = https://github.com/SanDisk-Open-Source/pyvcd.git
Expand Down Expand Up @@ -64,3 +61,6 @@
[submodule "third_party/python/meson"]
path = third_party/python/meson
url = https://github.com/mesonbuild/meson
[submodule "third_party/python/amaranth"]
path = third_party/python/amaranth
url = https://github.com/amaranth-lang/amaranth
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ make PLATFORM=sim load

* [LiteX](https://github.com/enjoy-digital/litex): Open-source framework for assembling the SoC (CPU + peripherals)
* [VexRiscv](https://github.com/SpinalHDL/VexRiscv): Open-source RISC-V soft CPU optimized for FPGAs
* [nMigen](https://github.com/nmigen/nmigen): Python toolbox for building digital hardware
* [Amaranth](https://github.com/amaranth-lang/amaranth): Python toolbox for building digital hardware


### Licensed under Apache-2.0 license
Expand Down
19 changes: 12 additions & 7 deletions common/_hps/hps/ld/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SECTIONS
_etext = .;
} > rom


.rodata :
{
/*
Expand All @@ -28,14 +29,17 @@ SECTIONS
_frodata = .;
src/models/*/*(SORT(.rodata.*))
src/conv2d_??.o(SORT(.rodata.*)) /* specific to hps_accel */
src/conv2d_???.o(SORT(.rodata.*)) /* specific to hps_accel */
src/pool_??.o(SORT(.rodata.*)) /* specific to hps_accel */

. = ALIGN(4096);
*(SORT(.rodata))
*(SORT(.rodata.*))
*(SORT(.gnu.linkonce.r.*))
*(SORT(.rodata1))
*(SORT(.srodata))
*(SORT(.srodata.*))
. = ALIGN(8);
. = ALIGN(4096);
_erodata = .;
} > rom

Expand Down Expand Up @@ -77,12 +81,13 @@ SECTIONS
_end = .;
} > sram

.arena (NOLOAD) :
{
_farena = .;
*(.arena)
_earena = .;
} > arena

.arena (NOLOAD) : /* For separate arena */
{
_farena = .;
*(.arena)
_earena = .;
} > arena
}

PROVIDE(_fstack = ORIGIN(sram) + LENGTH(sram) - 4);
1 change: 1 addition & 0 deletions common/src/models/hps_model/hps_0.dat

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions common/src/models/hps_model/hps_1.dat

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions common/src/models/hps_model/hps_2.dat

Large diffs are not rendered by default.

40 changes: 36 additions & 4 deletions common/src/models/hps_model/hps_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include "menu.h"
#include "models/hps_model/cat_picture.h"
#include "models/hps_model/diagram.h"
#include "models/hps_model/hps_0.h"
#include "models/hps_model/hps_1.h"
#include "models/hps_model/hps_2.h"
#include "models/hps_model/hps_model_2021_09_20_tiled.h"
#include "models/hps_model/hps_model_2022_01_05_74ops.h"
#include "models/hps_model/hps_model_2022_01_05_89ops.h"
Expand Down Expand Up @@ -98,17 +101,43 @@ int32_t classify_zeros() {

void do_classify_zeros() { printf("Result is %ld\n", classify_zeros()); }

// Classify hps_* inputs

int32_t classify_hps_0() {
tflite_set_input_unsigned(hps_0);
return classify();
}

void do_classify_hps_0() { printf("Result is %ld\n", classify_hps_0()); }

int32_t classify_hps_1() {
tflite_set_input_unsigned(hps_1);
return classify();
}

void do_classify_hps_1() { printf("Result is %ld\n", classify_hps_1()); }

int32_t classify_hps_2() {
tflite_set_input_unsigned(hps_2);
return classify();
}

void do_classify_hps_2() { printf("Result is %ld\n", classify_hps_2()); }

// Golden tests: expected results
struct GoldenTest {
int32_t (*fn)();
const char* name;
int32_t expected[5];
};

GoldenTest golden_tests[4] = {
GoldenTest golden_tests[] = {
{classify_cat, "cat", {-77, -47, -47, -101, -117}},
{classify_diagram, "diagram", {-124, -123, -123, -124, -127}},
{classify_zeros, "zeroes", {-126, -128, -128, -128, -128}},
{classify_hps_0, "hps_0", {-119, -75, -75, -73, -125}},
{classify_hps_1, "hps_1", {124, 127, 127, 121, -119}},
{classify_hps_2, "hps_2", {126, 127, 127, 125, 127}},
{nullptr, "", 0},
};

Expand Down Expand Up @@ -138,9 +167,12 @@ struct Menu MENU = {
"Tests for HPS model",
"hps",
{
MENU_ITEM('c', "Cat picture input", do_classify_cat),
MENU_ITEM('d', "Diagram input", do_classify_diagram),
MENU_ITEM('z', "Zeros input", do_classify_zeros),
MENU_ITEM('a', "Cat picture input", do_classify_cat),
MENU_ITEM('b', "Diagram input", do_classify_diagram),
MENU_ITEM('c', "Zeros input", do_classify_zeros),
MENU_ITEM('d', "hps_0", do_classify_hps_0),
MENU_ITEM('e', "hps_1", do_classify_hps_1),
MENU_ITEM('f', "hps_2", do_classify_hps_2),
MENU_ITEM('g', "Golden tests (check for expected outputs)",
do_golden_tests),
MENU_ITEM('0', "Reinitialize with 09_20 model", do_init_09_20),
Expand Down
Loading