Add matmul AXI master path
This commit is contained in:
108
sdk/axi_ram.mif
108
sdk/axi_ram.mif
@@ -52,7 +52,7 @@
|
||||
00000011100000000110000000001101
|
||||
00000100000000000000000110101100
|
||||
00011100000000000000000000101100
|
||||
00000010101100111111000110001100
|
||||
00000010101101001111000110001100
|
||||
00011100000000000001000000001101
|
||||
00000010101111001001000110101101
|
||||
00011100000000000001000000001110
|
||||
@@ -94,7 +94,7 @@
|
||||
00000000000101010000000000001110
|
||||
00101001000000000001000110101110
|
||||
00011100000000000000000000001100
|
||||
00000010100011000001000110001100
|
||||
00000010100011010001000110001100
|
||||
00000100000000000011000000101100
|
||||
00000011100000000000010000001101
|
||||
00000100000000010001000000101101
|
||||
@@ -146,67 +146,70 @@
|
||||
00010101011111100000000000010000
|
||||
00101001100000000111000001100001
|
||||
00101001100000000110000001110111
|
||||
00101001100000000101000001111000
|
||||
00000010100000010011010000001100
|
||||
00011100000000000001000000001111
|
||||
00000010101101101011000111101111
|
||||
00000010101101101010000111101111
|
||||
00000011100000000001011000001101
|
||||
00101001100000000011000001101100
|
||||
00101010000000000011000001101110
|
||||
00000010100000000000010111101111
|
||||
00000011010000000000000000000000
|
||||
00101010000000000000000110101100
|
||||
00000011010000001000000110001100
|
||||
01011011111111111111100110000000
|
||||
00101001000000000000001000001110
|
||||
00101000000000000000000111101100
|
||||
01011111111111111101110110000000
|
||||
01010100000001100011100000000000
|
||||
00010101011111100110000000001100
|
||||
00000011100010000000000110001100
|
||||
00000010100000000000100000001110
|
||||
00101001100000000001000110001110
|
||||
00010100001110001000000000001101
|
||||
00101001100000000010000110001101
|
||||
00000011100101000000000110110011
|
||||
00000010100000000010100000010010
|
||||
00101001100000000011000110010011
|
||||
00101001100000000100000110010010
|
||||
00010100001111101010000000010001
|
||||
00000010100000100000000000010000
|
||||
00101001100000000101000110010001
|
||||
00101001100000000110000110010000
|
||||
00000010100000110000000000001111
|
||||
00000010100000000000010000001110
|
||||
00101001100000000111000110001111
|
||||
00000000000101010000000010010111
|
||||
00000000000101010000000110001101
|
||||
01011111111111111110000110000000
|
||||
01010100000001100111100000000000
|
||||
00010101011111101010000000001100
|
||||
00000011100000000100000110010001
|
||||
00101001100000000000001000100000
|
||||
00000010100000000101100000010000
|
||||
00000011100000000001000110001101
|
||||
00101001100000000000000110110000
|
||||
00010100001110001000000000001110
|
||||
00000011100000001000000110001111
|
||||
00101001100000000000000111101110
|
||||
00000011100101000000000111000101
|
||||
00000000000101010000000010011000
|
||||
00000011100000001001000110000100
|
||||
00101001100000000000000010000101
|
||||
00000011100000001010000110010011
|
||||
00000010100000000010100000010100
|
||||
00101001100000000000001001110100
|
||||
00000011100000001011000110010001
|
||||
00000010100000100000000000010010
|
||||
00101001100000000000001000110010
|
||||
00000011100000001100000110001111
|
||||
00000010100000110000000000010000
|
||||
00000010100001000000000000001110
|
||||
00101001100000000000000111110000
|
||||
00010101011111101010000000010111
|
||||
00101001100000000000000110001110
|
||||
00000011010000000000000000000000
|
||||
00101000100000000001000110101100
|
||||
00000011010000000000100110001100
|
||||
00101000100000000000000110101100
|
||||
00000011010000000100000110001100
|
||||
01011011111111111111100110000000
|
||||
00000010100000000000100000001100
|
||||
00101001100000000001000110101100
|
||||
01010100000001011100110000000000
|
||||
00011100000000000001000000001110
|
||||
00000010101101011000000111001110
|
||||
00101000100000000000000111010010
|
||||
00010101011111101010000000001101
|
||||
00000010100000000100000000001100
|
||||
00101001100000000000000110101100
|
||||
01010100000001011111110000000000
|
||||
00011100000000000001000000001101
|
||||
00000010101101010100000110101101
|
||||
00000011100000000100001011110111
|
||||
00101000100000000000000110110010
|
||||
00101000100000000000001011110001
|
||||
00010100000000000001111010001100
|
||||
00000011100000000100000110101101
|
||||
00010101011111100000000000010000
|
||||
00000011100010010000000110001110
|
||||
00000000000100010101110010000100
|
||||
00000000000100010110000010000100
|
||||
00000000001000010011101001010011
|
||||
01011100000000000000100111000000
|
||||
00000000001010100000000000000111
|
||||
00101000100000000000000110110001
|
||||
00000010100000010011010000001100
|
||||
00000000001000010100110010010010
|
||||
01011100000000000000101001100000
|
||||
00000000001010100000000000000111
|
||||
00000010100000010011010000001100
|
||||
00011100000000000001000000001111
|
||||
00000010101100110101000111101111
|
||||
00000010101100110010000111101111
|
||||
00000011100000000001011000001101
|
||||
00101001100000000011000001101100
|
||||
00101010000000000011000001101110
|
||||
@@ -222,6 +225,7 @@
|
||||
00000010100000000010010000010100
|
||||
00000010101111111111000000010011
|
||||
00000011100000000001011000001101
|
||||
00000011010000000000000000000000
|
||||
00000000000101111011101000101100
|
||||
00000011010000000011110110001100
|
||||
00000010100000010101110110001111
|
||||
@@ -236,7 +240,7 @@
|
||||
00010101011111100000000000010000
|
||||
00000010100000000011010000001100
|
||||
00011100000000000001000000001111
|
||||
00000010101100011011000111101111
|
||||
00000010101100010111000111101111
|
||||
00000011100000000001011000001101
|
||||
00101001100000000011000001101100
|
||||
00101010000000000011000001101110
|
||||
@@ -248,11 +252,11 @@
|
||||
00101001000000000000001000001110
|
||||
00101000000000000000000111101100
|
||||
01011111111111111101110110000000
|
||||
01010100000000101001100000000000
|
||||
01010100000000101100100000000000
|
||||
00010101011111100000000000010000
|
||||
00000010100000000011010000001100
|
||||
00011100000000000001000000001111
|
||||
00000010101100010000000111101111
|
||||
00000010101100001100000111101111
|
||||
00000011100000000001011000001101
|
||||
00101001100000000011000001101100
|
||||
00101010000000000011000001101110
|
||||
@@ -265,11 +269,11 @@
|
||||
00101000000000000000000111101100
|
||||
01011111111111111101110110000000
|
||||
00000000000101010000001001000100
|
||||
01010100000000100101010000000000
|
||||
01010100000000101000010000000000
|
||||
00010101011111100000000000010000
|
||||
00000010100000000011010000001100
|
||||
00011100000000000001000000001111
|
||||
00000010101100000100000111101111
|
||||
00000010101100000000000111101111
|
||||
00000011100000000001011000001101
|
||||
00101001100000000011000001101100
|
||||
00101010000000000011000001101110
|
||||
@@ -282,10 +286,22 @@
|
||||
01011111111111111110000110000000
|
||||
00101000100000000111000001100001
|
||||
00101000100000000110000001110111
|
||||
00101000100000000101000001111000
|
||||
00000000000101010000000000000100
|
||||
00000010100000001000000001100011
|
||||
01001100000000000000000000100000
|
||||
00000011010000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000000000000000000000000000000
|
||||
00000010101111100001000001100011
|
||||
00101001100000011110000001100001
|
||||
00101001100000011101000001100010
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
/**
|
||||
* user-sample - CIC-IEC 2026 Stage 3 Evaluation Program
|
||||
*
|
||||
* (ULTIMATE PERFORMANCE DMA + PING-PONG BUFFER ARCHITECTURE v2)
|
||||
*
|
||||
* Optimizations over v1:
|
||||
* 1. Pre-fire DMA Ch0 load at loop tail → fully overlaps with IP compute
|
||||
* 2. Inlined wait loops → zero function-call overhead in hot path
|
||||
* 3. Inlined DMA start → skips redundant STATUS_BUSY_BIT check
|
||||
* 4. XOR bank toggle → avoids g%2 recomputation per iteration
|
||||
* Matmul AXI-master path.
|
||||
*/
|
||||
|
||||
#include <dma.h>
|
||||
@@ -82,12 +76,19 @@ unsigned long CORE_CLOCKS_PER_SEC = 33000000L;
|
||||
|
||||
#define MATMUL_CTRL (MATMUL_BASE_UNCACHED + 0x000)
|
||||
#define MATMUL_STATUS (MATMUL_BASE_UNCACHED + 0x004)
|
||||
#define MATMUL_BASE_PHYS_FOR_DMA MATMUL_BASE_PHYS
|
||||
#define MATMUL_DMA_SRC_BASE (MATMUL_BASE_UNCACHED + 0x020)
|
||||
#define MATMUL_DMA_DST_BASE (MATMUL_BASE_UNCACHED + 0x024)
|
||||
#define MATMUL_DMA_GROUPS (MATMUL_BASE_UNCACHED + 0x028)
|
||||
#define MATMUL_DMA_SRC_STRIDE (MATMUL_BASE_UNCACHED + 0x02C)
|
||||
#define MATMUL_DMA_DST_STRIDE (MATMUL_BASE_UNCACHED + 0x030)
|
||||
|
||||
#define CTRL_START_B0 0x1
|
||||
#define CTRL_START_B1 0x2
|
||||
#define CTRL_DMA_START (1 << 8)
|
||||
#define STATUS_DONE 0x2
|
||||
#define STATUS_ERROR 0x4
|
||||
#define STATUS_DMA_BUSY (1 << 3)
|
||||
#define STATUS_DMA_DONE (1 << 4)
|
||||
|
||||
#define MATMUL_CRC (MATMUL_BASE_UNCACHED + 0x010)
|
||||
|
||||
@@ -101,8 +102,9 @@ int main(void)
|
||||
if (MATMUL_GROUP_NUM <= 0) return 0;
|
||||
|
||||
/* ── Hot-path local volatile pointers (one-time addr calc) ──────── */
|
||||
volatile unsigned int *mat_crc = (volatile unsigned int *)MATMUL_CRC;
|
||||
volatile dma_seq_regs_t *seq = DMA_SEQ;
|
||||
volatile unsigned int *mat_ctrl = (volatile unsigned int *)MATMUL_CTRL;
|
||||
volatile unsigned int *mat_status = (volatile unsigned int *)MATMUL_STATUS;
|
||||
volatile unsigned int *mat_crc = (volatile unsigned int *)MATMUL_CRC;
|
||||
|
||||
unsigned int crc;
|
||||
unsigned int cycle_start, cycle_end, cycles, time_us;
|
||||
@@ -111,16 +113,16 @@ int main(void)
|
||||
uart_puts("MATMUL_START\r\n");
|
||||
cycle_start = get_clock_count();
|
||||
|
||||
seq->STATUS = SEQ_DONE_BIT;
|
||||
seq->SRC_BASE = EXTRAM_PHYS_AB(0);
|
||||
seq->DST_BASE = EXTRAM_PHYS_C(0);
|
||||
seq->GROUPS = MATMUL_GROUP_NUM;
|
||||
seq->MAT_BASE = MATMUL_BASE_PHYS_FOR_DMA;
|
||||
seq->SRC_STRIDE = 128;
|
||||
seq->DST_STRIDE = 192;
|
||||
seq->CTRL = SEQ_START_BIT;
|
||||
while (!(seq->STATUS & SEQ_DONE_BIT)) {}
|
||||
seq->STATUS = SEQ_DONE_BIT;
|
||||
*(volatile unsigned int *)MATMUL_CRC = 0;
|
||||
*mat_status = STATUS_DMA_DONE | STATUS_DONE | STATUS_ERROR;
|
||||
*(volatile unsigned int *)MATMUL_DMA_SRC_BASE = EXTRAM_PHYS_AB(0);
|
||||
*(volatile unsigned int *)MATMUL_DMA_DST_BASE = EXTRAM_PHYS_C(0);
|
||||
*(volatile unsigned int *)MATMUL_DMA_GROUPS = MATMUL_GROUP_NUM;
|
||||
*(volatile unsigned int *)MATMUL_DMA_SRC_STRIDE = 128;
|
||||
*(volatile unsigned int *)MATMUL_DMA_DST_STRIDE = 192;
|
||||
*mat_ctrl = CTRL_DMA_START;
|
||||
while (!(*mat_status & STATUS_DMA_DONE)) {}
|
||||
*mat_status = STATUS_DMA_DONE;
|
||||
cycle_end = get_clock_count();
|
||||
cycles = cycle_end - cycle_start;
|
||||
time_us = cycles / (CORE_CLOCKS_PER_SEC / 1000000UL);
|
||||
|
||||
Reference in New Issue
Block a user