Skip to content

Commit

Permalink
Merge pull request #15 from Fraunhofer-IMS/v1.2.0-pre
Browse files Browse the repository at this point in the history
update files to v1.2.0
  • Loading branch information
crolfes authored Feb 6, 2023
2 parents bf48174 + d2eb265 commit d926b02
Show file tree
Hide file tree
Showing 40 changed files with 2,771 additions and 891 deletions.
4 changes: 3 additions & 1 deletion .ci/sim_file_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,23 @@


../src/airi5c_alu.v
../src/airi5c_branch_prediction.v
../src/airi5c_core.v
../src/airi5c_csr_file.v
../src/airi5c_ctrl.v
../src/airi5c_debug_module.v
../src/airi5c_debug_rom.v
../src/airi5c_decode.v
../src/airi5c_decompression.v
../src/airi5c_dmem_latch.v
../src/airi5c_EX_pregs.v
../src/airi5c_fetch_simple.v
../src/airi5c_fetch.v
../src/airi5c_imm_gen.v
../src/airi5c_mem_arbiter.v
../src/airi5c_PC_mux.v
../src/airi5c_periph_mux.v
../src/airi5c_pipeline.v
../src/airi5c_prebuf_fifo.v
../src/airi5c_regfile.v
../src/airi5c_src_a_mux.v
../src/airi5c_src_b_mux.v
Expand Down
66 changes: 65 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,74 @@ Requirements for (re-)building the hardware and programming the (pre-build) bits

