Skip to content

Commit

Permalink
[#48860] Add prebuilt example
Browse files Browse the repository at this point in the history
  • Loading branch information
JanOlencki committed Sep 13, 2023
1 parent d8e648a commit 69a7acb
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 15 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/dpi-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,46 @@ on:
type: string

jobs:
run-prebuilt-sample:
name: "Run prebuilt sample"
strategy:
matrix:
config:
- runner: ubuntu-20.04
renode_url: ${{ inputs.renode_url_linux || 'https://builds.renode.io/renode-latest.linux-portable.tar.gz' }}
- runner: windows-latest
renode_url: ${{ inputs.renode_url_windows || 'https://builds.renode.io/renode-latest.zip' }}
runs-on: ${{ matrix.config.runner }}
defaults:
run:
shell: bash
env:
RENODE_ARGS: -e "emulation RunFor \"20\"; quit"

steps:
- uses: actions/checkout@v3

- name: Download Renode
run: curl -sSLO ${{ matrix.config.renode_url }}
- name: Unpack Renode for Linux
if: ${{ runner.os != 'Windows' }}
run: |
mkdir renode
tar xf renode*.tar.gz --strip-components 1 -C renode
- name: Unpack Renode for Windows
if: ${{ runner.os == 'Windows' }}
run: |
unzip renode*.zip
rm renode*.zip
mv renode_* renode
- name: Run Renode on Linux
if: ${{ runner.os != 'Windows' }}
run: renode/renode ${{ env.RENODE_ARGS }} samples/axi_fastvdma_prebuilt/platform.resc
- name: Run Renode on Windows
if: ${{ runner.os == 'Windows' }}
run: renode\bin\Renode.exe ${{ env.RENODE_ARGS }} samples\axi_fastvdma_prebuilt\platform.resc

build-verilator-linux:
uses: ./.github/workflows/build-verilator.yml
with:
Expand Down
52 changes: 37 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,42 @@ The HDL top simulation file contains Renode related snippets:
> **Note**
> The code intentionally blocks the elapse of the simulation time while waiting for a message.
## Usage of prebuilt example

### Preparing Renode
The rest of this instruction assumes you have Renode in the `renode` directory inside this repository. You just need to download and extract it, and install dependencies for the Robot test framework. Follow the steps below.

#### Linux
Run commands
```bash
wget --progress=dot:giga https://builds.renode.io/renode-latest.linux-portable.tar.gz
mkdir renode
tar -xf renode-latest.linux-portable.tar.gz --strip-components 1 -C renode
python3 -m pip install -r renode/tests/requirements.txt
```

#### Windows
* Download [the Renode nightly package](https://builds.renode.io/renode-latest.zip)
* Extract it to the `renode` directory
* Run `python -m pip install -r renode/tests/requirements.txt`

### Running Linux on Zynq-7000 with verilated FastVDMA
Run one of the commands below. It will start Renode and show two windows:
* Monitor which can be used to manage a simulation
* UART analyzer with terminal for interaction with Linux on Zynq-7000

This sample uses a prebuilt executable of a verilated [FastVDMA controller](https://github.com/antmicro/fastvdma).

#### Linux
```bash
renode/renode -e start samples/axi_fastvdma_prebuilt/platform.resc
```

#### Windows
```cmd
renode\bin\Renode.exe -e start samples\axi_fastvdma_prebuilt\platform.resc
```

## Usage

### Building Verilator
Expand All @@ -38,21 +74,7 @@ make -j `nproc`
```

### Preparing Renode
The rest of this instruction assumes you have Renode in the `renode` directory inside this repository. You just need to download and extract it, and install dependencies for the Robot test framework. Follow the steps below.

#### Linux
Run commands
```bash
wget --progress=dot:giga https://builds.renode.io/renode-latest.linux-portable.tar.gz
mkdir renode
tar -xf renode-latest.linux-portable.tar.gz --strip-components 1 -C renode
python3 -m pip install -r renode/tests/requirements.txt
```

#### Windows
* Download [the Renode nightly package](https://builds.renode.io/renode-latest.zip)
* Extract it to the `renode` directory
* Run `python -m pip install -r renode/tests/requirements.txt`
You can find an instruction on preparing Renode in [the previous section](/#preparing-renode).

### Building a sample

Expand Down
12 changes: 12 additions & 0 deletions samples/axi_fastvdma_prebuilt/platform.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using "platforms/boards/zedboard.repl"

dma: Verilated.VerilatedPeripheral @ sysbus <0x43c20000, +0x100>
maxWidth: 32
// Changing frequency to a non-default value breaks timings in a trace.
// But it improves a performance of Linux simulation.
frequency: 1000000
limitBuffer: 1000
timeout: 20000
numberOfInterrupts: 2
address: "127.0.0.1"
1 -> gic@31
42 changes: 42 additions & 0 deletions samples/axi_fastvdma_prebuilt/platform.resc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
:name: FastVDMA Cosimulation on Zynq
:description: This script runs Linux with built in FastVDMA driver on Zedboard.

using sysbus
$name?="Zynq-FastVDMA"
mach create $name

machine LoadPlatformDescription $ORIGIN/platform.repl

sysbus Redirect 0xC0000000 0x0 0x10000000

$bin?=@https://dl.antmicro.com/projects/renode/zynq-fastvdma_vmlinux-s_13611036-802d102e9341668636631447e99389f79043c18d
$rootfs?=@https://dl.antmicro.com/projects/renode/zynq-fastvdma_rootfs.ext2-s_33554432-7a53506ed3e6cdaf247280ad7025ff1aa4cb98c5
$dtb?=@https://dl.antmicro.com/projects/renode/zynq-fastvdma.dtb-s_12284-4f3a630a9bce9e0984151b95e9efa581ef7525bf

### create externals ###
showAnalyzer sysbus.uart1

## set timer frequency ##
ttc0 Frequency 33333333
ttc1 Frequency 33333333

dma SimulationFilePathLinux @https://dl.antmicro.com/projects/renode/renode-dpi-axi_fastvdma-verilated-s_2198472-214cbf7bc6d0bec2845f6b1c1bf9a66e6bbf3fd0
dma SimulationFilePathWindows @https://dl.antmicro.com/projects/renode/renode-dpi-axi_fastvdma-verilated.exe-s_4639440-4529c753cc329e0608ad953660983133253aae58

macro reset
"""
### set registers ###

cpu SetRegisterUnsafe 0 0x000
cpu SetRegisterUnsafe 1 0xD32 # board id
cpu SetRegisterUnsafe 2 0x100 # device tree address

### load binaries ###

sysbus LoadELF $bin
sysbus LoadFdt $dtb 0x100 "console=ttyPS0,115200 root=/dev/ram0 rw earlyprintk initrd=0x1a000000,32M" false
sysbus ZeroRange 0x1a000000 0x800000
sysbus LoadBinary $rootfs 0x1a000000
"""

runMacro $reset

0 comments on commit 69a7acb

Please sign in to comment.