Skip to content

Commit

Permalink
Merge branch 'control-pulp' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
bluewww committed Jun 17, 2022
2 parents dd39b06 + 07c26b5 commit 1ddf104
Show file tree
Hide file tree
Showing 28 changed files with 2,082 additions and 79 deletions.
4 changes: 2 additions & 2 deletions bin/openocd-genesys2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ ftdi_layout_signal nTRST -ndata 0x0010

set _CHIPNAME riscv

jtag newtap $_CHIPNAME unknown0 -irlen 5 -expected-id 0x10102001
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x249511C3
jtag newtap $_CHIPNAME unknown0 -irlen 5 -expected-id 0x53501db3
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x5cafedb3

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME -coreid 0x3e0
Expand Down
4 changes: 4 additions & 0 deletions configs/control-pulp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ else
fi

source $scriptDir/common.sh

export PULPRT_CONFIG_CFLAGS='-DARCHI_ASIC_PER_FREQUENCY=100000000 \
-DARCHI_ASIC_FC_FREQUENCY=100000000 \
-DARCHI_ASIC_CL_FREQUENCY=100000000'
21 changes: 21 additions & 0 deletions configs/fpgas/control-pulp/zcu102.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -e

export PULPRT_TARGET=control-pulp
export PULPRUN_TARGET=control-pulp

if [ -n "${ZSH_VERSION:-}" ]; then
DIR="$(readlink -f -- "${(%):-%x}")"
scriptDir="$(dirname $DIR)"
else
scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
fi

source $scriptDir/../../common.sh

export PULPRUN_PLATFORM=fpga

export PULPRT_CONFIG_CFLAGS='-DARCHI_FPGA_PER_FREQUENCY=10000000 \
-DARCHI_FPGA_FC_FREQUENCY=20000000 \
-DARCHI_FPGA_CL_FREQUENCY=20000000'

export io=uart
19 changes: 19 additions & 0 deletions configs/kairos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -e

export PULPRT_TARGET=kairos
export PULPRUN_TARGET=kairos

if [ -n "${ZSH_VERSION:-}" ]; then
DIR="$(readlink -f -- "${(%):-%x}")"
scriptDir="$(dirname $DIR)"
else

scriptDir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"

fi

source $scriptDir/common.sh

export PULPRT_CONFIG_CFLAGS='-DARCHI_ASIC_PER_FREQUENCY=100000000 \
-DARCHI_ASIC_FC_FREQUENCY=100000000 \
-DARCHI_ASIC_CL_FREQUENCY=100000000'
4 changes: 4 additions & 0 deletions include/archi/chips/control-pulp/memory_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
#define ARCHI_HWCE_OFFSET 0x00001000
#define ARCHI_ICACHE_CTRL_OFFSET 0x00001400
#define ARCHI_MCHAN_EXT_OFFSET 0x00001800
#define ARCHI_IDMA_EXT_OFFSET 0x00001800

#define ARCHI_CLUSTER_PERIPHERALS_ADDR ( ARCHI_CLUSTER_ADDR + ARCHI_CLUSTER_PERIPHERALS_OFFSET )
#define ARCHI_CLUSTER_PERIPHERALS_GLOBAL_ADDR(cid) ( ARCHI_CLUSTER_GLOBAL_ADDR(cid) + ARCHI_CLUSTER_PERIPHERALS_OFFSET )
Expand All @@ -107,6 +108,7 @@
#define ARCHI_EU_ADDR ( ARCHI_CLUSTER_PERIPHERALS_ADDR + ARCHI_EU_OFFSET )
#define ARCHI_HWCE_ADDR ( ARCHI_CLUSTER_PERIPHERALS_ADDR + ARCHI_HWCE_OFFSET )
#define ARCHI_MCHAN_EXT_ADDR ( ARCHI_CLUSTER_PERIPHERALS_ADDR + ARCHI_MCHAN_EXT_OFFSET )
#define ARCHI_IDMA_EXT_ADDR ( ARCHI_CLUSTER_PERIPHERALS_ADDR + ARCHI_IDMA_EXT_OFFSET )



