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
21 changes: 11 additions & 10 deletions .github/workflows/standalone_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ jobs:
# simulator: ["etiss", "spike"]
simulator: ["etiss"]
full: ["0", "1"]
config:
- {arch: "rv32im_zicsr_zifencei", abi: "ilp32", gnu_name: "riscv32-unknown-elf", gnu_version: "2024.09.03", llvm_version: "19.1.1"}
- {arch: "rv32gc", abi: "ilp32d", gnu_name: "riscv32-unknown-elf", gnu_version: "2024.09.03", llvm_version: "19.1.1"}
# TODO: rv64 and rvv
env:
INSTALL_DIR: ${{ github.workspace }}/examples/standalone/install
VENV_DIR: ${{ github.workspace }}/venv
PYTHONPATH: ${{ github.workspace }}
RISCV_NAME: "riscv32-unknown-elf"
RISCV_ARCH: "rv32im_zicsr_zifencei"
RISCV_ABI: "ilp32"
SIMULATOR: ${{ matrix.simulator }}
TOOLCHAIN: ${{ matrix.toolchain }}
FULL: ${{ matrix.full }}
Expand All @@ -64,7 +65,7 @@ jobs:
- name: Setup dependencies
working-directory: examples/standalone
run: |
./scripts/download_helper.sh $INSTALL_DIR/rv32im_ilp32/ gnu 2024.09.03 rv32im_zicsr_zifencei_ilp32
./scripts/download_helper.sh $INSTALL_DIR/${{ matrix.config.arch }}_${{ matrix.config.abi }}/ gnu 2024.09.03 rv32im_zicsr_zifencei_ilp32

if [[ "$TOOLCHAIN" == "llvm" ]]
then
Expand All @@ -83,10 +84,10 @@ jobs:
export SESS=$(pwd)/sess
export BUILD_DIR=$(pwd)/build

export RISCV_PREFIX=$INSTALL_DIR/rv32im_ilp32
export SYSROOT=$RISCV_PREFIX/$RISCV_NAME
export CC=$RISCV_PREFIX/bin/$RISCV_NAME-gcc
export OBJDUMP=$RISCV_PREFIX/bin/$RISCV_NAME-objdump
export RISCV_PREFIX=$INSTALL_DIR/${{ matrix.config.arch }}_${{ matrix.config.abi }}
export SYSROOT=$RISCV_PREFIX/${{ matrix.config.gnu_name }}
export CC=$RISCV_PREFIX/bin/${{ matrix.config.gnu_name }}-gcc
export OBJDUMP=$RISCV_PREFIX/bin/${{ matrix.config.gnu_name }}-objdump

