Remove all debug and printf

This commit is contained in:
2026-06-25 15:44:18 +08:00
parent b331301584
commit 57ba5d271d
12 changed files with 587 additions and 419 deletions

View File

@@ -341,8 +341,6 @@ module matmul_axi_slave (
if (c0_part == 2'd0) s_axi_rdata = target_c0[31:0]; if (c0_part == 2'd0) s_axi_rdata = target_c0[31:0];
else if (c0_part == 2'd1) s_axi_rdata = target_c0[63:32]; else if (c0_part == 2'd1) s_axi_rdata = target_c0[63:32];
else s_axi_rdata = {30'b0, target_c0[65:64]}; else s_axi_rdata = {30'b0, target_c0[65:64]};
$display("RCH B0_C off=%h elem=%d part=%d data=%h raw=%h",
current_r_offset, c0_elem, c0_part, s_axi_rdata, target_c0);
end end
else if (current_r_offset >= ADDR_B1_A && current_r_offset < ADDR_B1_B) else if (current_r_offset >= ADDR_B1_A && current_r_offset < ADDR_B1_B)
s_axi_rdata = b1_a[(current_r_offset - ADDR_B1_A) >> 2]; s_axi_rdata = b1_a[(current_r_offset - ADDR_B1_A) >> 2];
@@ -352,8 +350,6 @@ module matmul_axi_slave (
if (c1_part == 2'd0) s_axi_rdata = target_c1[31:0]; if (c1_part == 2'd0) s_axi_rdata = target_c1[31:0];
else if (c1_part == 2'd1) s_axi_rdata = target_c1[63:32]; else if (c1_part == 2'd1) s_axi_rdata = target_c1[63:32];
else s_axi_rdata = {30'b0, target_c1[65:64]}; else s_axi_rdata = {30'b0, target_c1[65:64]};
$display("RCH B1_C off=%h elem=%d part=%d data=%h raw=%h",
current_r_offset, c1_elem, c1_part, s_axi_rdata, target_c1);
end end
end end
end end
@@ -449,10 +445,6 @@ module matmul_axi_slave (
else else
b1_c[calc_idx] <= ({2'b0, mult_p_r[0]} + {2'b0, mult_p_r[1]}) + b1_c[calc_idx] <= ({2'b0, mult_p_r[0]} + {2'b0, mult_p_r[1]}) +
({2'b0, mult_p_r[2]} + {2'b0, mult_p_r[3]}); ({2'b0, mult_p_r[2]} + {2'b0, mult_p_r[3]});
$display("ACCUM calc_idx=%d expr=%h",
calc_idx,
({2'b0, mult_p_r[0]} + {2'b0, mult_p_r[1]}) +
({2'b0, mult_p_r[2]} + {2'b0, mult_p_r[3]}));
if (calc_idx == 4'd15) begin if (calc_idx == 4'd15) begin
calc_done_pulse <= 1'b1; calc_done_pulse <= 1'b1;

File diff suppressed because it is too large Load Diff

BIN
sdk/fft.bin Executable file

Binary file not shown.

BIN
sdk/fft_dma.bin Executable file

Binary file not shown.

View File

@@ -195,17 +195,6 @@ int main(void)
dma_start_transfer(1, phys_bank_C[(MATMUL_GROUP_NUM - 1) % 2], EXTRAM_PHYS_C(MATMUL_GROUP_NUM - 1), 192, 20); dma_start_transfer(1, phys_bank_C[(MATMUL_GROUP_NUM - 1) % 2], EXTRAM_PHYS_C(MATMUL_GROUP_NUM - 1), 192, 20);
dma_wait_polling(1); // 必须等待最后一组写回完成 dma_wait_polling(1); // 必须等待最后一组写回完成
/* ── DEBUG: read back specific C elements from ExtRAM ─────── */
#define C_WORD(g, elem, part) extram[DST_BASE_WORDS + (g)*48 + (elem)*3 + (part)]
printf("DBG g=0 C00=[%08lx %08lx %08lx] C11=[%08lx %08lx %08lx] C23=[%08lx %08lx %08lx]\n",
C_WORD(0,0,0),C_WORD(0,0,1),C_WORD(0,0,2),
C_WORD(0,5,0),C_WORD(0,5,1),C_WORD(0,5,2),
C_WORD(0,11,0),C_WORD(0,11,1),C_WORD(0,11,2));
printf("DBG g=1 C00=[%08lx %08lx %08lx] C11=[%08lx %08lx %08lx] C23=[%08lx %08lx %08lx]\n",
C_WORD(1,0,0),C_WORD(1,0,1),C_WORD(1,0,2),
C_WORD(1,5,0),C_WORD(1,5,1),C_WORD(1,5,2),
C_WORD(1,11,0),C_WORD(1,11,1),C_WORD(1,11,2));
/* ── CRC32 over result region ─────────────────────────────── */ /* ── CRC32 over result region ─────────────────────────────── */
crc = compute_crc32(extram); crc = compute_crc32(extram);

View File

@@ -0,0 +1,14 @@
#include "fft.h"
#include "common_func.h"
void fft_start() {
RegWrite(FFT_CSR_REG, FFT_CTRL_START);
}
void fft_wait() {
while ((RegRead(FFT_CSR_REG) & FFT_STAT_DONE) == 0) {}
}
unsigned int fft_get_csr() {
return RegRead(FFT_CSR_REG);
}

View File

@@ -0,0 +1,16 @@
#pragma once
#define FFT_BASE 0xbf400000
#define FFT_IN_RE_BASE (FFT_BASE + 0x1000)
#define FFT_IN_IM_BASE (FFT_BASE + 0x2000)
#define FFT_OUT_RE_BASE (FFT_BASE + 0x3000)
#define FFT_OUT_IM_BASE (FFT_BASE + 0x4000)
#define FFT_CSR_REG (FFT_BASE + 0xF000)
#define FFT_CTRL_START (1 << 4)
#define FFT_STAT_DONE (1 << 1)
#define FFT_STAT_BUSY (1 << 0)
#define FFT_POINT_NUM 1024
void fft_start();
void fft_wait();
unsigned int fft_get_csr();

View File

@@ -0,0 +1,37 @@
#include "dma.h"
void dma_start_transfer(int ch_id, uint32_t src, uint32_t dst, uint32_t bytes, uint32_t tag) {
volatile dma_ch_regs_t* ch = DMA_CH(ch_id);
// 检查通道是否空闲 防止覆盖正在运行的任务
if (ch->STATUS & STATUS_BUSY_BIT) {
// printf("channel %d busy\n", ch_id);
return; // 通道正忙,处理报错或重试
}
// 写入基本地址和长度
ch->SRC_ADDR = src;
ch->DST_ADDR = dst;
ch->LENGTH = bytes;
ch->TAG = tag; // 可选,填入任务ID
// 置 Burst 属性并触发传输
// AXI SIZE: 2 (代表 2^2 = 4 Bytes,与 32-bit 数据线匹配)
// AXI LEN: 15 (代表 16 beats 突发传输,最高效)
uint32_t ctrl_val = CTRL_BURST_SIZE(2) | CTRL_BURST_LEN(15);
// 写入 CTRL 并拉高 Bit 0 (Start)
ch->CTRL = ctrl_val | CTRL_START_BIT;
}
void dma_wait_polling(int ch_id) {
volatile dma_ch_regs_t* ch = DMA_CH(ch_id);
// 死等 Done bit 置 1
while (!(ch->STATUS & STATUS_DONE_BIT)) {
}
// 清除 Done 标志位 (Write 1 to Clear Bit 1)
// 注意:写 1 清 0 的设计,所以我们对 bit 1 写入 1
ch->STATUS = STATUS_DONE_BIT;
}

View File

@@ -0,0 +1,30 @@
#pragma once
#include <stdint.h>
typedef struct {
volatile uint32_t SRC_ADDR; // 0x00: 源地址
volatile uint32_t DST_ADDR; // 0x04: 目的地址
volatile uint32_t LENGTH; // 0x08: 传输总字节数
volatile uint32_t TAG; // 0x0C: 软件 Tag (硬件不处理,留给软件标记任务用)
volatile uint32_t CTRL; // 0x10: 控制寄存器 (配置 Burst 属性 + 启动)
volatile uint32_t STATUS; // 0x14: 状态寄存器 (Busy, Done)
volatile uint32_t RESV[10]; // 0x18 ~ 0x3C: 保留空间,凑齐 0x40 字节
} dma_ch_regs_t;
// DMA 控制器基地址
#define CDMA_MUX_BASE 0xbf300000
#define DMA_CH(i) ((volatile dma_ch_regs_t*)(CDMA_MUX_BASE + (i) * 0x40))
// CTRL 寄存器位定义
#define CTRL_START_BIT (1 << 0)
#define CTRL_BURST_SIZE(x) (((x) & 0x7) << 3) // Bits [5:3]: AXI AxSIZE (0=1B, 1=2B, 2=4B, 3=8B)
#define CTRL_BURST_LEN(x) (((x) & 0xFF) << 6) // Bits [13:6]: AXI AxLEN (0=1 beat, 15=16 beats)
// STATUS 寄存器位定义
#define STATUS_BUSY_BIT (1 << 0)
#define STATUS_DONE_BIT (1 << 1)
void dma_start_transfer(int ch_id, uint32_t src, uint32_t dst, uint32_t bytes, uint32_t tag);
void dma_wait_polling(int ch_id);

View File

@@ -0,0 +1,14 @@
#include "fft.h"
#include "common_func.h"
void fft_start() {
RegWrite(FFT_CSR_REG, FFT_CTRL_START);
}
void fft_wait() {
while ((RegRead(FFT_CSR_REG) & FFT_STAT_DONE) == 0) {}
}
unsigned int fft_get_csr() {
return RegRead(FFT_CSR_REG);
}

View File

@@ -0,0 +1,16 @@
#pragma once
#define FFT_BASE 0xbf400000
#define FFT_IN_RE_BASE (FFT_BASE + 0x1000)
#define FFT_IN_IM_BASE (FFT_BASE + 0x2000)
#define FFT_OUT_RE_BASE (FFT_BASE + 0x3000)
#define FFT_OUT_IM_BASE (FFT_BASE + 0x4000)
#define FFT_CSR_REG (FFT_BASE + 0xF000)
#define FFT_CTRL_START (1 << 4)
#define FFT_STAT_DONE (1 << 1)
#define FFT_STAT_BUSY (1 << 0)
#define FFT_POINT_NUM 1024
void fft_start();
void fft_wait();
unsigned int fft_get_csr();

Binary file not shown.