Skip to content

Commit

Permalink
hero: Working on runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrilKoe committed Feb 23, 2024
1 parent a1a4c7b commit df6afda
Show file tree
Hide file tree
Showing 21 changed files with 1,003 additions and 187 deletions.
21 changes: 10 additions & 11 deletions target/fpga/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,13 @@ CVA6_SDK ?= ${ROOT}/../cva6-sdk
DEBUG ?= 0
EXT_JTAG ?= 0
VCU ?= 01
FPGA_ID := 091847100576A
HW_SERVER := bordcomputer:3231
FPGA_ID :=
HW_SERVER :=
BENDER ?= bender
VIVADO ?= vitis-2020.2 vivado
# Do not proceed with implem (CI)
XILINX_SYNTHESIS_ONLY ?= 0

# Select VCU128-02
ifeq ($(VCU),02)
FPGA_ID := 091847100638A
HW_SERVER := bordcomputer:3232
endif

VIVADO ?= vivado
VIVADO_ARGS := XILINX_SYNTHESIS_ONLY=$(XILINX_SYNTHESIS_ONLY)
MKIMAGE ?= $(CURDIR)/br2_external/install/bin/mkimage
Expand All @@ -36,20 +30,25 @@ LINUX_UIMAGE ?= ${CVA6_SDK}/uImage

DTB = bootrom/occamy.dtb

BENDER_TARGETS += -t cv64a6_imafdc_sv39 -t occamy
ifeq ($(EXT_JTAG), 0)
BENDER_TARGETS += -t bscane
endif

default: all
all: occamy_vcu128

vivado_ips/occamy_xilinx:
${MAKE} -C vivado_ips occamy_xilinx
${MAKE} -C vivado_ips occamy_xilinx DEBUG=$(DEBUG) EXT_JTAG=$(EXT_JTAG)

bootrom/bootrom-spl.coe:
${MAKE} -C bootrom

occamy_vcu128: vivado_ips/occamy_xilinx bootrom/bootrom-spl.coe define_defines_includes_no_simset.tcl
$(VIVADO_ARGS) ${VIVADO} -mode batch -source occamy_vcu128.tcl -tclargs $(DEBUG) $(EXT_JTAG) $(NPROC) ${MKFILE_DIR}/bootrom/bootrom-spl.coe
$(VIVADO_ARGS) ${VIVADO} -mode gui -source occamy_vcu128.tcl -tclargs $(DEBUG) $(EXT_JTAG) $(NPROC) ${MKFILE_DIR}/bootrom/bootrom-spl.coe

define_defines_includes_no_simset.tcl: $(BENDER_FILES)
${BENDER} script vivado -t occamy -t cv64a6_imafdc_sv39 --only-defines --only-includes --no-simset > $@
${BENDER} script vivado $(BENDER_TARGETS) --only-defines --only-includes --no-simset > $@

program:
${VIVADO} -mode batch -source occamy_vcu128_program.tcl -tclargs ${VCU}
Expand Down
3 changes: 3 additions & 0 deletions target/fpga/bootrom/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ bootrom-spl.bin: bootrom.S $(OBJS_C) bootrom.ld occamy.dtb
$(OBJDUMP) -d bootrom-spl.elf > bootrom-spl.dump
$(OBJCOPY) -O binary bootrom-spl.elf bootrom-spl.bin

%.coe: %.bin
bin2coe -i $< -o $@ -w 32