if [[ "$SIMULATOR" == "etiss" ]]
then
Expand All @@ -109,10 +110,10 @@ jobs:
mkdir -p $BUILD_DIR
if [[ "$SIMULATOR" == "etiss" ]]
then
$CC -march=$RISCV_ARCH -mabi=$RISCV_ABI src/*.c $ETISS_CRT/crt0.S $ETISS_CRT/trap_handler.c -T $ETISS_LDSCRIPT -nostdlib -lc -lgcc -lsemihost -o $BUILD_DIR/coremark.elf -Iinc/ -DITERATIONS=100 -DFLAGS_STR='"testing"' -DPERFORMANCE_RUN -DHAS_STDIO -g -O3 -Xlinker -Map=build/coremark.map
$CC -march=${{ matrix.config.arch }} -mabi=${{ matrix.config.abi }} src/*.c $ETISS_CRT/crt0.S $ETISS_CRT/trap_handler.c -T $ETISS_LDSCRIPT -nostdlib -lc -lgcc -lsemihost -o $BUILD_DIR/coremark.elf -Iinc/ -DITERATIONS=100 -DFLAGS_STR='"testing"' -DPERFORMANCE_RUN -DHAS_STDIO -g -O3 -Xlinker -Map=build/coremark.map
elif [[ "$SIMULATOR" == "spike" ]]
then
$CC -march=$RISCV_ARCH -mabi=$RISCV_ABI src/*.c -o $BUILD_DIR/coremark.elf -Iinc/ -DITERATIONS=100 -DFLAGS_STR='"testing"' -DPERFORMANCE_RUN -DHAS_STDIO -g -O3 -Xlinker -Map=build/coremark.map
$CC -march=${{ matrix.config.arch }} -mabi=${{ matrix.config.abi }} src/*.c -o $BUILD_DIR/coremark.elf -Iinc/ -DITERATIONS=100 -DFLAGS_STR='"testing"' -DPERFORMANCE_RUN -DHAS_STDIO -g -O3 -Xlinker -Map=build/coremark.map
else
echo "Unsupported SIMULATOR=$SIMULATOR"
exit 1
Expand Down
36 changes: 30 additions & 6 deletions examples/standalone/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,53 @@ or similar.

```sh
# rv32im_ilp32
./scripts/download_helper.sh $INSTALL_DIR/rv32im_ilp32/ gnu 2024.09.03 rv32im_zicsr_zifencei_ilp32
./scripts/download_helper.sh $INSTALL_DIR/rv32im_ilp32/ gnu 2025.06.13 rv32im_zicsr_zifencei_ilp32

# rv32im_zve32x_ilp32
./scripts/download_helper.sh $INSTALL_DIR/rv32im_zve32x_ilp32/ gnu 2025.06.13 rv32im_zicsr_zifencei_zve32x_ilp32

# rv32gc_ilp32d
./scripts/download_helper.sh $INSTALL_DIR/rv32gc_ilp32d/ gnu 2025.06.13 rv32gc_ilp32d

# rv32gcv_ilp32d
./scripts/download_helper.sh $INSTALL_DIR/rv32gcv_ilp32d/ gnu 2025.06.13 rv32gcv_ilp32d

# rv64gc_lp64d
./scripts/download_helper.sh $INSTALL_DIR/rv64gc_lp64d/ gnu 2025.06.13 rv64gc_lp64d riscv64-unknown-elf

# rv64gcv_lp64d
./scripts/download_helper.sh $INSTALL_DIR/rv64gcv_lp64d/ gnu 2025.06.13 rv64gcv_lp64d riscv64-unknown-elf
```

### LLVM

```sh
# llvm 19
./scripts/download_helper.sh $INSTALL_DIR/llvm/ llvm 19.1.1

# llvm 20
./scripts/download_helper.sh $INSTALL_DIR/llvm/ llvm 0.1.8
```

## Simulators

### ETISS

```sh
# NOT IMPLEMENTED!
# ./scripts/download_helper.sh $INSTALL_DIR/etiss/ etiss 2024.11.28

# Alternative:
# prebuilt
# ./scripts/download_helper.sh $INSTALL_DIR/etiss/install etiss 2024.11.28
# ./scripts/setup_etiss_examples.sh $INSTALL_DIR/etiss
#
# from source:
./scripts/setup_etiss.sh $INSTALL_DIR/etiss
./scripts/setup_etiss_examples.sh $INSTALL_DIR/etiss
```

### Spike

Make sure to have `device-tree-compiler` (`dtc`) installed on your system.

```sh
./scripts/download_helper.sh $INSTALL_DIR/spike/ spike 2024.11.28
./scripts/download_helper.sh $INSTALL_DIR/spike/ spike 0bc176b3
```

11 changes: 11 additions & 0 deletions examples/standalone/coremark/qemu_cmds.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

# Full System mode (broken, needs HTIF?)
qemu-system-riscv32 -machine spike -bios none -icount shift=1 -cpu rv32,v=true,vlen=128,elen=64,vext_spec=v1.0 -nographic -kernel build/coremark.elf
# freezes:
qemu-system-riscv32 -machine virt -bios none -icount shift=1 -cpu rv32,v=true,vlen=128,elen=64,vext_spec=v1.0 -nographic -kernel build/coremark.elf
# User mode
make SIMULATOR=spike FORCE=1 clean all
qemu-riscv32 -one-insn-per-tb -singlestep -D log -d exec,nochain build/coremark.elf

# TODO: integrate in makefile using qemu_riscv{32,64}_{system,user}
# TODO: hwo about -icout step=1 ???
6 changes: 2 additions & 4 deletions examples/standalone/scripts/download_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ then
elif [[ "$tool_lower" == "spike" ]]
then
# TODO: label?
archive=spike-linux-gnu-$dist_lower-$release.$ext
archive=spike-x86_64-linux-gnu-$dist_lower-$release.$ext
elif [[ "$tool_lower" == "etiss" ]]
then
# TODO: label?
archive=etiss-linux-gnu-$dist_lower-$release.$ext
echo "ETISS tool not implemented!"
exit 1
archive=etiss-x86_64-linux-gnu-$dist_lower-$release.$ext
else
echo "Unsupported tool: $toolchain_lower"
exit 1
Expand Down
2 changes: 2 additions & 0 deletions examples/standalone/scripts/setup_etiss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ cmake -B $ETISS_BUILD_DIR -S $ETISS_DIR -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DC
cmake --build $ETISS_BUILD_DIR -j$NPROC
cmake --install $ETISS_BUILD_DIR

# TODO: call setup_etiss_min.sh

export MEM_ROM_ORIGIN=0x10000000
export MEM_ROM_LENGTH=0x00400000
export MEM_RAM_ORIGIN=0x20000000
Expand Down
170 changes: 170 additions & 0 deletions examples/standalone/scripts/setup_etiss_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#!/bin/bash

set -e

if [ "$#" -lt 1 ]; then
echo "Illegal number of parameters!"
echo "Usage: $0 DEST [ETISS_REF [BUILD_TYPE]]"
exit 1
fi

ETISS_DIR=$(readlink -f $1)
ETISS_EXAMPLES_DIR=$ETISS_DIR/etiss_riscv_examples
ETISS_INSTALL_DIR=$ETISS_DIR/install

mkdir -p $ETISS_DIR

if [[ ! -d $ETISS_INSTALL_DIR ]]
then
echo "ETISS installation is missing!"
exit 1
fi

if [[ -d $ETISS_EXAMPLES_DIR ]]
then
echo "ETISS examples already cloned!"
else
git clone https://github.com/tum-ei-eda/etiss_riscv_examples.git $ETISS_EXAMPLES_DIR
fi

export MEM_ROM_ORIGIN=0x10000000
export MEM_ROM_LENGTH=0x00400000
export MEM_RAM_ORIGIN=0x20000000
export MEM_RAM_LENGTH=0x00100000

export MIN_STACK_SIZE=0x1000
export MIN_HEAP_SIZE=0x1000

cat <<EOT > $ETISS_INI
[StringConfigurations]
etiss.output_path_prefix=
jit.type=TCCJIT

[BoolConfigurations]
arch.or1k.ignore_sr_iee=false
jit.gcc.cleanup=true
jit.verify=false
etiss.load_integrated_libraries=true
jit.debug=false
etiss.enable_dmi=false
etiss.log_pc=false

[IntConfigurations]
arch.or1k.if_stall_cycles=0
etiss.max_block_size=100
arch.cpu_cycle_time_ps=31250
ETISS::CPU_quantum_ps=100000
ETISS::write_pc_trace_from_time_us=0
ETISS::write_pc_trace_until_time_us=3000000
ETISS::sim_mode=0
vp::simulation_time_us=20000000
etiss.loglevel=4

[BoolConfigurations]
arch.enable_semihosting=true

[IntConfigurations]
simple_mem_system.memseg_origin_00=$MEM_ROM_ORIGIN
simple_mem_system.memseg_length_00=$MEM_ROM_LENGTH
simple_mem_system.memseg_origin_01=$MEM_RAM_ORIGIN
simple_mem_system.memseg_length_01=$MEM_RAM_LENGTH
EOT

cat <<EOT > $ETISS_LDSCRIPT
/*
// Copyright 2017 ETH Zurich and University of Bologna.
// Copyright and related rights are licensed under the Solderpad Hardware
// License, Version 0.51 (the “License”); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
// or agreed to in writing, software, hardware and materials distributed under
// this 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.

// This file was modified by the Chair of Electronic Design Automation, TUM
*/