Expand All @@ -118,11 +120,13 @@

#define ARCHI_EU_DEMUX_OFFSET ( 0x00000 )
#define ARCHI_MCHAN_DEMUX_OFFSET ( 0x00400 )
#define ARCHI_IDMA_DEMUX_OFFSET ( 0x00400 )


#define ARCHI_DEMUX_PERIPHERALS_ADDR ( ARCHI_CLUSTER_ADDR + ARCHI_DEMUX_PERIPHERALS_OFFSET )

#define ARCHI_EU_DEMUX_ADDR ( ARCHI_DEMUX_PERIPHERALS_ADDR + ARCHI_EU_DEMUX_OFFSET )
#define ARCHI_MCHAN_DEMUX_ADDR ( ARCHI_DEMUX_PERIPHERALS_ADDR + ARCHI_MCHAN_DEMUX_OFFSET )
#define ARCHI_IDMA_DEMUX_ADDR ( ARCHI_DEMUX_PERIPHERALS_ADDR + ARCHI_IDMA_DEMUX_OFFSET )

#endif
58 changes: 33 additions & 25 deletions include/archi/chips/control-pulp/properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* FPGA
*/

#define ARCHI_FPGA_FREQUENCY 5000000

/*
* MEMORIES
Expand Down Expand Up @@ -67,9 +66,14 @@
#define ITC_VERSION 1
#define FLL_VERSION 1
#define RISCV_VERSION 4
#define MCHAN_VERSION 7
// TODO: if we have to switch between idma and mchan, make this configurable with #ifdef
//#define MCHAN_VERSION 7
#define IDMA_VERSION 1
#define PADS_VERSION 2

#if defined(MCHAN_VERSION) && defined(IDMA_VERSION)
#error "MCHAN and IDMA not compatible"
#endif

/*
* CLUSTER
Expand All @@ -80,6 +84,7 @@
#define ARCHI_CLUSTER_NB_PE 8
#define ARCHI_NB_CLUSTER 1

#define ARCHI_HAS_DMA_DEMUX 1

/*
* HWS
Expand All @@ -96,7 +101,7 @@
#define ARCHI_FC_CID 31
#define ARCHI_HAS_FC_ITC 1
#define ARCHI_HAS_FC 1

#define ARCHI_CORE_HAS_1_10 1

/*
* CLOCKS
Expand All @@ -113,33 +118,31 @@

#define ARCHI_UDMA_HAS_SPIM 1
#define ARCHI_UDMA_HAS_UART 1
#define ARCHI_UDMA_HAS_SDIO 1
#define ARCHI_UDMA_HAS_SDIO 0
#define ARCHI_UDMA_HAS_I2C 1
#define ARCHI_UDMA_HAS_I2S 1
#define ARCHI_UDMA_HAS_CAM 1
#define ARCHI_UDMA_HAS_TRACER 1
#define ARCHI_UDMA_HAS_FILTER 1
#define ARCHI_UDMA_HAS_I2S 0
#define ARCHI_UDMA_HAS_CAM 0
#define ARCHI_UDMA_HAS_TRACER 0
#define ARCHI_UDMA_HAS_FILTER 0

#define ARCHI_UDMA_NB_SPIM 1
#define ARCHI_UDMA_NB_SPIM 8
#define ARCHI_UDMA_NB_UART 1
#define ARCHI_UDMA_NB_SDIO 1
#define ARCHI_UDMA_NB_I2C 1
#define ARCHI_UDMA_NB_I2S 1
#define ARCHI_UDMA_NB_CAM 1
#define ARCHI_UDMA_NB_TRACER 1
#define ARCHI_UDMA_NB_FILTER 1
#define ARCHI_UDMA_NB_SDIO 0
#define ARCHI_UDMA_NB_I2C 12
#define ARCHI_UDMA_NB_I2S 0
#define ARCHI_UDMA_NB_CAM 0
#define ARCHI_UDMA_NB_TRACER 0
#define ARCHI_UDMA_NB_FILTER 1

#define ARCHI_UDMA_UART_ID(id) 0
#define ARCHI_UDMA_SPIM_ID(id) (1 + (id))
#define ARCHI_UDMA_I2C_ID(id) (9 + (id))
#define ARCHI_UDMA_SDIO_ID(id) (21 + (id))
#define ARCHI_UDMA_FILTER_ID(id) (22 + (id))
#define ARCHI_UDMA_TRACER_ID(id) 23
#define ARCHI_UDMA_TGEN_ID(id) 24

#define ARCHI_NB_PERIPH 25
#define ARCHI_UDMA_FILTER_ID(id) (21 + (id))

#define ARCHI_NB_PERIPH 22

#define ARCHI_UDMA_NB_I2C_MAX 12
#define ARCHI_UDMA_NB_SPIM_MAX 8

/*
* FLLS
Expand All @@ -162,9 +165,12 @@
#define ARCHI_SOC_EVENT_UDMA_NB_CHANNEL_EVT_LOG2 2
#define ARCHI_SOC_EVENT_UDMA_NB_CHANNEL_EVT (1<<ARCHI_SOC_EVENT_UDMA_NB_CHANNEL_EVT_LOG2)
#define ARCHI_SOC_EVENT_UDMA_FIRST_EVT 0
#define ARCHI_SOC_EVENT_UDMA_NB_EVT (ARCHI_SOC_EVENT_UDMA_NB_CHANNEL_EVT * ARCHI_NB_PERIPH)
#define ARCHI_SOC_EVENT_UDMA_NB_EVT (ARCHI_SOC_EVENT_UDMA_NB_CHANNEL_EVT * ARCHI_NB_PERIPH_MAX)
#define ARCHI_SOC_EVENT_UDMA_NB_TGEN_EVT 6

#define ARCHI_SOC_EVENT_UDMA_NB_EVT_MAX 32*4
#define ARCHI_NB_PERIPH_MAX ((ARCHI_SOC_EVENT_UDMA_NB_EVT_MAX-ARCHI_UDMA_NB_SPIM_MAX-ARCHI_UDMA_NB_I2C_MAX)>>2)

#define ARCHI_SOC_EVENT_PERIPH_FIRST_EVT(x) ((x)*ARCHI_SOC_EVENT_UDMA_NB_CHANNEL_EVT)

#define ARCHI_SOC_EVENT_UART0_RX 0
Expand All @@ -176,6 +182,7 @@
#define ARCHI_SOC_EVENT_SPIM_TX (id) (5 + (id) * 4)
#define ARCHI_SOC_EVENT_SPIM_CMD(id) (6 + (id) * 4)
#define ARCHI_SOC_EVENT_SPIM_EOT(id) (7 + (id) * 4)
#define ARCHI_SOC_EVENT_SPIM_REQ(id) (ARCHI_SOC_EVENT_UDMA_NB_EVT + (id))

#define ARCHI_SOC_EVENT_I2C0_RX 8
#define ARCHI_SOC_EVENT_I2C0_TX 9
Expand Down Expand Up @@ -252,11 +259,12 @@

#define ARCHI_FC_EVT_FIRST_SW 0
#define ARCHI_FC_EVT_NB_SW 8
#define ARCHI_FC_EVT_TIMER0_LO 10
#define ARCHI_FC_EVT_TIMER0_HI 11
#define ARCHI_FC_EVT_TIMER0_LO 10
#define ARCHI_FC_EVT_TIMER0_HI 11
#define ARCHI_FC_EVT_I2C_SLV_BMC 13
#define ARCHI_FC_EVT_CLK_REF 14
#define ARCHI_FC_EVT_GPIO 15
#define ARCHI_FC_EVT_RTC 16
#define ARCHI_FC_EVT_I2C_SLV 16
#define ARCHI_FC_EVT_ADV_TIMER0 17
#define ARCHI_FC_EVT_ADV_TIMER1 18
#define ARCHI_FC_EVT_ADV_TIMER2 19
Expand Down
9 changes: 8 additions & 1 deletion include/archi/chips/control-pulp/pulp.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@

// cv32e40p-specific
#include "archi/cv32e40p/cv32e40p.h"
#include "archi/riscv/priv_1_11.h"
#include "archi/riscv/priv_1_12.h"

#include "archi/chips/control-pulp/memory_map.h"
#include "archi/chips/control-pulp/apb_soc.h"
#include "archi/stdout/stdout_v3.h"
// TODO: do we need to have this switch bounded to exact versions?
// Maybe better to bound them to dma type (mchan or idma)
#if MCHAN_VERSION == 7
#include "archi/dma/mchan_v7.h"
#endif
#if IDMA_VERSION == 1
#include "archi/dma/idma_v1.h"
#endif

#include "archi/udma/spim/udma_spim_v3.h"
#include "archi/udma/i2c/udma_i2c_v2.h"
Expand Down
121 changes: 121 additions & 0 deletions include/archi/chips/kairos/apb_soc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Copyright (C) 2018 ETH Zurich and University of Bologna
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the 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.
*/