clean:
rm -rf *.bin *.coe *.dump src/*.o *.dtb *.elf *.tcl

Expand Down
15 changes: 10 additions & 5 deletions target/fpga/bootrom/occamy.dts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#address-cells = <2>;
#size-cells = <2>;
ranges;
snitch_mem: buffer@c0000000 {
snitch_mem: l3_mem@c0000000 {
reg = <0x0 0xc0000000 0x0 0x10000000>;
};
};
Expand Down Expand Up @@ -63,7 +63,7 @@
soc: soc {
#address-cells = <2>;
#size-cells = <2>;
compatible = "simple-bus";
compatible = "eth,occamy-soc", "simple-bus";
ranges;
debug@0 {
compatible = "riscv,debug-013";
Expand Down Expand Up @@ -191,9 +191,8 @@
clock-names = "s_axi_lite_clk", "axis_clk";
// interrupt and mac_irq
interrupts-extended = <&PLIC0 1 &PLIC0 6>;
// local-mac-address = [ 00 0A 35 04 E1 60 ]; // hero-vcu128-01
local-mac-address = [ 00 0A 35 04 E1 52 ]; // hero-vcu128-02
mac-address = [ 00 0A 35 04 E1 52 ];
local-mac-address = [ 00 0A 35 07 D5 DD ]; // hero-vcu128-03
mac-address = [ 00 0A 35 07 D5 DD ]; // hero-vcu128-03
device_type = "network";
axistream-connected = <&eth_dma0>;
axistream-control-connected = <&eth_dma0>;
Expand Down Expand Up @@ -238,6 +237,12 @@
reg-names = "quadrant-control";
reg = <0x0 0x0b000000 0x0 0x10000>;
};
// We do not use the spm-narrow (contains OpenSBI code)
spm_wide: spm-wide@71000000 {
compatible = "eth,occamy-spm-wide";
reg-names = "spm-wide";
reg = <0x0 0x71000000 0x0 0x100000>;
};
// Instantiate a snitch cluster
snitch-cluster@10000000 {
compatible = "eth,snitch-cluster";
Expand Down
145 changes: 145 additions & 0 deletions target/fpga/bootrom/occamy_pcie.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Copyright 2021 ETH Zurich and University of Bologna.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0


// TODO(niwis) auto generate
/dts-v1/;
/plugin/;
&{/dev@0,0} {
axi-bus {
#address-cells = <1>;
#size-cells = <2>;
compatible = "simple-bus";
ranges;
// Create a reserved memory region for Snitch program memory
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
snitch_mem: buffer@c0000000 {
reg = <0x0 0xc0000000 0x0 0x10000000>;
};
};
cpus {
#address-cells = <1>;
#size-cells = <0>;
timebase-frequency = <12500000>;
CPU0: cpu@0 {
device_type = "cpu";
status = "okay";
compatible = "eth,ariane", "riscv";
clock-frequency = <25000000>;
riscv,isa = "rv64fimafd";
mmu-type = "riscv,sv39";
tlb-split;
reg = <0>;
// represents the destination of the mcause bits
// ariane has 3 interrupt inputs:
// - software (ipi_i[0], IRQ_M_SOFT)
// - timer (time_irq_i[0], IRQ_M_TIMER)
// - external (irq_i[1:0], {IRQ_S_EXT, IRQ_M_EXT})
CPU0_intc: interrupt-controller {
#interrupt-cells = <1>;
#address-cells = <1>;
interrupt-controller;
compatible = "riscv,cpu-intc";
};
};
};
sysclk: virt_25mhz {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <25000000>;
};
soc: soc {
#address-cells = <2>;
#size-cells = <2>;
compatible = "eth,occamy-soc", "simple-bus";
ranges;
debug@0 {
compatible = "riscv,debug-013";
// interrupts-extended = <&CPU0_intc 65535>;
reg-names = "control";
reg = <0x0 0x0 0x0 0x1000>;
};
serial@2002000 {
compatible = "ns16550a";
reg = <0x0 0x2002000 0x0 0x1000>;
clock-frequency = <25000000>;
current-speed = <115200>;
interrupt-parent = <&PLIC0>;
interrupts = <36>;
reg-offset = <0>;
reg-shift = <2>; // regs are spaced on 32 bit boundary
reg-io-width = <4>; // only 32-bit access are supported
// fifo-size = <64>;
};
timer@2006000 {
compatible = "pulp,apb_timer";
interrupt-parent = <&PLIC0>;
interrupts = <0x00000068 0x00000069 0x00000070 0x00000071>;
reg = <0x00000000 0x2006000 0x00000000 0x00001000>;
reg-names = "control";
};
clint0: clint@4000000 {
clock-frequency = <12500000>;
compatible = "riscv,clint0";
// clint generates software and timer interrupts to the core. Attach them
// to the CPU
// bits in mip and exception code in mcause:
// - IRQ_M_SOFT = 3: Machine software interrupt
// - IRQ_M_TIMER = 7: Machine timer interrupt
interrupts-extended = <&CPU0_intc 3 &CPU0_intc 7>;
reg-names = "clint";
reg = <0x0 0x4000000 0x0 0x100000>;
};
PLIC0: interrupt-controller@c000000 {
compatible = "riscv,plic0";
#address-cells = <0>;
#interrupt-cells = <1>;
interrupt-controller;
// PLIC generates external interrupts to the core, M and S mode
// - IRQ_M_EXT = 11: Machine external interrupt
// - IRQ_S_EXT = 9: Supervisor external interrupt
interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9>;
riscv,max-priority = <6>;
riscv,ndev = <72>;
reg = <0x0 0xc000000 0x0 0x4000000>;
};
soc_ctl0: soc-control@2000000 {
compatible = "eth,occamy-soc-control";
reg-names = "soc-control";
reg = <0x0 0x02000000 0x0 0x1000>;
};
quadrant_ctrl0: quadrant-control@b000000 {
compatible = "eth,occamy-quadrant-control";
reg-names = "quadrant-control";
reg = <0x0 0x0b000000 0x0 0x10000>;
};
scratchpad-narrow@70000000 {
compatible = "eth,scratchpad-narrow";
reg = <0x0 0x70000000 0x0 0x80000>;
};
// Instantiate a snitch cluster
snitch-cluster@10000000 {
compatible = "eth,snitch-cluster";
// TCDM and Peripheral spaces
reg = <0x0 0x10000000 0x0 0x40000>;
// points to a memory region reserved for use by the cluster
memory-region = <&snitch_mem>;
// cluster specific properties
eth,compute-cores = <8>;
eth,dm-cores = <1>;
eth,quadrant-idx = <0>;
eth,cluster-idx = <0>; // Used to calculate offsets in clint, soc-ctrl etc..
// A handle to the soc-control register where isolates etc are located
eth,soc-ctl = <&soc_ctl0>;
// Handle to the associated quadrant controller
eth,quadrant-ctrl = <&quadrant_ctrl0>;
// handle to the clint where IPI interrupts are attached
eth,clint = <&clint0>;
};
};
};
};
5 changes: 3 additions & 2 deletions target/fpga/occamy_vcu128_bd.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ proc create_root_design { parentCell } {
assign_bd_address -offset 0x0011F0000000 -range 0x10000000 -target_address_space [get_bd_addr_spaces occamy/m_axi_hbm_7] [get_bd_addr_segs hbm_0/SAXI_28/HBM_MEM31] -force
assign_bd_address -offset 0x4CC00000 -range 0x00400000 -target_address_space [get_bd_addr_spaces occamy/m_axi_pcie] [get_bd_addr_segs hbm_0/SAPB_0/Reg] -force
assign_bd_address -offset 0x4C800000 -range 0x00400000 -target_address_space [get_bd_addr_spaces occamy/m_axi_pcie] [get_bd_addr_segs hbm_0/SAPB_1/Reg] -force
assign_bd_address -offset 0x20000000 -range 0x00100000 -target_address_space [get_bd_addr_spaces occamy/m_axi_pcie] [get_bd_addr_segs xdma_0/S_AXI_B/BAR0] -force
assign_bd_address -offset 0x20000000 -range 0x20000000 -target_address_space [get_bd_addr_spaces occamy/m_axi_pcie] [get_bd_addr_segs xdma_0/S_AXI_B/BAR0] -force
assign_bd_address -offset 0x00000000 -range 0x20000000 -target_address_space [get_bd_addr_spaces occamy/m_axi_pcie] [get_bd_addr_segs xdma_0/S_AXI_LITE/CTL0] -force
assign_bd_address -offset 0x00000000 -range 0x0001000000000000 -target_address_space [get_bd_addr_spaces xdma_0/M_AXI_B] [get_bd_addr_segs occamy/s_axi_pcie/reg0] -force

Expand Down Expand Up @@ -1163,7 +1163,6 @@ proc create_root_design { parentCell } {
# Restore current instance
current_bd_instance $oldCurInst

validate_bd_design
save_bd_design
}
# End of create_root_design()
Expand All @@ -1176,3 +1175,5 @@ proc create_root_design { parentCell } {
create_root_design ""


common::send_gid_msg -ssname BD::TCL -id 2053 -severity "WARNING" "This Tcl script was generated from a block design that has not been validated. It is possible that design <$design_name> may result in errors during validation."

13 changes: 12 additions & 1 deletion target/fpga/occamy_vcu128_procs.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ proc target_02 {} {
set occ_bit_stem occamy_vcu128/occamy_vcu128.runs/impl_1/occamy_vcu128_wrapper
}

proc target_03 {} {
global occ_hw_server
global occ_target_serial
global occ_hw_device
global occ_bit_stem
set occ_hw_server bordcomputer:3233
set occ_target_serial 12309159258A
set occ_hw_device xcvu37p_0
set occ_bit_stem occamy_vcu128/occamy_vcu128.runs/impl_1/occamy_vcu128_wrapper
}

proc occ_connect { } {
global occ_hw_server
global occ_target_serial
Expand Down Expand Up @@ -144,4 +155,4 @@ proc occ_flash_spi { mcs_file flash_offset flash_file } {
# Program SPI flash
puts "Programing SPI flash"
program_hw_cfgmem -hw_cfgmem $hw_cfgmem
}
}
4 changes: 3 additions & 1 deletion target/sim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ PLATFORM_HEADERS += $(PLATFORM_HEADERS_DIR)/snitch_cluster_peripheral.h
PLATFORM_HEADERS += $(PLATFORM_HEADERS_DIR)/snitch_quad_peripheral.h
PLATFORM_HEADERS += $(PLATFORM_HEADERS_DIR)/snitch_hbm_xbar_peripheral.h

.PHONY: sw clean-headers clean-sw
.PHONY: sw all-headers clean-headers clean-sw

all-headers: $(PLATFORM_HEADERS)

sw: $(PLATFORM_HEADERS)
$(MAKE) -C sw/ all
Expand Down
2 changes: 2 additions & 0 deletions target/sim/sw/device/apps/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ BUILDDIR = $(abspath build)
# Dependencies
INCDIRS += $(RUNTIME_DIR)/src
INCDIRS += $(SNRT_DIR)/api
INCDIRS += $(SNRT_DIR)/api/omp
INCDIRS += $(SNRT_DIR)/src
INCDIRS += $(SNRT_DIR)/src/omp
INCDIRS += $(SNRT_DIR)/vendor/riscv-opcodes
INCDIRS += $(SW_DIR)/shared/platform/generated
INCDIRS += $(SW_DIR)/shared/platform
Expand Down
10 changes: 6 additions & 4 deletions target/sim/sw/device/apps/libomptarget_device/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MK_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
SRC_DIR := $(realpath $(MK_DIR)/src)

APP ?= omptarget_device
SRCS ?= $(SRC_DIR)/main.c
SRCS ?= $(SRC_DIR)/main.c $(SRC_DIR)/sw_mailbox.c
INCDIRS += $(SRC_DIR)

.PHONY: clean
Expand All @@ -21,10 +21,12 @@ OBJS := $(subst $(SRC_DIR), $(BUILDDIR), $(SRCS:.c=.o))
LIB := $(BUILDDIR)/libomptarget_device.a

$(BUILDDIR)/origin.ld: | $(BUILDDIR)
echo "L3_ORIGIN = 0x80000000;" > $(BUILDDIR)/origin.ld
echo "L3_ORIGIN = 0xC0000000;" > $(BUILDDIR)/origin.ld

$(LIB): $(OBJS) | $(BUILDDIR)
$(RISCV_AR) $(RISCV_ARFLAGS) $@ $^
# We first extract objects from libnnruntime and then link them with our objects
$(BUILDDIR)/libomptarget_device.a: $(OBJS) | $(BUILDDIR)
cd $(BUILDDIR) && $(RISCV_AR) -x $(SNRT_LIB_DIR)/lib$(SNRT_LIB_NAME).a
$(RISCV_AR) $(RISCV_ARFLAGS) $@ $(BUILDDIR)/*.o

# For this target, only build the library
all: $(LIB)
Loading

0 comments on commit df6afda

Please sign in to comment.