ENTRY(_start)
SEARCH_DIR(.)


MEMORY
{
ROM (rx) : ORIGIN = $MEM_ROM_ORIGIN, LENGTH = $MEM_ROM_LENGTH
RAM (rw) : ORIGIN = $MEM_RAM_ORIGIN, LENGTH = $MEM_RAM_LENGTH
}

/* minimum sizes for heap and stack. It will be checked that they can fit on the RAM */
__stack_size = $MIN_STACK_SIZE;
__heap_size = $MIN_HEAP_SIZE;


SECTIONS
{
/* ================ ROM ================ */

.text : {
*(.text .text.* )
} > ROM

.rodata : {
*(.rodata .rodata.*)
} > ROM
.srodata : {
*(.srodata .srodata.*)
} > ROM



/* ================ RAM ================ */

.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(.init_array .init_array.*))
PROVIDE_HIDDEN (__init_array_end = .);
} > RAM
.fini_array : {
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array .fini_array.*))
PROVIDE_HIDDEN (__fini_array_end = .);
} > RAM

.gcc_except_table : {
*(.gcc_except_table .gcc_except_table.*)
} > RAM

.eh_frame : {
KEEP (*(.eh_frame))
} > RAM

__data_start = .;
.data : {
*(.data .data.*)
} > RAM
__sdata_start = .;
.sdata : {
*(.sdata .sdata.*)
} > RAM

