拆分主站从站软件

This commit is contained in:
RuigeLee
2024-10-29 11:21:04 +08:00
parent 8068a31e77
commit 683b6cad92
7 changed files with 268 additions and 44 deletions

49
tb/sw/src/slvMain.S Normal file
View File

@@ -0,0 +1,49 @@
#define cdr_0_tx_status 0x40000000
#define cdr_0_tx_txLen 0x40000004
#define cdr_0_tx_txFifo 0x40000008
#define cdr_0_rx_softReset 0x40000010
#define cdr_0_rx_status 0x40000014
#define cdr_0_rx_rxLen 0x40000018
#define cdr_0_rx_rxFifo 0x4000001c
#define cdr_1_tx_status 0x40000080
#define cdr_1_tx_txLen 0x40000084
#define cdr_1_tx_txFifo 0x40000088
#define cdr_1_rx_softReset 0x40000090
#define cdr_1_rx_status 0x40000094
#define cdr_1_rx_rxLen 0x40000098
#define cdr_1_rx_rxFifo 0x4000009c
.global main
main:
lui x5, %hi(cdr_0_tx_status)
li x6, 128
sw x6, 4(x5) #cdr_0_tx_txLen
li x6, 32 # 设置循环次数
1:
beqz x15, 3f # 如果x10为0,则跳到3
2:
li x15, 0 # 清标志位
lw x7, 0(x5) # 读取cdr_0_tx_status的值
andi x7, x7, 0x2 # 检查第1比特(位1)
bnez x7, 2b # 如果第1比特不为0,则回到2处继续循环
3:
# 向cdr_0_tx_txFifo地址写入0x55,循环32次
sw x6, 8(x5) # 向cdr_0_tx_txFifo写入0x55
addi x6, x6, -1 # 递减计数器
bnez x6, 1b # 如果计数器不为0,则继续循环
4:
j 4b

54
tb/sw/src/slvStartup.S Normal file
View File

@@ -0,0 +1,54 @@
#include "custom_ops.S"
.extern main
.globl _prog_start
.section .text.init
_prog_start:
li x15, 0
picorv32_maskirq_insn(zero, zero)
call main
li gp, 1;
ecall
.balign 32
.section .trap_entry, "ax", %progbits
trap_entry:
# q0 return address
# q1 bitmask of all IRQ to be handled, may be more than one IRQ
# q2 q3 unused, can be use as temp storage register
# q寄存器已经禁用, Without the q-registers, the irq return address will be stored in x3 (gp) and the IRQ bitmask in x4 (tp),
addi x15, x4, 0
picorv32_retirq_insn()