-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix expected left budget (W/R) calculation * Extend to support multiple CVA6 cores
- Loading branch information
Showing
3 changed files
with
81 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,60 +3,95 @@ | |
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Thomas Benz <[email protected]> | ||
// Alessandro Ottaviano <[email protected]> | ||
// | ||
// Validate the budget functionality of AXI RT | ||
|
||
#include "axirt.h" | ||
#include "dif/dma.h" | ||
#include "regs/axi_rt.h" | ||
#include "params.h" | ||
#include "regs/axi_rt.h" | ||
#include "regs/cheshire.h" | ||
#include "util.h" | ||
|
||
// transfer | ||
#define SIZE_BYTES 256 | ||
#define SRC_STRIDE 0 | ||
#define DST_STRIDE 0 | ||
#define NUM_REPS 8 | ||
#define SRC_ADDR 0x0000000010000000 | ||
#define DST_ADDR 0x0000000080000000 | ||
#define SIZE_BEAT_BYTES 8 | ||
#define DMA_NUM_BEATS 32 | ||
#define DMA_NUM_REPS 8 | ||
#define DMA_SIZE_BYTES (SIZE_BEAT_BYTES * DMA_NUM_BEATS) | ||
#define DMA_TOTAL_SIZE_BYTES (DMA_SIZE_BYTES * DMA_NUM_REPS) | ||
#define DMA_SRC_STRIDE 0 | ||
#define DMA_DST_STRIDE 0 | ||
#define SRC_ADDR 0x0000000078000000 // L2 | ||
#define DST_ADDR 0x0000000080000000 // DRAM | ||
|
||
#define TOTAL_SIZE (SIZE_BYTES * NUM_REPS) | ||
// AXI-REALM | ||
#define CVA6_ALLOCATED_BUDGET 0x10000000 | ||
#define CVA6_ALLOCATED_PERIOD 0x10000000 | ||
#define DMA_ALLOCATED_BUDGET 0x10000000 | ||
#define DMA_ALLOCATED_PERIOD 0x10000000 | ||
#define FRAGMENTATION_SIZE_BEATS 1 // Max fragmentation applied to bursts | ||
|
||
int main(void) { | ||
|
||
uint32_t cheshire_num_harts = *reg32(&__base_regs, CHESHIRE_NUM_INT_HARTS_REG_OFFSET); | ||
|
||
// enable and configure axi rt with fragmentation of 8 beats | ||
__axirt_claim(1, 1); | ||
__axirt_set_len_limit_group(7, 0); | ||
__axirt_set_len_limit_group(FRAGMENTATION_SIZE_BEATS, 0); | ||
__axirt_set_len_limit_group(FRAGMENTATION_SIZE_BEATS, 1); | ||
fence(); | ||
|
||
// configure CVA6 | ||
__axirt_set_region(0, 0xffffffff, 0, 0); | ||
__axirt_set_region(0x100000000, 0xffffffffffffffff, 1, 0); | ||
__axirt_set_budget(0x10000000, 0, 0); | ||
__axirt_set_budget(0x10000000, 1, 0); | ||
__axirt_set_period(0x10000000, 0, 0); | ||
__axirt_set_period(0x10000000, 1, 0); | ||
// configure CVA6 cores | ||
for (enum axirealm_mngr_id id = AXIREALM_MNGR_ID_CVA60; id <= cheshire_num_harts; id++) { | ||
__axirt_set_region(0, 0xffffffff, 0, id); | ||
__axirt_set_region(0x100000000, 0xffffffffffffffff, 1, id); | ||
__axirt_set_budget(CVA6_ALLOCATED_BUDGET, 0, id); | ||
__axirt_set_budget(CVA6_ALLOCATED_BUDGET, 1, id); | ||
__axirt_set_period(CVA6_ALLOCATED_PERIOD, 0, id); | ||
__axirt_set_period(CVA6_ALLOCATED_PERIOD, 1, id); | ||
fence(); | ||
} | ||
|
||
// configure DMA | ||
__axirt_set_region(0, 0xffffffff, 0, 2); | ||
__axirt_set_region(0x100000000, 0xffffffffffffffff, 1, 2); | ||
__axirt_set_budget(0x10000000, 0, 2); | ||
__axirt_set_budget(0x10000000, 1, 2); | ||
__axirt_set_period(0x10000000, 0, 2); | ||
__axirt_set_period(0x10000000, 1, 2); | ||
__axirt_set_region(0, 0xffffffff, 0, AXIREALM_MNGR_ID_DMA); | ||
__axirt_set_region(0x100000000, 0xffffffffffffffff, 1, AXIREALM_MNGR_ID_DMA); | ||
__axirt_set_budget(DMA_ALLOCATED_BUDGET, 0, AXIREALM_MNGR_ID_DMA); | ||
__axirt_set_budget(DMA_ALLOCATED_BUDGET, 1, AXIREALM_MNGR_ID_DMA); | ||
__axirt_set_period(DMA_ALLOCATED_PERIOD, 0, AXIREALM_MNGR_ID_DMA); | ||
__axirt_set_period(DMA_ALLOCATED_PERIOD, 1, AXIREALM_MNGR_ID_DMA); | ||
fence(); | ||
|
||
// enable RT unit for DMA and CVA6 cores | ||
__axirt_enable((BIT(AXIREALM_MNGR_ID_CVA60) | BIT(AXIREALM_MNGR_ID_DMA))); | ||
fence(); | ||
|
||
volatile uint64_t *sys_src = (volatile uint64_t *)SRC_ADDR; | ||
volatile uint64_t *sys_dst = (volatile uint64_t *)DST_ADDR; | ||
|
||
// initialize src region | ||
for (int i = 0; i < DMA_NUM_BEATS; i++) { | ||
sys_src[i] = 0xcafedeadbaadf00d + i; | ||
fence(); | ||
} | ||
|
||
// enable RT unit for DMA and CVA6 | ||
__axirt_enable(0x5); | ||
// launch blocking DMA transfer | ||
sys_dma_2d_blk_memcpy(DST_ADDR, SRC_ADDR, DMA_SIZE_BYTES, DMA_DST_STRIDE, DMA_SRC_STRIDE, DMA_NUM_REPS); | ||
|
||
// launch DMA transfer | ||
sys_dma_2d_blk_memcpy(DST_ADDR, SRC_ADDR, SIZE_BYTES, DST_STRIDE, SRC_STRIDE, NUM_REPS); | ||
// Check DMA transfers against gold. | ||
for (volatile int i = 0; i < DMA_NUM_BEATS; i++) { | ||
CHECK_ASSERT(20, sys_dst[i] == sys_src[i]); | ||
} | ||
|
||
// read budget registers and compare | ||
volatile uint32_t read_budget = *reg32(&__base_axirt, AXI_RT_READ_BUDGET_LEFT_2_REG_OFFSET); | ||
volatile uint32_t write_budget = *reg32(&__base_axirt, AXI_RT_WRITE_BUDGET_LEFT_2_REG_OFFSET); | ||
// read budget registers for dma and compare | ||
volatile uint32_t dma_read_budget_left = *reg32(&__base_axirt, AXI_RT_READ_BUDGET_LEFT_4_REG_OFFSET); | ||
volatile uint32_t dma_write_budget_left = *reg32(&__base_axirt, AXI_RT_WRITE_BUDGET_LEFT_4_REG_OFFSET); | ||
|
||
// check | ||
volatile uint8_t difference = (TOTAL_SIZE - read_budget) + (TOTAL_SIZE - write_budget); | ||
volatile uint8_t mismatch = read_budget != write_budget; | ||
// check budget: return 0 if (initial budget - final budget) matches number of transferred bytes, otherwise return 1 | ||
volatile uint8_t dma_r_difference = (DMA_ALLOCATED_BUDGET - dma_read_budget_left) != DMA_TOTAL_SIZE_BYTES; | ||
volatile uint8_t dma_w_difference = (DMA_ALLOCATED_BUDGET - dma_write_budget_left) != DMA_TOTAL_SIZE_BYTES; | ||
// w and r are symmetric on the dma: left budgets should be equal | ||
volatile uint8_t dma_rw_mismatch = dma_read_budget_left != dma_write_budget_left; | ||
|
||
return mismatch | (difference << 1); | ||
return dma_rw_mismatch | dma_r_difference | dma_w_difference; | ||
} |