- Xilinx Vivado: [2020.2 WebPack](https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/vivado-design-tools/archive.html) (for generating and programming the bitstream)
- Xilinx Vivado: [2020.2 LabEdition](https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/vivado-design-tools/archive.html) (for programming the pre-compiled bitstream only)
- FPGA board: [Digilent Nexys Video](https://digilent.com/reference/programmable-logic/nexys-video/start)
- FPGA board: [Digilent Nexys Video](https://digilent.com/reference/programmable-logic/nexys-video/start) or
[Digilent Arty A7](https://digilent.com/reference/programmable-logic/arty-a7/start)

The [`fpga`](https://github.com/Fraunhofer-IMS/airisc_core_complex/tree/main/fpga) folder provides pre-configured TCL scripts
to automatically generate a Xilinx Vivado project and to program the bitstream to the FPGA. See the project's
[online documentation](https://fraunhofer-ims.github.io/airisc_core_complex/index.html) for more information on how to setup a
AIRISC Xilinx Vivado project from scratch.

:bulb: Prebuilt bitstreams for the supported boards can be found in
[`fpga/sdcard`](https://github.com/Fraunhofer-IMS/airisc_core_complex/tree/main/fpga/sdcard).

#### Exemplary Synthesis Results

* FPGA: Xilinx Artix-7 `xc7a200tsbg484-1`
* Board: Digilent Nexys Video
* Results generated on Dec. 19th, 2022

| Name | Slice LUTs | Slice Registers | DSPs |
|:-----|-----------:|----------------:|-----:|
| FPGA_Top | 8476 | 4236 | 4 |
| > clkgen (clk_wiz_0) | 0 | 0 | 0 |
| > DUT (airi5c_top_asic) | 6650 | 4167 | 4 |
| >> airi5c (airi5c_core) | 4351 | 2612 | 4 |
| >>> debug_module (airi5c_debug_module) | 168 | 214 | 0 |
| >>> debug_rom (airi5c_debug_rom) | 20 | 75 | 0 |
| >>> mul_div (airi5c_mul_div) | 581 | 337 | 4 |
| >>> pipeline (airi5c_pipeline) | 2963 | 1984 | 0 |
| >>>> csr (airi5c_csr_file) | 394 | 425 | 0 |
| >>>> ctrl (airi5c_ctrl) | 114 | 24 | 0 |
| >>>> decoder (airi5c_decode) | 52 | 65 | 0 |
| >>>> EX_pipeline_regs (airi5c_EX_pregs) | 1049 | 107 | 0 |
| >>>> fetcher (airi5c_fetch) | 283 | 119 | 0 |
| >>>> imm_gen (airi5c_imm_gen) | 3 | 0 | 0 |
| >>>> regfile (airi5c_regfile) | 834 | 1024 | 0 |
| >>>> src_a_mux (airi5c_src_a_mux) | 64 | 0 | 0 |
| >>>> the_dmem_latch (airi5c_dmem_latch) | 16 | 32 | 0 |
| >>>> WB_pipeline_regs (airi5c_WB_pregs) | 155 | 188 | 0 |
| >> dtm (airi5c_dtm) | 86 | 178 | 0 |
| >> gpio0 (airi5c_gpio) | 43 | 33 | 0 |
| >> icap1 (airi5c_icap) | 0 | 2 | 0 |
| >> peripheral_mux (airi5c_periph_mux) | 110 | 24 | 0 |
| >> spi0 (airi5c_spi) | 267 | 336 | 0 |
| >> system_timer (airi5c_timer) | 131 | 163 | 0 |
| >> uart0 (airi5c_uart) | 1664 | 819 | 0 |
| > SRAM (blk_mem_gen_0) | 1819 | 44 | 0 |

#### CoreMark Benchmark

Coremark result @32 MHz on the NexysVideo FPGA Dev Board with local BlockRAM as instruction memory:

```
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 7794
Total time (secs): 15
Iterations/Sec : 80
Iterations : 1200
Compiler version : GCC10.1.0
Compiler flags : -o3
Memory location : STACK
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0x988c
Correct operation validated. See README.md for run and reporting rules.
```

### Application

Requirements for running the _hello world_ example program:
Expand All @@ -130,6 +191,9 @@ Requirements for (re-)building the software example (_optional_):

- [RISC-V GCC Toolchain](https://github.com/riscv-collab/riscv-gnu-toolchain)

:bulb: A pre-compiled version (`*.elf`; including debug symbols) of the example/demo program can be found in
[`bsp/example`](https://github.com/Fraunhofer-IMS/airisc_core_complex/tree/main/bsp/example).

### Simulation / CI

The [`.ci`](https://github.com/Fraunhofer-IMS/airisc_core_complex/tree/main/.ci) ("continuous integration") folder is used
Expand Down
279 changes: 140 additions & 139 deletions bsp/README.md
Original file line number Diff line number Diff line change
@@ -1,139 +1,140 @@
# AIRISC Board Support Package (BSP)

This folder includes everything you need to convert a high-level C/C++ program into
an AIRISC executable.

- [Folder Structure](#Folder-Structure)
- [How to Use](#How-to-Use)
- [CPU Boot](#CPU-Boot)
- [Executable Layout](#Executable-Layout)


## Folder Structure

- `.gitignore`: ignore build artifacts (like object files)
- `common`: linker script, start-up code, main application makefile
- `debugger`: on-chip-debugger: openOCD configuration scripts, GDB helper scripts
- `example`: simple example SW project including a Makefile
- `include`: CPU core and peripheral headers (HAL)
- `source`: CPU core and peripheral sources (HAL)


## Example Program

The `example` folder provides a simple demo program. Run `make` to see the help menu of the
Makefile. This will show all available targets as well as all variables that can be customized.

To generate an ELF file (ready for upload via GDB) run:

```bash
airi5c-base-core/bsp/example$ make clean_all elf
Memory utilization:
text data bss dec hex filename
13756 2108 64 15928 3e38 main.elf
```

This is what the example project directory looks like after compilation:

```bash
airi5c-base-core/bsp/example$ ll
total 256
-rwxrwxrwx. 1 nolting r_1842684567 3517 Nov 9 13:00 main.c
-rwxrwxrwx. 1 nolting r_1842684567 127020 Nov 9 15:29 main.c.o
-rwxrwxrwx. 1 nolting r_1842684567 116416 Nov 9 15:29 main.elf
-rwxrwxrwx. 1 nolting r_1842684567 64 Nov 8 13:52 Makefile
```

## How to Use

Include this repository (the AIRISC base core) as submodule into your software-only
project. :warning: Make sure to keep this submodule updated as the board support package
is maintained (only!) in the AIRISC core repository!

In your main source file (and in other files if needed) you just need to include the main AIRISC
library header, which will automatically include all further AIRISC header files:

```c
#include <airisc.h>
```

### Using Makefile

Copy and rename the `example` folder and use _that_ for your project. Adjust the default
project-local `Makefile` to include additional source files and headers.

Show help screen and list makefile variables:

```bash
airi5c-base-core/bsp/example$ make help
AIRISC Software Application Makefile

=== Targets ===
help - Show this text
check - Check RISC-V GCC toolchain

...
```

Check the installed RISC-V GCC toolchain:

```bash
airi5c-base-core/bsp/example$ make check
---------------- Check: Shell ----------------
/bin/sh
/usr/bin/bash
---------------- Check: riscv32-unknown-elf-gcc ----------------
Using built-in specs.
COLLECT_GCC=riscv32-unknown-elf-gcc
COLLECT_LTO_WRAPPER=/sw/lx_sw/lxcad/xgcc/rv32multi/bin/../libexec/gcc/riscv32-unknown-elf/10.2.0/lto-wrapper
Target: riscv32-unknown-elf

...
```

Check the makefile configuration (flags and variables):

```bash
airi5c-base-core/bsp/example$ make info
---------------- Info: Project ----------------
Project folder: example
Source files: ./main.c
Include folder(s): -I .
ASM include folder(s): -I .
---------------- Info: AIRISC ----------------
AIRISC home folder (AIRISC_HOME): ../..

...
```

:bulb: **TIP** You can override the Makefile variables during invokation of _make_. Example: `make EFFORT=-O3 clean_all elf`

### Using an IDE

Add the submodule's `include`, `source` and `common` folder to your project. Copy the
GCC toolchain configuration (i.e. compiler flags) from the central makefile (`common/common.mk`).


## CPU Boot

The CPU start-up code `common/crt0.S` is responsible for initializing the CPU itself and for
preparing the C runtime environment.

* setup stack pointer and global pointer according to linker script smybols
* initialize all relevant CSRs
* setup trap vector (first-level trap handler defined in `airisc.c`)
* disable interrupts globally
* reset cycle counter `mcycle` and instructions-retired counter `minstret`
* clear all MTIME timer registers (reset system time)
* initialize all integer registers to zero (only register 1..15 if `E` ISA extension is enabled)
* clear `.bss` section (defined by linker script)
* call applications's `main` function; `argc` = `argv` = 0
* if `main` function returns:
* disable interrupts globally
* copy `main`'s return value to `mscratch` (for inspection via debugger)
* (try to) enter sleep mode executing `wfi`
* stall in an endless loop

## Executable Layout

Coming soon.
# AIRISC Board Support Package (BSP)

This folder includes everything you need to convert a high-level C/C++ program into
an AIRISC executable.

- [Folder Structure](#Folder-Structure)
- [How to Use](#How-to-Use)
- [CPU Boot](#CPU-Boot)
- [Executable Layout](#Executable-Layout)


## Folder Structure

- `.gitignore`: ignore build artifacts (like object files)
- `common`: linker script, start-up code, main application makefile
- `debugger`: on-chip-debugger: openOCD configuration scripts, GDB helper scripts
- `example`: simple example SW project including a Makefile
- `include`: CPU core and peripheral headers (HAL)
- `source`: CPU core and peripheral sources (HAL)


## Example Program

The `example` folder provides a simple demo program. Run `make` to see the help menu of the
Makefile. This will show all available targets as well as all variables that can be customized.

To generate an ELF file (ready for upload via GDB) run:

```bash
airi5c-base-core/bsp/example$ make clean_all elf
Memory utilization:
text data bss dec hex filename
13756 2108 64 15928 3e38 main.elf
```

This is what the example project directory looks like after compilation:

```bash
airi5c-base-core/bsp/example$ ll
total 256
-rwxrwxrwx. 1 nolting r_1842684567 3517 Nov 9 13:00 main.c
-rwxrwxrwx. 1 nolting r_1842684567 127020 Nov 9 15:29 main.c.o
-rwxrwxrwx. 1 nolting r_1842684567 116416 Nov 9 15:29 main.elf
-rwxrwxrwx. 1 nolting r_1842684567 64 Nov 8 13:52 Makefile
```

## How to Use

Include this repository (the AIRISC base core) as submodule into your software-only
project. :warning: Make sure to keep this submodule updated as the board support package
is maintained (only!) in the AIRISC core repository!

In your main source file (and in other files if needed) you just need to include the main AIRISC
library header, which will automatically include all further AIRISC header files:

```c
#include <airisc.h>
```
:warning: You want to call the provided test functions `simd_test_uart();` for SIMD and `ai_acc_test();` for AI_ACC, just add them in the `bsp/example/main.c`!

### Using Makefile

Copy and rename the `example` folder and use _that_ for your project. Adjust the default
project-local `Makefile` to include additional source files and headers.

Show help screen and list makefile variables:

```bash
airi5c-base-core/bsp/example$ make help
AIRISC Software Application Makefile

=== Targets ===
help - Show this text
check - Check RISC-V GCC toolchain

...
```

Check the installed RISC-V GCC toolchain:

```bash
airi5c-base-core/bsp/example$ make check
---------------- Check: Shell ----------------
/bin/sh
/usr/bin/bash
---------------- Check: riscv32-unknown-elf-gcc ----------------
Using built-in specs.
COLLECT_GCC=riscv32-unknown-elf-gcc
COLLECT_LTO_WRAPPER=/sw/lx_sw/lxcad/xgcc/rv32multi/bin/../libexec/gcc/riscv32-unknown-elf/10.2.0/lto-wrapper
Target: riscv32-unknown-elf

...
```

Check the makefile configuration (flags and variables):

```bash
airi5c-base-core/bsp/example$ make info
---------------- Info: Project ----------------
Project folder: example
Source files: ./main.c
Include folder(s): -I .
ASM include folder(s): -I .
---------------- Info: AIRISC ----------------
AIRISC home folder (AIRISC_HOME): ../..

...
```

:bulb: **TIP** You can override the Makefile variables during invokation of _make_. Example: `make EFFORT=-O3 clean_all elf`

### Using an IDE

Add the submodule's `include`, `source` and `common` folder to your project. Copy the
GCC toolchain configuration (i.e. compiler flags) from the central makefile (`common/common.mk`).


## CPU Boot

The CPU start-up code `common/crt0.S` is responsible for initializing the CPU itself and for
preparing the C runtime environment.

* setup stack pointer and global pointer according to linker script smybols
* initialize all relevant CSRs
* setup trap vector (first-level trap handler defined in `airisc.c`)
* disable interrupts globally
* reset cycle counter `mcycle` and instructions-retired counter `minstret`
* clear all MTIME timer registers (reset system time)
* initialize all integer registers to zero (only register 1..15 if `E` ISA extension is enabled)
* clear `.bss` section (defined by linker script)
* call applications's `main` function; `argc` = `argv` = 0
* if `main` function returns:
* disable interrupts globally
* copy `main`'s return value to `mscratch` (for inspection via debugger)
* (try to) enter sleep mode executing `wfi`
* stall in an endless loop

## Executable Layout

Coming soon.
Loading

0 comments on commit d926b02

Please sign in to comment.