#ifndef __ARCHI_KAIROS_APB_SOC_H__
#define __ARCHI_KAIROS_APB_SOC_H__

#define APB_SOC_BOOT_OTHER 0
#define APB_SOC_BOOT_JTAG 1
#define APB_SOC_BOOT_SPI 2
#define APB_SOC_BOOT_ROM 3
#define APB_SOC_BOOT_PRELOAD 4
#define APB_SOC_BOOT_HYPER 5
#define APB_SOC_BOOT_SPIM 6
#define APB_SOC_BOOT_SPIM_QPI 7

#define APB_SOC_PLT_OTHER 0
#define APB_SOC_PLT_FPGA 1
#define APB_SOC_PLT_RTL 2
#define APB_SOC_PLT_VP 3
#define APB_SOC_PLT_CHIP 4

//PADs configuration is made of 8bits out of which only the first 6 are used
//bit0 enable pull UP
//bit1 enable pull DOWN
//bit2 enable ST
//bit3 enable SlewRate Limit
//bit4..5 Driving Strength
//bit6..7 not used

#define APB_SOC_BOOTADDR_OFFSET 0x04
#define APB_SOC_INFO_OFFSET 0x00 //contains number of cores [31:16] and clusters [15:0]
#define APB_SOC_INFOEXTD_OFFSET 0x04 //not used at the moment
#define APB_SOC_NOTUSED0_OFFSET 0x08 //not used at the moment
#define APB_SOC_CLUSTER_ISOLATE_OFFSET 0x0C //not used at the moment