__bss_start = .;
.sbss : {
*(.sbss .sbss.*)
} > RAM
.bss : {
*(.bss .bss.*)
} > RAM
_end = .;

/* do not place anything after this address, because the heap starts here! */

/* point the global pointer so it can access sdata, sbss, data and bss */
__global_pointer$ = MIN(__sdata_start + 0x800, MAX(__data_start + 0x800, _end - 0x800));

/* stack pointer starts at the top of the ram */
__stack = ORIGIN(RAM) + LENGTH(RAM);
.stack : {
ASSERT ((__stack > (_end + __heap_size + __stack_size)), "Error: RAM too small for heap and stack");
}
}
EOT
30 changes: 30 additions & 0 deletions isaac_toolkit/frontend/instr_trace/riscv_qemu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pandas as pd
from tqdm import tqdm

input_file = "/workspaces/isaac-toolkit/examples/standalone/coremark/log"

dfs = []
# 'with' context works in pandas >= 1.4 for TextFileReader
with pd.read_csv(
input_file,
sep="@",
header=None,
chunksize=2**22, # ~4 million lines per chunk
# chunksize=2**20, # ~4 million lines per chunk
engine="python",
) as reader:
for df in tqdm(reader, disable=False):
# print("A", df.head())
# df is a DataFrame chunk
# e.g., extract PCs here
pcs_chunk = df[0].str.extract(r"\[(?:[^/]+/){1}([^/]+)/")[0].apply(lambda x: int(x, 16))
pcs_chunk = pcs_chunk.astype("category")

print("B", pcs_chunk.head(), len(pcs_chunk), pcs_chunk.dtypes, pcs_chunk.memory_usage())
# process pcs_chunk or append to list
dfs.append(pcs_chunk)

full_df = pd.concat(dfs)
full_df = full_df.astype("category")

print("FULL", full_df.head(), len(full_df), full_df.dtypes, full_df.memory_usage())
Loading