:name: Murax SoC with VexRiscv
:description: This script runs an echo demo using a verilated UART.

$name?="APB3UART"

using sysbus
mach create $name
machine LoadPlatformDescription @platforms/cpus/verilated/murax_vexriscv_verilated_uart.repl

# Binaries from https://github.com/antmicro/renode-verilator-integration, rev. f9b4139
$uartLinux?=@https://dl.antmicro.com/projects/renode/libVapb3uart-Linux-x86_64-12746432362.so-s_2075112-cdd84640aaef40f017ea1739f3a81f07bd739908
$uartWindows?=@https://dl.antmicro.com/projects/renode/libVapb3uart-Windows-x86_64-12746432362.dll-s_3239943-9bb6d65ee4f7a2945d3dfb3d503f90f399ad0cf8
$uartMacOS?=@https://dl.antmicro.com/projects/renode/libVapb3uart-macOS-x86_64-12746432362.dylib-s_220440-f0c9f7e8fd31d14f9e0eda3437cdf419494abee8

showAnalyzer uart

uart SimulationFilePathLinux $uartLinux
uart SimulationFilePathWindows $uartWindows
# uart SimulationFilePathMacOS $uartMacOS

macro reset
"""
    sysbus LoadELF @https://dl.antmicro.com/projects/renode/murax--demo.elf-s_26952-7635fc30d0a3ed10c5b7cba622131b02d103f629
    sysbus.cpu MTVEC 0x80000020
"""

runMacro $reset

# this is a hack to allow handling interrupts at all; this should be after #13326
cpu SetMachineIrqMask 0xffffffff

## set frame length in the FrameCongfig register (0xC)
sysbus WriteDoubleWord 0xF001000C 0x000F
