添加gpio测试,软件没有运行
This commit is contained in:
4
Makefile
4
Makefile
@@ -60,7 +60,7 @@ test:
|
||||
|
||||
|
||||
sw:
|
||||
|
||||
rm ./tb/sw/build/* -f
|
||||
|
||||
riscv64-unknown-elf-gcc -Os -ggdb -march=rv32i -mabi=ilp32 -Wall -mcmodel=medany -mexplicit-relocs -mcmodel=medany -mexplicit-relocs \
|
||||
-I ./tb/sw/ -I ./tb/sw/src \
|
||||
@@ -120,6 +120,8 @@ sw:
|
||||
riscv64-unknown-elf-objcopy -O verilog ./tb/sw/build/slvTest.elf ./tb/sw/build/slvTest.verilog
|
||||
sed -i 's/@800/@000/g' ./tb/sw/build/slvTest.verilog
|
||||
|
||||
python3 ./tb/sw/bin_to_hex.py
|
||||
|
||||
|
||||
fst:
|
||||
gtkwave ./tb/build/wave.fst &
|
||||
|
||||
24
tb/sw/bin_to_hex.py
Normal file
24
tb/sw/bin_to_hex.py
Normal file
@@ -0,0 +1,24 @@
|
||||
def bin_to_hex_file(bin_file, hex_file, address_depth=1024, data_width=32):
|
||||
# 打开二进制文件和输出的Hex文件
|
||||
with open(bin_file, 'rb') as bf, open(hex_file, 'w') as hf:
|
||||
# 写入文件头
|
||||
hf.write("#File_format=Hex\n")
|
||||
hf.write(f"#Address_depth={address_depth}\n")
|
||||
hf.write(f"#Data_width={data_width}\n")
|
||||
|
||||
# 读取二进制文件内容
|
||||
data = bf.read()
|
||||
|
||||
# 将二进制内容按每4字节分割并转换为十六进制字符串
|
||||
for i in range(address_depth):
|
||||
if i * 4 < len(data):
|
||||
# 提取4字节数据并转为32位的十六进制字符串
|
||||
value = int.from_bytes(data[i*4:(i+1)*4], byteorder='little')
|
||||
hf.write(f"{value:08X}\n")
|
||||
else:
|
||||
# 如果数据不够,填充0
|
||||
hf.write("00000000\n")
|
||||
|
||||
# 运行脚本
|
||||
bin_to_hex_file("./tb/sw/build/slvTest.bin", "./tb/sw/build/slvTest.mi")
|
||||
bin_to_hex_file("./tb/sw/build/mstTest.bin", "./tb/sw/build/mstTest.mi")
|
||||
@@ -44,6 +44,8 @@ void main()
|
||||
|
||||
uint32_t isLast;
|
||||
|
||||
uint32_t led = 0;
|
||||
|
||||
while(1){
|
||||
|
||||
*cdr_softReset = 1; //复位脉冲
|
||||
@@ -53,11 +55,19 @@ void main()
|
||||
"1:\n"
|
||||
"rdcycle ra\n"
|
||||
"srli ra, ra, 12\n"
|
||||
//"srli ra, ra, 26\n"
|
||||
// "srli ra, ra, 26\n"
|
||||
"andi ra, ra, 0x1\n"
|
||||
"beqz ra, 1b\n"
|
||||
);
|
||||
|
||||
if( led ){
|
||||
*WriteGpio = 0xFFFFFFFF;
|
||||
led = 0;
|
||||
} else{
|
||||
*WriteGpio = 0x0;
|
||||
led = 1;
|
||||
}
|
||||
|
||||
|
||||
//发送下行包头
|
||||
*cdr_txLen = 520; //总长520
|
||||
|
||||
@@ -48,6 +48,7 @@ void main()
|
||||
*cdr_softReset = 1; //复位脉冲
|
||||
isLast = *ReadIsLast;
|
||||
*cdr_direct = 0;
|
||||
*WriteGpio = 0xaaaa;
|
||||
|
||||
asm volatile (
|
||||
"1:\n"
|
||||
|
||||
Reference in New Issue
Block a user