#define APB_SOC_PADFUN0_OFFSET 0x10
#define APB_SOC_PADCFG0_OFFSET 0x20

#define APB_SOC_PADFUN_OFFSET(g) (APB_SOC_PADFUN0_OFFSET+(g)*4) //sets the mux for pins g*16+0 (bits [1:0]) to g*16+15 (bits [31:30])
#define APB_SOC_PADFUN_NO(pad) ((pad) >> 4)
#define APB_SOC_PADFUN_PAD(padfun) ((padfun)*16)
#define APB_SOC_PADFUN_SIZE 2
#define ARCHI_APB_SOC_PADFUN_NB 4
#define APB_SOC_PADFUN_BIT(pad) (((pad) & 0xF) << 1)

#define APB_SOC_PADCFG_OFFSET(g) (APB_SOC_PADCFG0_OFFSET+(g)*4) //sets config for pin g*4+0(bits [7:0]) to pin g*4+3(bits [31:24])
#define APB_SOC_PADCFG_NO(pad) ((pad) >> 2)
#define APB_SOC_PADCFG_PAD(padfun) ((padfun)*4)
#define APB_SOC_PADCFG_SIZE 8
#define APB_SOC_PADCFG_BIT(pad) (((pad) & 0x3) << 3)

#define APB_SOC_PWRCMD_OFFSET 0x60 //change power mode(not funtional yet)
#define APB_SOC_PWRCFG_OFFSET 0x64 //configures power modes(not funtional yet)
#define APB_SOC_PWRREG_OFFSET 0x68 //32 bit GP register used by power pngmt routines to see if is hard or cold reboot
#define APB_SOC_BUSY_OFFSET 0x6C //not used at the moment
#define APB_SOC_MMARGIN_OFFSET 0x70 //memory margin pins(not used at the moment)
#define APB_SOC_JTAG_REG 0x74 // R/W register for interaction with the the chip environment
#define APB_SOC_L2_SLEEP_OFFSET 0x78 //memory margin pins(not used at the moment)
#define APB_SOC_NOTUSED3_OFFSET 0x7C //not used at the moment
#define APB_SOC_CLKDIV0_OFFSET 0x80 //soc clock divider(to be removed)
#define APB_SOC_CLKDIV1_OFFSET 0x84 //cluster clock divider(to be removed)
#define APB_SOC_CLKDIV2_OFFSET 0x88 //not used at the moment
#define APB_SOC_CLKDIV3_OFFSET 0x8C //not used at the moment
#define APB_SOC_CLKDIV4_OFFSET 0x90 //not used at the moment
#define APB_SOC_NOTUSED4_OFFSET 0x94 //not used at the moment
#define APB_SOC_NOTUSED5_OFFSET 0x98 //not used at the moment
#define APB_SOC_NOTUSED6_OFFSET 0x9C //not used at the moment
#define APB_SOC_CORESTATUS_OFFSET 0xA0 //32bit GP register to be used during testing to return EOC(bit[31]) and status(bit[30:0])
#define APB_SOC_CORESTATUS_RO_OFFSET 0xC0 //32bit GP register to be used during testing to return EOC(bit[31]) and status(bit[30:0])
#define APB_SOC_PADS_CONFIG 0xC4

#define APB_SOC_PADS_CONFIG_BOOTSEL_BIT 0

#define APB_SOC_JTAG_REG_EXT_BIT 8
#define APB_SOC_JTAG_REG_EXT_WIDTH 4

#define APB_SOC_JTAG_REG_LOC_BIT 0
#define APB_SOC_JTAG_REG_LOC_WIDTH 4

#define APB_SOC_INFO_CORES_OFFSET (APB_SOC_INFO_OFFSET + 2)
#define APB_SOC_INFO_CLUSTERS_OFFSET (APB_SOC_INFO_OFFSET)

#define APB_SOC_STATUS_EOC_BIT 31
#define APB_SOC_NB_CORE_BIT 16


#define APB_SOC_BYPASS_OFFSET 0x70

#define APB_SOC_BYPASS_CLOCK_GATE_BIT 10
#define APB_SOC_BYPASS_CLUSTER_STATE_BIT 3
#define APB_SOC_BYPASS_USER0_BIT 14
#define APB_SOC_BYPASS_USER1_BIT 15


#define APB_SOC_FLL_CTRL_OFFSET 0xD0
#define APB_SOC_CLKDIV_SOC_OFFSET 0xD4
#define APB_SOC_CLKDIV_CLUSTER_OFFSET 0xD8
#define APB_SOC_CLKDIV_PERIPH_OFFSET 0xDC


#define APB_SOC_FLL_CTRL_SOC_BIT 0
#define APB_SOC_FLL_CTRL_CLUSTER_BIT 1
#define APB_SOC_FLL_CTRL_PERIPH_BIT 2


#define APB_SOC_RTC_OFFSET 0x1D0

#endif
Loading

0 comments on commit 1ddf104

Please sign in to comment.